TypeError Occurs in nltk.tbl.demo.demo_template_statistics()

11 views
Skip to first unread message

Min Jun Park

unread,
Apr 10, 2015, 4:38:45 AM4/10/15
to nltk-...@googlegroups.com
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Loading tagged data from treebank...
Read testing data (200 sents/5251 wds)
Read training data (800 sents/19933 wds)
Read baseline data (800 sents/19933 wds) [reused the training set]
Trained baseline tagger
    Accuracy on test set: 0.8349
Training tbl tagger...
TBL train (fast) (seqs: 800; tokens: 19933; tpls: 24; min score: 3; min acc: None)
Finding initial useful rules...
    Found 12850 useful rules.

           B      |
   S   F   r   O  |        Score = Fixed - Broken
   c   i   o   t  |  R     Fixed = num tags changed incorrect -> correct
   o   x   k   h  |  u     Broken = num tags changed correct -> incorrect
   r   e   e   e  |  l     Other = num tags changed incorrect -> incorrect
   e   d   n   r  |  e
------------------+-------------------------------------------------------
  23  23   0   0  | POS->VBZ if Pos:PRP@[-2,-1]
  20  21   1   0  | NN->VB if Pos:-NONE-@[-2] & Pos:TO@[-1]
  15  16   1   0  | VBN->VBD if Pos:PRP@[-1]
  13  13   0   0  | NN->VB if Pos:MD@[-1]
  12  12   0   0  | VBP->VB if Pos:MD@[-2,-1]
  10  10   0   0  | VB->VBP if Pos:PRP@[-1]
   9   9   0   0  | VBD->VBN if Pos:VBD@[-1]
   9  15   6   0  | IN->WDT if Pos:NNS@[-1] & Pos:-NONE-@[1]
   7   7   0   0  | VBP->VB if Pos:TO@[-1]
   7   8   1   0  | IN->RB if Word:as@[2]
   6   6   0   0  | VB->VBP if Pos:NNS@[-1]
   6   7   1   0  | VBD->VBN if Pos:VBZ@[-1]
   6   6   0   0  | WDT->IN if Pos:VBG@[2]
   6   6   0   0  | IN->WDT if Pos:-NONE-@[1] & Pos:VBZ@[2]
   5   5   0   0  | POS->VBZ if Pos:-NONE-@[-1]
   5   7   2   3  | RP->RB if Pos:CD@[1,2]
   5   5   0   1  | IN->WDT if Pos:-NONE-@[1] & Pos:VBD@[2]
   4   4   0   0  | POS->VBZ if Pos:``@[-2]
   4   4   0   0  | VBD->VBN if Pos:VBP@[-2,-1]
   4   4   0   0  | VBP->VB if Pos:VBD@[-2,-1]
   4   4   0   0  | NN->VBP if Pos:NNS@[-2] & Pos:RB@[-1]
   4   5   1   0  | VBN->VBD if Pos:NNP@[-2] & Pos:NNP@[-1]
   4   4   0   0  | IN->WDT if Pos:-NONE-@[1] & Pos:MD@[2]
   4   4   0   0  | JJS->RBS if Word:most@[0] & Word:the@[-1] & Pos:DT@[-1]
   3   3   0   1  | VB->NN if Pos:DT@[-1]
   3   3   0   0  | VBD->VBN if Pos:VBN@[-1]
   3   4   1   0  | VBN->VB if Pos:TO@[-1]
   3   4   1   1  | IN->RB if Pos:.@[1]
   3   3   0   0  | JJ->RB if Pos:VBD@[1]
   3   3   0   0  | PRP$->PRP if Pos:TO@[1]
   3   3   0   0  | RP->RB if Pos:DT@[-2,-1]
   3   3   0   1  | VBD->VBN if Pos:VB@[-2,-1]
   3   3   0   0  | NN->VBP if Pos:NNS@[-1] & Pos:DT@[1]
   3   3   0   0  | RB->JJ if Pos:DT@[-1] & Pos:NN@[1]
   3   3   0   0  | VBP->VB if Word:n't@[-2,-1]
Trained tbl tagger in 6.46 seconds
    Accuracy on test set: 0.8543
Incrementally tagging the test data, collecting individual rule statistics
    Rule statistics collected
WARNING: train_stats asked for separate_baseline_data=True; the baseline will be artificially high
TEMPLATE STATISTICS (TEST AND TRAIN) (12 templates, 35 rules)
TEST  (   5251 tokens) initial   867 0.8349 final:   765 0.8543
TRAIN (  19933 tokens) initial   621 0.9688 final:   396 0.9801
#ID | Score (test) | Score (train) |  #Rules     | Template
-----------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python34\Lib\site-packages\nltk\tbl\demo.py", line 368, in <module>
    demo_template_statistics()
  File "C:\Python34\Lib\site-packages\nltk\tbl\demo.py", line 78, in demo_template_statistics
    postag(incremental_stats=True, template_stats=True)
  File "C:\Python34\Lib\site-packages\nltk\tbl\demo.py", line 265, in postag
    brill_tagger.print_template_statistics(teststats)
  File "C:\Python34\lib\site-packages\nltk\tag\brill.py", line 385, in print_template_statistics
    print_testtrain_stats()
  File "C:\Python34\lib\site-packages\nltk\tag\brill.py", line 371, in print_testtrain_stats
    Template.ALLTEMPLATES[int(tid)],
TypeError: non-empty format string passed to object.__format__
>>>

I searched this on google, it seems that It has something to do with the version of Python, but I don't know how to get around it.
I was working on Python 3.4.3(32bit), NLTK 3.0.2
Reply all
Reply to author
Forward
0 new messages