Example #1
0
 def test_holo(self):
     self.assertGreater(holonymous("IRAQ" , "Baghdad"), 0)
Example #2
0
            hit = False
            search = True
            if same_stem(s[0], r):
                search = False
                printout(",".join(['same stem', s[0], r, str(s[1]), str(n)]))

            if not_in_wordnet(r):
                search = False
                printout(",".join(
                    ['not_in_wordnet', s[0], r,
                     str(s[1]), str(n)]))
            if search:
                hyper = hypernomous(s[0], r)
                hypo = hyoponomous(s[0], r)
                syno = synononymous(s[0], r)
                holo = holonymous(s[0], r)
                mero = meronymous(s[0], r)
                if hyper > 0 and hyper < 1:
                    printout(",".join(
                        ['hyper', s[0], r,
                         str(s[1]),
                         str(n),
                         str(hyper)]))
                if hypo > 0 and hypo < 1:
                    printout(",".join(
                        ['hypo', s[0], r,
                         str(s[1]),
                         str(n), str(hypo)]))
                if syno > 0 and syno < 1:
                    printout(",".join(
                        ['syn', s[0], r,
Example #3
0
 k = k + 1
 for pos in parts_of_speech:
     s = (s[0].encode("ascii", 'ignore'), s[1])
     hit = False
     search = True
     if same_stem(s[0], r):
         search = False
         printout(",".join(['same stem', pos, str(model.similarity(s[0], r)), s[0], r, str(s[1]), str(counter) + "-" + str(k), str(1)]))
     if not_in_wordnet(r, pos):
         search = False
         printout(",".join(['not_in_wordnet', pos, str(model.similarity(s[0], r)), s[0], r, str(s[1]), str(counter) + "-" + str(k), str(1)]))
     if search:
         hyper = hypernomous(r, s[0], pos)
         hypo = hyoponomous(r, s[0], pos)
         syno = synononymous(r, s[0], pos)
         holo = holonymous(r, s[0], pos)
         mero = meronymous(r, s[0], pos)
         all_possible_hyper = get_all_possible_hypernyms(r, s[0], pos)
         all_possible_hypo = get_all_possible_hyponyms(r, s[0], pos)
         all_possible_mero = get_all_possible_meronyms(r, s[0], pos)
         all_possible_holo = get_all_possible_holonyms(r, s[0], pos)
         all_possible_syns = len(wn.synsets(r, pos=pos)) * len(wn.synsets(s[0], pos=pos))
         tracker = str(counter) + "-" + str(k)
         printout(",".join(['hyper', pos, str(model.similarity(s[0], r)), r.replace(',', ""), s[0].replace(',', ""), str(s[1]), tracker, str(hyper), str(all_possible_hyper)]))
         printout(",".join(['hypo', pos, str(model.similarity(s[0], r)), r.replace(',', ""), s[0].replace(',', ""), str(s[1]), tracker, str(hypo), str(all_possible_hypo)]))
         printout(",".join(['syn', pos, str(model.similarity(s[0], r)), r.replace(',', ""), s[0].replace(',', ""), str(s[1]), tracker, str(syno), str(all_possible_syns)]))
         printout(",".join(['holo', pos, str(model.similarity(s[0], r)), r.replace(',', ""), s[0].replace(',', ""), str(s[1]), tracker, str(holo), str(all_possible_holo)]))
         printout(",".join(['mero', pos, str(model.similarity(s[0], r)), r.replace(',', ""), s[0].replace(',', ""), str(s[1]), tracker, str(mero), str(all_possible_mero)]))
         if (((hyper + hypo + syno + holo + mero) == 0) or ((hyper + hypo + syno + holo + mero) == 5)):
             printout(",".join(['none', pos, str(model.similarity(s[0], r)), r, s[0], str(s[1]), tracker]))
         print "debug mero {} {} {}".format(mero, tracker, pos)
Example #4
0
         str(1)
     ]))
 if not_in_wordnet(r, pos):
     search = False
     printout(",".join([
         'not_in_wordnet', pos,
         str(model.similarity(s[0], r)), s[0], r,
         str(s[1]),
         str(counter) + "-" + str(k),
         str(1)
     ]))
 if search:
     hyper = hypernomous(r, s[0], pos)
     hypo = hyoponomous(r, s[0], pos)
     syno = synononymous(r, s[0], pos)
     holo = holonymous(r, s[0], pos)
     mero = meronymous(r, s[0], pos)
     all_possible_hyper = get_all_possible_hypernyms(
         r, s[0], pos)
     all_possible_hypo = get_all_possible_hyponyms(r, s[0], pos)
     all_possible_mero = get_all_possible_meronyms(r, s[0], pos)
     all_possible_holo = get_all_possible_holonyms(r, s[0], pos)
     all_possible_syns = len(wn.synsets(r, pos=pos)) * len(
         wn.synsets(s[0], pos=pos))
     tracker = str(counter) + "-" + str(k)
     printout(",".join([
         'hyper', pos,
         str(model.similarity(s[0], r)),
         r.replace(',', ""), s[0].replace(',', ""),
         str(s[1]), tracker,
         str(hyper),
         n = n + 1
         print "counter: " + str(counter) + "-" + str(n)
         s = (s[0].encode("ascii", 'ignore'), s[1])
         hit = False
         search = True
         if same_stem(s[0], r):
             search = False
             printout(",".join(['same stem', s[0], r, str(s[1]), str(n)]))
         if not_in_wordnet(r):
             search = False
             printout(",".join(['not_in_wordnet', s[0], r, str(s[1]), str(n)]))
         if search:
             hyper = hypernomous(s[0], r)
             hypo = hyoponomous(s[0], r)
             syno = synononymous(s[0], r)
             holo = holonymous(s[0], r)
             mero = meronymous(s[0], r)
             if hyper > 0 and hyper < 1:
                 printout(",".join(['hyper', s[0], r, str(s[1]), str(n), str(hyper)]))
             if hypo > 0 and hypo < 1:
                 printout(",".join(['hypo', s[0], r, str(s[1]), str(n), str(hypo)]))
             if syno > 0 and syno < 1:
                 printout(",".join(['syn', s[0], r, str(s[1]), str(n), str(syno)]))
             if holo > 0 and holo < 1:
                 printout(",".join(['holo', s[0], r, str(s[1]), str(n), str(holo)]))
             if mero > 0 and mero < 1:
                 printout(",".join(['mero', s[0], r, str(s[1]), str(n), str(mero)]))
             if (((hyper + hypo + syno + holo + mero) == 0) or ((hyper + hypo + syno + holo + mero) == 5)):
                 printout(",".join(['none', s[0], r, str(s[1]), str(n)]))
 except KeyError:
     print printout(",".join(['KeyError', r]))