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

Function map32

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

Returns an (id, pos)-tuple with the WordNet2 synset id for the given WordNet3 synset id. Returns None if no id was found.

(id, pos=NOUN)

Source from the content-addressed store, hash-verified

337_map32_cache = None
338
339def map32(id, pos=NOUN):
340 """ Returns an (id, pos)-tuple with the WordNet2 synset id for the given WordNet3 synset id.
341 Returns None if no id was found.
342 """
343 global _map32_cache
344 if not _map32_cache:
345 _map32_cache = open(os.path.join(MODULE, "dict", "index.32")).readlines()
346 _map32_cache = (x for x in _map32_cache if x[0] != ";") # comments
347 _map32_cache = dict(x.strip().split(" ") for x in _map32_cache)
348 k = pos in _map32_pos2 and pos or _map32_pos1.get(pos, "x")
349 k+= str(id).lstrip("0")
350 k = _map32_cache.get(k, None)
351 if k is not None:
352 return int(k[1:]), _map32_pos2[k[0]]
353 return None
354
355#### SENTIWORDNET ##################################################################################
356# http://nmis.isti.cnr.it/sebastiani/Publications/LREC06.pdf

Callers

nothing calls this directly

Calls 4

strFunction · 0.85
stripMethod · 0.80
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…