Skip to content

Commit

Permalink
more reading mode
Browse files Browse the repository at this point in the history
  • Loading branch information
letuananh committed Apr 24, 2019
1 parent be325c8 commit 1f26a6f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions coolisf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def getLogger():
# Functions
# ----------------------------------------------------------------------

def read_ace_output(ace_output_file):
def read_ace_output(ace_output_file, top1dmrs=False):
''' Read output file from ACE batch mode
Sample command: ace -g grammar.dat infile.txt > outfile.txt
Read more: http://moin.delph-in.net/AceOptions
Expand All @@ -79,10 +79,19 @@ def read_ace_output(ace_output_file):
# item = [line, mrs_line]
s = Sentence(line[5:], ID=current_sid)
doc.add(s)
while mrs_line.strip():
s.add(mrs_line)
mrs_line = input_mrs.readline()
input_mrs.readline()
if not top1dmrs:
while mrs_line.strip():
s.add(mrs_line)
mrs_line = input_mrs.readline()
input_mrs.readline()
else:
# all lines = a single DMRS
dmrs_text = ''
while mrs_line.strip():
dmrs_text += mrs_line
mrs_line = input_mrs.readline()
input_mrs.readline()
s.add(dmrs_text)
c.count('sent')
c.count('total')
elif line.startswith('SKIP'):
Expand Down

0 comments on commit 1f26a6f

Please sign in to comment.