def getclosest(query): """ get closest in here... """ # this is a set of phonemes orig = getInventory(query) sims = {} for langid in u.invsets.keys(): if langid == query: continue # try getting F1 here instead of just intersection. tgt = getInventory(langid) score = phoible.getF1(orig, tgt) #score = getDistinctiveFeatures(orig, tgt, pmap) #score = getOV(tgt, orig, langs["eng"]) sims[langid] = score return sims
# langlist represents a list of languages to use. if args.langlist: lines = map(lambda s: s[0], utils.readFile(args.langlist[0], sep=" ")) u.loadinventorysets(lines) else: u.loadinventorysets() if args.getInventory: getInventory(args.getInventory[0]) elif args.getF1: l1, l2 = args.getF1 l1set = getInventory(l1) l2set = getInventory(l2) print phoible.getF1(l1set, l2set) elif args.getClosest: lang = args.getClosest[0] c = getclosest(lang) ci = sorted(c.items(), key=lambda p: p[1], reverse=True) logger.info("Writing to mine." + lang) with open("mine." + lang, "w") as out: out.write(lang + "\t1.0\n") ignored = 0 iset = set() for l in ci: if l[1] >= 0: out.write(l[0] + "\t" + str(l[1]) + "\n") else: iset.add(l[0]) ignored += 1