-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.py
executable file
·27 lines (22 loc) · 907 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
from frog import Frog, FrogOptions
import folia.main as folia
frog = Frog(FrogOptions(parser=True))
output = frog.process_raw("Dit is een test")
print("RAW OUTPUT=",output)
assert output
output = frog.process("Dit is nog een test.")
print("PARSED OUTPUT=",output)
assert output
frog = Frog(FrogOptions(parser=True,xmlout=True))
output = frog.process("Dit is een FoLiA test.")
assert isinstance(output, folia.Document)
assert len(output.data) == 1
assert next(output.select(folia.Sentence)).text() == "Dit is een FoLiA test."
#output is now no longer a string but an instance of folia.Document, provided by the FoLiA library in PyNLPl (pynlpl.formats.folia)
print("FOLIA OUTPUT=")
print(output.xmlstring())
print("Inspecting FoLiA output (example):")
for word in output.words():
print(word.text() + " " + word.pos() + " " + word.lemma())
assert len(list(output.words())) == 6