nltk/nltk — Issue #69: HMM tagger bug
Author: alexrudnick
Created: 2012-01-17 06:25:20+00:00
State: open

$ python nltk/tag/hmm.py

[...]

HMM-tagged: the/AT grand/DO jury/DO commented/DO on/DO a/DO number/DO of/DO
other/DO topics/DO ,/DO among/DO them/DO the/DO atlanta/DO and/DO fulton/DO
county/DO purchasing/DO departments/DO which/DO it/DO said/DO ``/DO are/DO
well/DO operated/DO and/DO follow/DO generally/DO accepted/DO practices/DO
which/DO inure/DO to/DO the/DO best/DO interest/DO of/DO both/DO
governments/DO ''/DO ./DO

All demo cases tag words as "DO" after the first word.

Migrated from http://code.google.com/p/nltk/issues/detail?id=393

earlier comments

alex.rudnick said, at 2010-01-08T15:59:35.000Z:

Just the demo cases in demo_pos_bw(), though, right? All the other demos in that file
return sensible-looking results, for me.

Baum-Welch can take a really long time to train up a good HMM; isn't doing 5
iterations with 10 sample sentences likely to produce wonky results?

aku.ankka8 said, at 2010-02-19T23:57:42.000Z:

I did this:

>>> import nltk
>>> BROWN = list(nltk.corpus.brown.tagged_sents())
>>> train = BROWN[:51606]
>>> test = BROWN[51606:]
>>> hmmt = nltk.tag.HiddenMarkovModelTrainer()
>>> hmm = hmmt.train(train)
>>> hmm.evaluate(test)
0.67956455229353951
>>> hmm.tag([x[0] for x in test[10]])
[('Had', 'HVD'), ('Dandy', 'NP'), ('been', 'BEN'), ('older', 'JJR'), ('or', 'CC'),
('wiser', 'JJR'), (',', ','), ('instinct', 'NN'), ('might', 'MD'), ('have', 'HV'),
('warned', 'VBN'), ('him', 'PPO'), ('that', 'CS'), ('he', 'PPS'), ('would', 'MD'),
('be', 'BE'), ('well', 'RB'), ('advised', 'VBN'), ('to', 'IN'), ('flee', 'AT'),
('from', 'AT'), ('the', 'AT'), ("Lalauries'", 'AT'), ('tender', 'AT'), ('care',
'AT'), ('if', 'AT'), ('he', 'AT'), ('valued', 'AT'), ('his', 'AT'), ('life', 'AT'),
('.', 'AT')]

I guess I'm doing something wrong, but haven't figured out what ... this is on 2.0b6,
but I got very similar results with 2.0b8 as well.