Correct way to calculate probabilities using ARPA LM data

Viewed 640

I am writing a small library for calculating ngram probabilities.

I have a LM described by arpa file (its a quite simple format: probability ngram backoff_weight):

...
-5.1090264  Hello   -0.05108307
-5.1090264  Bob -0.05108307
-3.748848   we -0.38330063
...
-2.5558481  Hello Bob   -0.012590006
...
-1.953679   Hello Bob how   -0.0022290824
...
-0.58411354 Hello Bob how are   -0.0007929117
...
-1.4516809  Hello Bob how are you
...

But how do I calculate P(we|Hello Bob how are) here correctly?

P(we|Hello Bob how are) = P(we) * BWt(Hello Bob how are) ?

or is this the right way:

P(we|Hello Bob how are) = P(are we) * BWt(Hello Bob how) ?

what if I don't have backoff weight for the 4-gram (Hello Bob how are) ?

Please point me to some universal formula for calculating the probabilities or where can I read it, I really can't find anything good somehow...

1 Answers
Related