示例#1
0
 pu = []
 for name in u[user]:
     print '@' + root + name
     count = count + 1
     if count < 6:
         fin = open(root + name + '.txt', 'r')
         lines = fin.readlines()
         fin.close()
         pu.append([line.strip('\n') for line in lines])
     else:
         if count == 6 or type(zipf) == float and zipf < 1:
             if stype == 3 and type(zipf) == float and zipf < 0:
                 result = sm.dg3(root + name, cll, b, s, p, wtolu, ltow,
                                 ukk)
             else:
                 result = sm.dg(root + name, cll, sys.argv[3], b, s,
                                wtolu, ukk, zipf, stype)
         else:
             if stype == 3 and type(zipf) == float and zipf < 0:
                 result = sm.dg4(root + name, cll, b, s, p, wtolu, ltow,
                                 ukk, vecu)
             else:
                 result = sm.dg2(root + name, cll, sys.argv[3], b, s,
                                 wtolu, ukk, zipf, vecu, stype)
         dlu = np.array([10.0 for i in range(0, len(result) - 1)])
         mt = []
         sim = []
         for i in range(0, len(result) - 1):
             if count == 6:
                 vect[i] = sm.vecof(result[i], a, wtola, akk)
                 mt.append(vect[i].max())
                 sim.append(attack.simatt(result[i], pu))
示例#2
0
    if len(u[user]) > 5:
        print user
        usernum = usernum + 1
        count = 0
        vec = [np.zeros(akk) for i in range(0, 4)]
        vect = [np.zeros(akk) for i in range(0, 4)]
        for name in u[user]:
            count = count + 1
            fin = open(root + name, 'r')
            line = fin.read()
            title = re.search(r'【発明の名称】(.*?)\(', line, re.DOTALL)
            cl = re.search(r'(【国際特許分類第.*版】.*?)([A-H][0-9]+?[A-Z])', line,
                           re.DOTALL)
            #print title.group(1)
            #print cl.group(2)
            result = sm.dg(root + name, cll, sys.argv[3], a, s, wtol, ukk,
                           zipf, type)

            dl = np.array([10.0 for i in range(0, len(result) - 1)])
            print '@' + root + name
            for i in range(0, len(result) - 1):
                if count == 1:
                    vect[i] = sm.vecof(result[i], a, wtol, akk)
                else:
                    for j in range(0, len(result) - 1):
                        vecr = sm.vecof(result[i], a, wtol, akk)
                        dlt = spatial.distance.cosine(vecr, vec[j])
                        #print i,j,vecr.argmax(),dlt
                        if (dlt < dl[i]):
                            dl[i] = dlt
                            vect[i] = vec[j]
                    vect[i] = (vecr + vect[i] * count) / (count + 1)