-
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
Showing
1 changed file
with
9 additions
and
15 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 |
---|---|---|
@@ -1,27 +1,21 @@ | ||
import sys | ||
from freeling.freeling_API.tokenize_and_tag import Freeling_tok_tagger | ||
from tokenize_and_tag import Freeling_tok_tagger | ||
from srg_freeling2yy import convert_sentences | ||
|
||
|
||
if __name__ == "__main__": | ||
# read input from file or standard input; sentences are separated by one | ||
# or more blank lines. Put the sentence through freeling and convert the | ||
# output to YY input format. | ||
# read input from file or standard input, one sentence per line. Put each | ||
# sentence through FreeLing and convert the output to YY input format. | ||
ftok = Freeling_tok_tagger() | ||
if len(sys.argv) < 2 or sys.argv[1] == "-": | ||
f = sys.stdin | ||
else: | ||
f = open(sys.argv[1], 'r') | ||
sent = "" | ||
for ln in f: | ||
if ln.strip() == "": # inter-sentence blank line? | ||
if sent != "": | ||
freeling_s = ftok.tokenize_and_tag([sent]) | ||
print(convert_sentences([freeling_s[0]])) | ||
sent = "" | ||
for sent in f: | ||
if sent.strip() == "": # FreeLing doesn't cope well with empty input | ||
print("") | ||
else: | ||
sent += ln | ||
if sent != "": | ||
freeling_s = ftok.tokenize_and_tag([sent]) | ||
print(convert_sentences([freeling_s[0]])) | ||
freeling_s = ftok.tokenize_and_tag([sent]) | ||
print(convert_sentences([freeling_s[0]])[0]) | ||
if f is not sys.stdin: | ||
f.close() |