Example #1
0
 def test_not_in_wordnet(self):
     self.assertEqual(not_in_wordnet("hot"), False)
Example #2
0
    # r = r.encode('ascii', 'ignore').decode('ascii') # bytes object is not being handled by most_similar function
    try:
        n = 0
        sims = model.most_similar(positive=[r], topn=200)

        for s in sims:
            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),
Example #3
0
for r in words:
    counter = counter + 1
    r = r.encode('ascii', 'ignore')
    try:
        k = 0
        sims = model.most_similar(positive=[r], topn=200)
        for s in sims:
            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)]))
Example #4
0
 for s in sims:
     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(
for r in words:
    counter = counter + 1
    r = r.encode('ascii', 'ignore')
    try:
        n = 0
        sims = model.most_similar(positive=[r], topn=200)
        for s in sims:
            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: