Пример #1
0
 def __str__(self):
     """Represent the n-best list in a similar output format to the
     command-line parser and reranker."""
     if self._reranked:
         from cStringIO import StringIO
         combined = StringIO()
         combined .write('%d dummy\n' % len(self.parses))
         for parse in self.parses:
             combined.write('%s %s\n%s\n' % \
                 (parse.reranker_score, parse.parser_score, parse.ptb_parse))
         combined.seek(0)
         return combined.read()
     else:
         return parser.asNBestList(self._parses)
Пример #2
0
 def __str__(self):
     """Represent the n-best list in a similar output format to the
     command-line parser and reranker."""
     if self._reranked:
         from cStringIO import StringIO
         combined = StringIO()
         combined.write('%d dummy\n' % len(self.parses))
         for parse in self.parses:
             combined.write('%s %s\n%s\n' % \
                 (parse.reranker_score, parse.parser_score, parse.ptb_parse))
         combined.seek(0)
         return combined.read()
     else:
         return parser.asNBestList(self._parses)
Пример #3
0
 def __str__(self):
     """Represent the n-best list in a similar output format to the
     command-line parser and reranker."""
     sentence_id = self.sentence_id or 'x'
     if self._reranked:
         from cStringIO import StringIO
         combined = StringIO()
         combined.write('%d %s\n' % (len(self.parses), sentence_id))
         for parse in self.parses:
             combined.write('%s %s\n%s\n' % (parse.reranker_score,
                                             parse.parser_score,
                                             parse.ptb_parse))
         combined.seek(0)
         return combined.read()
     else:
         if self._parses:
             return parser.asNBestList(self._parses, str(sentence_id))
         else:
             return '0 %s' % sentence_id
Пример #4
0
 def __str__(self):
     """Represent the n-best list in a similar output format to the
     command-line parser and reranker."""
     sentence_id = self.sentence_id or 'x'
     if self._reranked:
         from cStringIO import StringIO
         combined = StringIO()
         combined.write('%d %s\n' % (len(self.parses), sentence_id))
         for parse in self.parses:
             combined.write('%s %s\n%s\n' %
                            (parse.reranker_score, parse.parser_score,
                             parse.ptb_parse))
         combined.seek(0)
         return combined.read()
     else:
         if self._parses:
             return parser.asNBestList(self._parses, str(sentence_id))
         else:
             return '0 %s' % sentence_id