Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tags for the graphical condordance #252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions book/ch05.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ category of the Brown corpus:
We can use these tags to do powerful searches using a graphical
POS-concordance tool ``nltk.app.concordance()``. Use it
to search for any combination of words and POS tags, e.g.
``N N N N``, ``hit/VD``, ``hit/VN``, or ``the ADJ man``.
``NOUN NOUN NOUN NOUN``, ``hit/VBD``, ``hit/VBN``, or ``the ADJ man``.

.. Screenshot

Expand Down Expand Up @@ -416,8 +416,9 @@ will do this for the WSJ tagset rather than the universal tagset:

To clarify the distinction between ``VBD`` (past tense) and ``VBN``
(past participle), let's find words which can be both ``VBD`` and
``VBN``, and see some surrounding text:
``VBN`` from the WSJ tagset, and see some surrounding text:

>>> cfd1 = nltk.ConditionalFreqDist(wsj)
>>> [w for w in cfd1.conditions() if 'VBD' in cfd1[w] and 'VBN' in cfd1[w]]
['Asked', 'accelerated', 'accepted', 'accused', 'acquired', 'added', 'adopted', ...]
>>> idx1 = wsj.index(('kicked', 'VBD'))
Expand Down Expand Up @@ -565,7 +566,7 @@ the distinctions between the tags.
>>> data = nltk.ConditionalFreqDist((word.lower(), tag)
... for (word, tag) in brown_news_tagged)
>>> for word in sorted(data.conditions()):
... if len(data[word]) > 3:
... if len(data[word]) >= 3:
... tags = [tag for (tag, _) in data[word].most_common()]
... print(word, ' '.join(tags))
...
Expand Down