f=sys.argv[1] s="" withopen(f,"r") as fl: s=fl.read() resstr,stype=synonyms.seg(s)
withopen(sys.argv[2],"w") as fw: for i in resstr: iflen(i)==1: fw.write(i) else : nearbystr,num=synonyms.nearby(i) iflen(nearbystr)>1and num[1]> 0.75: print(nearbystr[1],num[1]) fw.write(nearbystr[1]) else : fw.write(i)
可以调整if len(nearbystr)>1 and num[1]> 0.75:来修改近义词的准确率.