擅长:python、mysql、java
<p>我喜欢Martjin的回答。。。但这也应该有效,你可能会发现它更具可读性。你知道吗</p>
<p><code>positive_assoc = sum(pmi[term][tx] for tx in positive_vocab if term in pmi and
tx in pmi[term)
negative_assoc = sum(pmi[term][tx] for tx in negative_vocab if term in pmi and
tx in pmi[term)</code></p>