Ivan Kovatchev (Triply Support)

ivan
Member since Sep 2nd, 2020
Site administrator
Organizations

The first 50000 natural numbers:

#! /usr/bin/env python3
"""
Generate the natural numbers in turtle format.
"""
from argparse import ArgumentParser

ARGV_OVERRIDE = None
# ARGV_OVERRIDE = ["10"]

HEADER = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
""".strip()
LINE_FORMAT = '<http://dbpedia.org/resource/{number}_(number)> rdf:value' \
    '"{number}"^^xsd:positiveInteger .'

parser = ArgumentParser(description=__doc__)
parser.add_argument(
    "n",
    help="Number of positive integers to calculate",
    type=int)

n = parser.parse_args(ARGV_OVERRIDE).n

print(HEADER)
for i in range(1, n + 1):
    print(LINE_FORMAT.format(number=i))