简体   繁体   English

模块“pytextrank”没有属性“parse_doc”

[英]Module 'pytextrank' has no attribute 'parse_doc'

I am performing a nlp task.我正在执行 nlp 任务。 I have written the following code.我已经编写了以下代码。 While executing, it is showing the following error.在执行时,它显示以下错误。 Any suggestion to resolve the error will be helpful.任何解决错误的建议都会有所帮助。 I am having python 3 env in google colab .我在 google colab 中有 python 3 env。

# Pytextrank
import pytextrank
import json

# Sample text
sample_text = 'I Like Flipkart. He likes Amazone. she likes Snapdeal. Flipkart and amazone is on top of google search.'

# Create dictionary to feed into json file

file_dic = {"id" : 0,"text" : sample_text}
file_dic = json.dumps(file_dic)
loaded_file_dic = json.loads(file_dic)

# Create test.json and feed file_dic into it.
with open('test.json', 'w') as outfile:
json.dump(loaded_file_dic, outfile)

path_stage0 = "test.json"
path_stage1 = "o1.json"

# Extract keyword using pytextrank
with open(path_stage1, 'w') as f:
for graf in pytextrank.parse_doc(pytextrank.json_iter(path_stage0)):
f.write("%s\n" % pytextrank.pretty_print(graf._asdict()))

print(pytextrank.pretty_print(graf._asdict()))

I am getting the following error :我收到以下错误:

  AttributeError                            Traceback (most recent call last)      
  <ipython-input-33-286ce104df34> in <module>()      
       20 # Extract keyword using pytextrank      
       21 with open(path_stage1, 'w') as f:      
  ---> 22   for graf in 
  pytextrank.parse_doc(pytextrank.json_iter(path_stage0)):     
       23     f.write("%s\n" % pytextrank.pretty_print(graf._asdict()))       
       24     print(pytextrank.pretty_print(graf._asdict()))      

      AttributeError: module 'pytextrank' has no attribute 'parse_doc'   

Implementation of TextRank in Python for use in spaCy pipelines在 Python 中实现 TextRank 以用于 spaCy 管道

import spacy
import pytextrank
nlp = spacy.load('en_core_web_sm')
tr = pytextrank.TextRank()
nlp.add_pipe(tr.PipelineComponent, name='textrank', last=True)
# Sample text
sample_text = 'I Like Flipkart. He likes Amazone. she likes Snapdeal. Flipkart and amazone is on top of google search.'
#funct
for p in doc._.phrases:
    print(p.text)

PyTextRank 的更新版本简化了调用代码,并使这些步骤变得不必要: https ://spacy.io/universe/project/spacy-pytextrank

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError: 模块 &#39;urllib&#39; 没有属性 &#39;parse&#39; - AttributeError: module 'urllib' has no attribute 'parse' 模块 &#39;avro.schema&#39; 没有属性 &#39;parse&#39; - module 'avro.schema' has no attribute 'parse' 如何解决“AttributeError: module &#39;xmltodict&#39; has no attribute &#39;parse&#39;”。? - How to solve the "AttributeError: module 'xmltodict' has no attribute 'parse'".? CQLSH 客户端 - 模块&#39;对象没有属性&#39;parse_options - CQLSH client - module' object has no attribute 'parse_options 模块“tensorflow.tools.docs.doc_controls”没有属性“inheritable_header” - Module 'tensorflow.tools.docs.doc_controls' has no attribute 'inheritable_header' AttributeError:模块“ app.parse”没有属性“ sheet” - AttributeError: module 'app.parse' has no attribute 'sheet' AttributeError: &#39;spacy.tokens.doc.Doc&#39; 对象没有属性 &#39;lower&#39; - AttributeError: 'spacy.tokens.doc.Doc' object has no attribute 'lower' AttributeError: 'CollectionReference' 对象没有属性 'doc' - AttributeError: 'CollectionReference' object has no attribute 'doc' &#39;Doc2Vec&#39;对象没有属性&#39;wv&#39; - 'Doc2Vec' object has no attribute 'wv' 'module'没有属性'urlencode' - 'module' has no attribute 'urlencode'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM