Created
March 20, 2020 20:20
-
-
Save ozekik/636a8fb521401070e02e010ce591fa92 to your computer and use it in GitHub Desktop.
LightRDF Bench 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lightrdf | |
import sys | |
parser = lightrdf.nt.Parser() | |
cnt = 0 | |
for triple in parser.parse(sys.argv[1]): | |
cnt += 1 | |
print(cnt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rdflib.plugins.parsers.ntriples import NTriplesParser | |
import sys | |
class Sink(object): | |
def __init__(self): | |
self.cnt = 0 | |
def triple(self, s, p, o): | |
self.cnt += 1 | |
sink = Sink() | |
parser = NTriplesParser(sink) | |
with open(sys.argv[1], "rb") as f: | |
parser.parse(f) | |
print(sink.cnt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment