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)
| 337 | _map32_cache = None |
| 338 | |
| 339 | def 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 |