用于确定文本观点(第一、第二、第三或未知)的python包。
pointofview的Python项目详细描述
用于确定文本观点(第一、第二、第三或未知)的python包。
安装
pointofview在pypi上可用。只需使用pip:
安装$ pip install pointofview
您也可以从源代码安装它:
$ git clone https://github.com/prosegrinder/python-pointofview.git Cloning into 'python-pointofview'... ... $ cd python-pointofview $ python setup.py install ...
用法
pointofview通过计算视点代词来猜测文本的视点。主函数get_text_pov()将返回“first”、“second”、“third”或null(python的None对象):
>>> import pointofview >>> text = "I'm a piece of text written in first person! What are you?" >>> pointofview.get_text_pov(text) 'first'
还有另外两个助手函数。
get_word_pov()返回单个单词的视角:
>>> pointofview.get_word_pov("I") 'first' >>> pointofview.get_word_pov("nope") None
parse_pov_words返回包含所有第一、第二和第三人称pov单词的dict:
>>> text = """ ... When I try to analyze my own cravings, motives, actions and so forth, I surrender to a sort of retrospective imagination which feeds the analytic faculty with boundless alternatives and which causes each visualized route to fork and re-fork without end in the maddeningly complex prospect of my past. ... """ >>> pointofview.parse_pov_words(text) {'first': ['i', 'i'], 'second': [], 'third': []}