a.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:air-poems 作者: leoneckert 项目源码 文件源码
def to_files_special_dict(dict_name):
    writer = open("out_files/" + str(dict_name) + ".txt", "w")
    count = 0
    for t in words_by_pos:
        for w in words_by_pos[t]:
            print "\t\t", w
            try:
                writer.write(w)
                writer.write("\n")
                count += 1
            except:
                nevermind = 1
    writer.close()
    print "[+] saved to files. Saved", count, "words."



# rawjson = open("secret_societies_corpora.json").read()  #puts the file as a big string into the variable rawjson
# data = json.loads(rawjson) #json.loads take a string and turns it into a data structure
# for elem in data:
#   w = elem["name"]
#   pos = tag(w)[-1][1]
#   # print "-"*20
#   # print w, pos
#   add_word(w,pos)

#   if pos.startswith("VB") and Word(w).lemmatize('v') is not w:
#       w = Word(w).lemmatize('v')
#       pos = tag("to " + w)[-1][1]
#       # print "-"*5
#       # print w, pos
#       add_word(w,pos)
#   if pos.startswith("NN") and Word(w).lemmatize('n') is not w:
#       w = Word(w).lemmatize('n')
#       pos = tag(w)[-1][1]
#       # print "-"*5
#       # print w, pos
#       add_word(w,pos)
#   if pos.startswith("JJ") and Word(w).lemmatize('a') is not w:
#       w = Word(w).lemmatize('a')
#       pos = tag("a " + w + " thing")[-2][1]
#       # print "-"*5
#       # print w, pos
#       add_word(w,pos)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号