Commit 7ba46b9d by Steven Bird

Merge pull request #912 from longdt219/fix_CI_Errors

Fix errors shown in CI
parents b62b6d15 7d12d2ae
......@@ -27,19 +27,17 @@ The input is:
- List of the operations needed to be performed.
- (optionally) the encoding of the input data (default:utf-8)
>>> from __future__ import unicode_literals
>>> from nltk.classify import Senna
>>> pipeline = Senna('/usr/share/senna-v2.0', ['pos', 'chk', 'ner'])
>>> sent = 'Düsseldorf is an international business center'.split()
>>> pipeline.tag(sent)
[{'word': 'D\xfcsseldorf', 'chk': 'B-NP', 'ner': 'B-PER', 'pos': 'NNP'},
{'word': 'is', 'chk': 'B-VP', 'ner': 'O', 'pos': 'VBZ'},
{'word': 'an', 'chk': 'B-NP', 'ner': 'O', 'pos': 'DT'},
{'word': 'international', 'chk': 'I-NP', 'ner': 'O', 'pos': 'JJ'},
{'word': 'business', 'chk': 'I-NP', 'ner': 'O', 'pos': 'NN'},
{'word': 'center', 'chk': 'I-NP', 'ner': 'O','pos': 'NN'}]
>>> sent = 'Dusseldorf is an international business center'.split()
>>> [(token['word'], token['chk'], token['ner'], token['pos']) for token in pipeline.tag(sent)]
[('Dusseldorf', 'B-NP', 'B-LOC', 'NNP'), ('is', 'B-VP', 'O', 'VBZ'), ('an', 'B-NP', 'O', 'DT'),
('international', 'I-NP', 'O', 'JJ'), ('business', 'I-NP', 'O', 'NN'), ('center', 'I-NP', 'O', 'NN')]
"""
from __future__ import unicode_literals
from os import path, sep, environ
from subprocess import Popen, PIPE
from platform import architecture, system
......
......@@ -1313,7 +1313,7 @@ class ChartParser(ParserI):
# Width, for printing trace edges.
trace_edge_width = self._trace_chart_width // (chart.num_leaves() + 1)
if trace: print(chart.pretty_format_leaves(trace_edge_width))
if self._use_agenda:
# Use an agenda-based algorithm.
for axiom in self._axioms:
......@@ -1628,8 +1628,9 @@ def demo(choice=None,
print()
cp = ChartParser(grammar, strategies[strategy][1], trace=trace)
t = time.time()
parses = cp.parse_all(tokens)
chart = cp.chart_parse(tokens)
parses = list(chart.parses(grammar.start()))
times[strategies[strategy][0]] = time.time()-t
print("Nr edges in chart:", len(chart.edges()))
if numparses:
......
......@@ -24,7 +24,7 @@ class CRFTagger(TaggerI):
"""
A module for POS tagging using CRFSuite https://pypi.python.org/pypi/python-crfsuite
>>> from nltk.tag.crfsuite import CRFTagger
>>> from nltk.tag.crf import CRFTagger
>>> ct = CRFTagger()
>>> train_data = [[('University','Noun'), ('is','Verb'), ('a','Det'), ('good','Adj'), ('place','Noun')],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment