FeatureChartParser not using nbest_parse?

33 views
Skip to first unread message

Cerin

unread,
Oct 19, 2016, 3:06:51 PM10/19/16
to nltk-users
I went to test some old FCFG code with the most recent version of NLTK, and I noticed the FeatureChartParser class's "nbest_parse()" method has been removed and replaced with simply "parse()", which returns an iterator.

The docs (http://www.nltk.org/api/nltk.parse.html#nltk.parse.chart.ChartParser.parse) don't mention if there's any sorting involved. Does this function imply the first chart returned is the "best" or do I now need to iterate over every single chart, and score them individually, to determine which is the best?

If it no longer sorts by score or probability of correctness, is there any new built-in functionality to help me implement that?

Peter Ljunglöf

unread,
Nov 16, 2016, 8:58:04 AM11/16/16
to nltk-...@googlegroups.com
Hi Cerin,

I'm sorry for this late answer, I don't read this list that often... Anyway, the non-probabilistic chart parsers in NLTK have never done any sorting, simply because all parse trees are equally probably in a non-probabilistic grammar.

I.e., the FeatureChartParser didn't sort by probability even when it had the method nbest_parse(), it just return n trees in an unspecified order. If you want to get the "best" tree, I guess you have to collect all trees and score them individually. Also, note that you have to implement the scoring function yourself since the grammar doesn't give you any help there.

best,
Peter Ljunglöf
Reply all
Reply to author
Forward
0 new messages