How to draw a graph for each sentence in the document based on the tags assigned to each word in the document using Python

北城余情 提交于 2019-12-11 16:58:22

问题


Extract out each sentence from the document.(cricket.txt) Check for each tag of the word in tagged-text.txt If word is N-NNP then assign it to subject_list, if word is QT-QTC, N-NN, PR-PRP then assign it to object_list, if word is V_VM_VF then assign it to verb_list Create a graph for each sentence in the document.

I'm using Python 2.7 on Jupyter Notebook.

for subject in subject_list:
    s=subject.decode('utf-8')
    graph.add_node(s)
    labels[s]=s

Example: Tommy Dias is drinking milk. Tommy/N-NNP, Dias/N-NNP, is/V-VM_VF, drinking/V-VM-VF, milk/N-NN Tommy Dias-> is drinking-> milk

来源:https://stackoverflow.com/questions/55553495/how-to-draw-a-graph-for-each-sentence-in-the-document-based-on-the-tags-assigned

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!