Skip to content

Commit b4e0000

Browse files
committed
Skip setting up Senna instances in doctests
These can throw LookupError's if the SENNA env variable is defined, like in the CI. Long story short, it's easiest to skip these, and we won't miss out on test coverage, as Senna should already be tested in test/unit/test_senna.py by the Linux workers
1 parent b3448ae commit b4e0000

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

nltk/classify/senna.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
Note: Unit tests for this module can be found in test/unit/test_senna.py
3131
3232
>>> from nltk.classify import Senna
33-
>>> pipeline = Senna('/usr/share/senna-v3.0', ['pos', 'chk', 'ner'])
33+
>>> pipeline = Senna('/usr/share/senna-v3.0', ['pos', 'chk', 'ner']) # doctest: +SKIP
3434
>>> sent = 'Dusseldorf is an international business center'.split()
35-
>>> [(token['word'], token['chk'], token['ner'], token['pos']) for token in pipeline.tag(sent)] # doctest: +SKIP
35+
>>> [(token['word'], token['chk'], token['ner'], token['pos']) for token in pipeline.tag(sent)] # doctest: +SKIP
3636
[('Dusseldorf', 'B-NP', 'B-LOC', 'NNP'), ('is', 'B-VP', 'O', 'VBZ'), ('an', 'B-NP', 'O', 'DT'),
3737
('international', 'I-NP', 'O', 'JJ'), ('business', 'I-NP', 'O', 'NN'), ('center', 'I-NP', 'O', 'NN')]
3838
"""

nltk/tag/senna.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
Note: Unit tests for this module can be found in test/unit/test_senna.py
1818
1919
>>> from nltk.tag import SennaTagger
20-
>>> tagger = SennaTagger('/usr/share/senna-v3.0')
20+
>>> tagger = SennaTagger('/usr/share/senna-v3.0') # doctest: +SKIP
2121
>>> tagger.tag('What is the airspeed of an unladen swallow ?'.split()) # doctest: +SKIP
2222
[('What', 'WP'), ('is', 'VBZ'), ('the', 'DT'), ('airspeed', 'NN'),
2323
('of', 'IN'), ('an', 'DT'), ('unladen', 'NN'), ('swallow', 'NN'), ('?', '.')]
2424
2525
>>> from nltk.tag import SennaChunkTagger
26-
>>> chktagger = SennaChunkTagger('/usr/share/senna-v3.0')
26+
>>> chktagger = SennaChunkTagger('/usr/share/senna-v3.0') # doctest: +SKIP
2727
>>> chktagger.tag('What is the airspeed of an unladen swallow ?'.split()) # doctest: +SKIP
2828
[('What', 'B-NP'), ('is', 'B-VP'), ('the', 'B-NP'), ('airspeed', 'I-NP'),
2929
('of', 'B-PP'), ('an', 'B-NP'), ('unladen', 'I-NP'), ('swallow', 'I-NP'),
3030
('?', 'O')]
3131
3232
>>> from nltk.tag import SennaNERTagger
33-
>>> nertagger = SennaNERTagger('/usr/share/senna-v3.0')
33+
>>> nertagger = SennaNERTagger('/usr/share/senna-v3.0') # doctest: +SKIP
3434
>>> nertagger.tag('Shakespeare theatre was in London .'.split()) # doctest: +SKIP
3535
[('Shakespeare', 'B-PER'), ('theatre', 'O'), ('was', 'O'), ('in', 'O'),
3636
('London', 'B-LOC'), ('.', 'O')]
@@ -80,14 +80,14 @@ def bio_to_chunks(self, tagged_sent, chunk_type):
8080
Extracts the chunks in a BIO chunk-tagged sentence.
8181
8282
>>> from nltk.tag import SennaChunkTagger
83-
>>> chktagger = SennaChunkTagger('/usr/share/senna-v3.0')
83+
>>> chktagger = SennaChunkTagger('/usr/share/senna-v3.0') # doctest: +SKIP
8484
>>> sent = 'What is the airspeed of an unladen swallow ?'.split()
85-
>>> tagged_sent = chktagger.tag(sent) # doctest: +SKIP
86-
>>> tagged_sent # doctest: +SKIP
85+
>>> tagged_sent = chktagger.tag(sent) # doctest: +SKIP
86+
>>> tagged_sent # doctest: +SKIP
8787
[('What', 'B-NP'), ('is', 'B-VP'), ('the', 'B-NP'), ('airspeed', 'I-NP'),
8888
('of', 'B-PP'), ('an', 'B-NP'), ('unladen', 'I-NP'), ('swallow', 'I-NP'),
8989
('?', 'O')]
90-
>>> list(chktagger.bio_to_chunks(tagged_sent, chunk_type='NP')) # doctest: +SKIP
90+
>>> list(chktagger.bio_to_chunks(tagged_sent, chunk_type='NP')) # doctest: +SKIP
9191
[('What', '0'), ('the airspeed', '2-3'), ('an unladen swallow', '5-6-7')]
9292
9393
:param tagged_sent: A list of tuples of word and BIO chunk tag.

0 commit comments

Comments
 (0)