我使用hazm
以便使用python 2.7
提取文本中的块(由于库兼容性,使用旧版本的python)
在一行中,我必须参考以下称为postagger.model
的模型:
tagger = POSTagger(model='./resources/postagger.model')
但出现错误:无法导入名称模型
我不得不提到我已经创建资源文件夹并将postagger.model
放入该文件夹。
您能帮我解决我的项目有什么问题吗?
谢谢
更新:我提到了完整的回溯错误消息:
ImportError at /testCore1
cannot import name Model
Request Method: GET
Request URL: http://127.0.0.1:8000/testCore1?sentence=gre
Django Version: 1.11.29
Exception Type: ImportError
Exception Value:
cannot import name Model
Exception Location: C:\Python27\lib\site-packages\hazm\SequenceTagger.py in __init__, line 22
Python Executable: C:\Python27\python27.exe
Python Version: 2.7.15
Python Path:
['C:\\Users\\user\\Desktop\\newapp',
'C:\\Windows\\SYSTEM32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages',
'C:\\Python27\\lib\\site-packages\\wapiti']
Server time: Tue, 28 Apr 2020 05:10:01 +0000
Traceback Switch to copy-and-paste view
C:\Python27\lib\site-packages\django\core\handlers\exception.py in inner
response = get_response(request) ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\handlers\base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\handlers\base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
C:\Users\user\Desktop\newapp\keywordextraction\views.py in testCore1
tagger = POSTagger(model='resources/postagger.model') ...
▶ Local vars
C:\Python27\lib\site-packages\hazm\SequenceTagger.py in __init__
from wapiti import Model ...
▶ Local vars
似乎错误不在您的代码中。如果您尚未安装WSL,hazm会给出此错误。有关更多信息,请参见Github上的此问题: