Skip to content

how to use co_occur.py

alexr edited this page Mar 7, 2013 · 1 revision

How to use co_occur.py:

First create an instance of the class

    cls = Occurrence(sourceword,lan1,lan2)

** Get the conditional probs**.

    cond1,cond2 = cls.get_conditional()

Note: cond1 is the probability p(lan2| lan1), language2 conditioned on language1.

  cond2 is the probability   p(lan1| lan2),  language1 conditioned on language2.

  eg. lan1 = de, lan2 = es,    p( bank_de| bank_es) = cond2[bank_es][bank_de]

                                p( bank_es| bank_de) = cond1[bank_de][bank_es]

** Get the joint probs**

    joint = cls.get_joint()

The joint prob dictionary is symmetric, so to look up P(bank_es,bank_de), can do either joint[ "bank_es&&bank_de" ], or joint[ "bank_de&&bank_es"].

NOte: use "&&" to join the two words,and use that as the key

Clone this wiki locally