Skip to content

Commit

Permalink
Keep processing other sentences when errors happen
Browse files Browse the repository at this point in the history
  • Loading branch information
letuananh committed Sep 26, 2017
1 parent b299e5f commit 7caf0f4
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions coolisf/ghub.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,28 @@ def parse_many_iterative(self, texts, parse_count=None, extra_args=None, ignore_
continue
# not in cache then ...
s = Sentence(text)
# preprocessor
if self.preps:
for prep in self.preps:
prep.process(s)
result = parser.interact(s.text)
if result and 'RESULTS' in result:
top_res = result['RESULTS']
for mrs in top_res:
parse = s.add(mrs['MRS'])
if self.posts:
for p in self.posts:
p.process(parse)
# cache it
if self.cache:
self.cache.save(s, self.name, parse_count, exargs_str, ctx=ctx)
try:
# preprocessors
if self.preps:
for prep in self.preps:
prep.process(s)
# interact with grammar
result = parser.interact(s.text)
# postprocessors
if result and 'RESULTS' in result:
top_res = result['RESULTS']
for mrs in top_res:
parse = s.add(mrs['MRS'])
if self.posts:
for p in self.posts:
p.process(parse)
# cache it
if self.cache:
self.cache.save(s, self.name, parse_count, exargs_str, ctx=ctx)
except Exception as e:
s.flag = Sentence.ERROR
s.comment = "This sentence is not fully processed"
logger.exception("Error happened while processing sentence: {}".format(text))
yield s

def parse_many(self, texts, parse_count=None, extra_args=None, ignore_cache=False):
Expand Down

0 comments on commit 7caf0f4

Please sign in to comment.