forked from MaxwellRebo/nltk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added indents so comments aren't included in the doctest results
- Loading branch information
Steven Xu
committed
May 18, 2014
1 parent
93dac6c
commit 520148f
Showing
1 changed file
with
33 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
.. Copyright (C) 2001-2014 NLTK Project | ||
.. For license information, see LICENSE.TXT | ||
|
||
>>> from nltk.corpus.reader.bnc import BNCCorpusReader | ||
>>> bnc = BNCCorpusReader(root='.', fileids=r'FX8.xml') | ||
>>> from nltk.corpus.reader.bnc import BNCCorpusReader | ||
>>> bnc = BNCCorpusReader(root='.', fileids=r'FX8.xml') | ||
|
||
Checking the word access. | ||
------------------------- | ||
|
||
>>> len(bnc.words()) | ||
151 | ||
>>> len(bnc.words()) | ||
151 | ||
|
||
>>> bnc.words()[:6] | ||
['Ah', 'there', 'we', 'are', ',', '.'] | ||
>>> bnc.words(stem=True)[:6] | ||
['ah', 'there', 'we', 'be', ',', '.'] | ||
>>> bnc.words()[:6] | ||
['Ah', 'there', 'we', 'are', ',', '.'] | ||
>>> bnc.words(stem=True)[:6] | ||
['ah', 'there', 'we', 'be', ',', '.'] | ||
|
||
>>> bnc.tagged_words()[:6] | ||
[('Ah', 'INTERJ'), ('there', 'ADV'), ('we', 'PRON'), ('are', 'VERB'), (',', 'PUN'), ('.', 'PUN')] | ||
>>> bnc.tagged_words()[:6] | ||
[('Ah', 'INTERJ'), ('there', 'ADV'), ('we', 'PRON'), ('are', 'VERB'), (',', 'PUN'), ('.', 'PUN')] | ||
|
||
>>> bnc.tagged_words(c5=True)[:6] | ||
[('Ah', 'ITJ'), ('there', 'AV0'), ('we', 'PNP'), ('are', 'VBB'), (',', 'PUN'), ('.', 'PUN')] | ||
>>> bnc.tagged_words(c5=True)[:6] | ||
[('Ah', 'ITJ'), ('there', 'AV0'), ('we', 'PNP'), ('are', 'VBB'), (',', 'PUN'), ('.', 'PUN')] | ||
|
||
Testing access to the sentences. | ||
-------------------------------- | ||
|
||
>>> len(bnc.sents()) | ||
15 | ||
>>> len(bnc.sents()) | ||
15 | ||
|
||
>>> bnc.sents()[0] | ||
['Ah', 'there', 'we', 'are', ',', '.'] | ||
>>> bnc.sents(stem=True)[0] | ||
['ah', 'there', 'we', 'be', ',', '.'] | ||
>>> bnc.sents()[0] | ||
['Ah', 'there', 'we', 'are', ',', '.'] | ||
>>> bnc.sents(stem=True)[0] | ||
['ah', 'there', 'we', 'be', ',', '.'] | ||
|
||
>>> bnc.tagged_sents()[0] | ||
[('Ah', 'INTERJ'), ('there', 'ADV'), ('we', 'PRON'), ('are', 'VERB'), (',', 'PUN'), ('.', 'PUN')] | ||
>>> bnc.tagged_sents(c5=True)[0] | ||
[('Ah', 'ITJ'), ('there', 'AV0'), ('we', 'PNP'), ('are', 'VBB'), (',', 'PUN'), ('.', 'PUN')] | ||
>>> bnc.tagged_sents()[0] | ||
[('Ah', 'INTERJ'), ('there', 'ADV'), ('we', 'PRON'), ('are', 'VERB'), (',', 'PUN'), ('.', 'PUN')] | ||
>>> bnc.tagged_sents(c5=True)[0] | ||
[('Ah', 'ITJ'), ('there', 'AV0'), ('we', 'PNP'), ('are', 'VBB'), (',', 'PUN'), ('.', 'PUN')] | ||
|
||
A not lazy loader. | ||
----------------- | ||
|
||
>>> eager = BNCCorpusReader(root='.', fileids=r'FX8.xml', lazy=False) | ||
>>> eager = BNCCorpusReader(root='.', fileids=r'FX8.xml', lazy=False) | ||
|
||
>>> len(eager.words()) | ||
151 | ||
>>> eager.words(stem=True)[6:17] | ||
['right', 'abdominal', 'wound', ',', 'she', 'be', 'a', 'wee', 'bit', 'confuse', '.'] | ||
>>> len(eager.words()) | ||
151 | ||
>>> eager.words(stem=True)[6:17] | ||
['right', 'abdominal', 'wound', ',', 'she', 'be', 'a', 'wee', 'bit', 'confuse', '.'] | ||
|
||
>>> eager.tagged_words()[6:11] | ||
[('Right', 'ADV'), ('abdominal', 'ADJ'), ('wound', 'SUBST'), (',', 'PUN'), ('she', 'PRON')] | ||
>>> eager.tagged_words(c5=True)[6:17] | ||
[('Right', 'AV0'), ('abdominal', 'AJ0'), ('wound', 'NN1'), (',', 'PUN'), ('she', 'PNP'), ("'s", 'VBZ'), ('a', 'AT0'), ('wee', 'AJ0-NN1'), ('bit', 'NN1'), ('confused', 'VVN-AJ0'), ('.', 'PUN')] | ||
>>> len(eager.sents()) | ||
15 | ||
>>> eager.tagged_words()[6:11] | ||
[('Right', 'ADV'), ('abdominal', 'ADJ'), ('wound', 'SUBST'), (',', 'PUN'), ('she', 'PRON')] | ||
>>> eager.tagged_words(c5=True)[6:17] | ||
[('Right', 'AV0'), ('abdominal', 'AJ0'), ('wound', 'NN1'), (',', 'PUN'), ('she', 'PNP'), ("'s", 'VBZ'), ('a', 'AT0'), ('wee', 'AJ0-NN1'), ('bit', 'NN1'), ('confused', 'VVN-AJ0'), ('.', 'PUN')] | ||
>>> len(eager.sents()) | ||
15 |