blmoistawinde / HarvestText

文本挖掘和预处理工具(文本清洗、新词发现、情感分析、实体识别链接、关键词抽取、知识抽取、句法分析等),无监督或弱监督方法
MIT License
2.43k stars 330 forks source link

Fix broken API call #44

Closed tabletreedev closed 1 year ago

tabletreedev commented 1 year ago

Reproduceable Error:

(.venv) $ python3
Python 3.11.1 (main, Jan  3 2023, 16:00:30) [Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import harvesttext
>>> para = "上港的武磊和恒大的郜林,谁是中国最好的前锋?那当然是武磊武球王了,他是射手榜第一,原来是弱点的单刀也有了进步"
>>> ht = harvesttext.HarvestText()
>>> ht.extract_keywords(para, 5, method="textrank")
Building prefix dict from the default dictionary ...
Loading model from cache /var/folders/25/11vt3cf12jn7v1z3n8c8wchm0000gn/T/jieba.cache
Loading model cost 0.896 seconds.
Prefix dict has been built successfully.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xxx/github/networkx/networkx/.venv/lib/python3.11/site-packages/harvesttext/word_discover.py", line 299, in extract_keywords
    kwds = textrank(block_words, topK, with_score, window, weighted)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/github/networkx/networkx/.venv/lib/python3.11/site-packages/harvesttext/algorithms/keyword.py", line 31, in textrank
    pr = nx.pagerank_scipy(G)
         ^^^^^^^^^^^^^^^^^
AttributeError: module 'networkx' has no attribute 'pagerank_scipy'
>>> 

Solution: Renamed the method call to the recent name.

blmoistawinde commented 1 year ago

Thanks, merged the PR