MCPcopy Create free account
hub / github.com/clips/pattern / information_content

Function information_content

pattern/text/en/wordnet/__init__.py:311–330  ·  view source on GitHub ↗

Returns the IC value for the given Synset (trained on the Brown corpus).

(synset)

Source from the content-addressed store, hash-verified

309IC_MAX = 0
310
311def information_content(synset):
312 """ Returns the IC value for the given Synset (trained on the Brown corpus).
313 """
314 global IC_MAX
315 if not IC:
316 IC[NOUN] = {}
317 IC[VERB] = {}
318 for s in open(IC_CORPUS).readlines()[1:]: # Skip the header.
319 s = s.split()
320 id, w, pos = (
321 int(s[0][:-1]),
322 float(s[1]),
323 s[0][-1] == "n" and NOUN or VERB)
324 if len(s) == 3 and s[2] == "ROOT":
325 IC[pos][0] = IC[pos].get(0,0) + w
326 if w != 0:
327 IC[pos][id] = w
328 if w > IC_MAX:
329 IC_MAX = w
330 return IC.get(synset.pos, {}).get(synset.id, 0.0)
331
332### WORDNET3 TO WORDNET2 ###########################################################################
333# Map WordNet3 synset id's to WordNet2 synset id's.

Callers 1

icMethod · 0.85

Calls 3

lenFunction · 0.85
splitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…