Search code examples
javaparsingnlplibsvmliblinear

Does MaltParser actually provide an option for returning probabilities of Parse trees?


While looking at the source code of Malt Parser which actually has class LibLinear.java(jar file) and calls the java version of the liblinear toolkit; I don't find any option/way to return probability despite the information that, in principle training the model using liblinear(by default in malt parser) with Logistic regression(-s 0) should produce probability score of parsed trees.

The main concern is: Do the integration of Liblinear and Malt Parser working smoothly without affecting each other expected operations?

Working separately with Liblinear does give me probability output for the datasets.

liblinear-train -s 0 train_scale 

//training data using logistic regression model

liblinear-predict -b 1 test_scale train_scale.model test_scale_output 

//labels and classes and probability outputs. Here -b 1 does extract out probabilities of each datasets.

Reference: https://stackoverflow.com/questions/28791352/how-to-get-probability-score-of-parsed-sentences-using-malt-parser


Solution

  • Malt parser works based on a transition system and 2 or three stacks. At each step a transition is predicted using liblinear or libsvm. The input to these models is composed of what is in the stacks and the current state of the machine. So making a decision at one step affects the rest of the possible decisions. To compute the probability of a tree would require to compute the aggregated probabilites of all trees (so that they sum up to 1), which is infeasable. You could compute a trust score of a tree, I guess, or of a particular arc, but it would be a trust score, not a probability. And afaik maltparser doesn't offer this out of the box. You would have to alter the source code, but it is do-able I think