def u_2(self): v = self.p.t1().u_m() v2 = self.p.t1_r().u_m() s = (1 / (v + 0.1)) * (v2 + 0.1) w = {i: s[i] + 1 for i in v_gi(v)} o = sorted(w, key=w.get, reverse=True) return o
def to_wv(v, wv): v2 = np.zeros(wv.shape[1]) s = sum(v) for i in v_gi(v): v2 += (v[i] * wv[i]) if s > 0.0: v2 = v2 / s return v2
def c_2(self): v = self.p.t1().c_m() v2 = self.p.t1_r().c_m() #v2 = v2 * 0 s = (1 / (v + 0.1)) * (v2 + 0.1) w = {i: s[i] for i in v_gi(v)} o = sorted(w, key=w.get, reverse=True) return o
def gen_co(v, w): m = np.zeros([len(w), len(w)]) for v_ in v: i = v_gi(v_) for k1 in range(len(i)): for k2 in range(k1 + 1, len(i)): m[i[k1], i[k2]] += 1 m[i[k2], i[k1]] += 1 return m
def c_pick(self): v = self.p.t1().c_m() f = 1 / (self.c_f + 1) s = self.w1 * v/sum(v) + \ self.w2 * self.d_f/sum(self.d_f) + \ self.w3 * f/sum(f) w = {i: s[i] for i in v_gi(v)} o = sorted(w, key=w.get, reverse=True) # max return o
def c_pick(self): t_ = self.p.t1() r = [] for i, c2 in enumerate(t_.c2): sc = c_sim(c2, self.ec) if sc >= self.sc_low: r.append(i) t2_ = t(t_.v[r]) v = t2_.c_m() w = {i: v[i] for i in v_gi(v)} o = sorted(w, key=w.get, reverse=True) # max return o
import numpy as np import os from d.e import e from d.dt import dd from d.de import de from d.ul import v_gi, c_sim from d.g.wv import e_cv e_ = e(np.load(os.path.join(dd, "e2.npy"))) q = 50 qc = e_cv.v[q] w = {} for i, c2 in enumerate(e_.c2): w[i] = c_sim(qc, c2) o = sorted(w, key=w.get, reverse=True) # max r = e(e_.v[o[:30]]) print("q:{}".format(de.sh_c([q]))) for i in r.c: print(de.sh_c(v_gi(i)))
from d.dt import dt from d.de import de from d.ul import v_gi # c c = 0 for i, v in zip(dt.t.ti, dt.t.c): print("\n"+dt.raw[str(int(i))]["text"]) print(dt.sh_c(v_gi(v))) c += 1 if c > 200: break # u c = 0 for i, v in zip(dt.t.ti, dt.t.u): print("\n"+dt.raw[str(int(i))]["user"]["description"]) print(dt.sh_u(v_gi(v))) c += 1 if c > 200: break # e for i, v in zip(de.e.ei, de.e.c): print("\n"+de.raw[str(int(i))]["text"]) print(de.sh_c(v_gi(v))) # for i in tf_.vr.vocabulary_: # if not i in o: # print("error")
# w[i] = c_sim(qc, c2) + \ # u_sim(qu, u2) + \ # l_sim(ql, l) + \ # z_sim(qz, z) w[i] = c_sim(qc, c2) #w[i] = u_sim(qu, u2) # w[i] = l_sim(ql, l) # w[i] = z_sim(qz, z) o = sorted(w, key=w.get, reverse=True) # max r = t(t_.v[o[:30]]) print("q_c:{}".format(dt.sh_c([q]))) for i in r.c: print(dt.sh_c(v_gi(i))) # u w = {} for i, (c2, u2, l, z) in enumerate(zip(t_.c2, t_.u2, t_.l, t_.z)): w[i] = u_sim(qu, u2) o = sorted(w, key=w.get, reverse=True) # max r = t(t_.v[o[:30]]) print("\nq_u:{}".format(dt.sh_u([q]))) for i in r.u: print(dt.sh_u(v_gi(i)))