-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f98c9ad
commit 2e19caa
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import stanza | ||
|
||
language = input() | ||
try: | ||
nlp = stanza.Pipeline(language) | ||
except ValueError: | ||
exit(1) | ||
print("done") | ||
|
||
while True: | ||
contents = "" | ||
while True: | ||
line = input() | ||
if line == "": | ||
break; | ||
contents += line + "\n" | ||
|
||
doc = nlp(contents) | ||
|
||
print("[") | ||
for sent_index, sent in enumerate(doc.sentences): | ||
for word_index, word in enumerate(sent.words): | ||
# If it's not the first word, print a comma to conform to json syntax | ||
if not (word_index == 0 and sent_index == 0): | ||
print(",") | ||
print(word, end="") | ||
print("\n]") |