我使用Docker运行概念注释工具(CAT),然后以与以下网站相同的方式安装它:https://libraries.io/pypi/medcat 这些步骤是成功的。
然后我想在我的Python代码中实现它。当我运行代码时,我从导入行中得到一个错误:
Traceback (most recent call last):
File "<ipython-input-10-32d167ab52db>", line 1, in <module>
runfile('C:/Users/as/Desktop/Data/Preprocessing.py', wdir='C:/Users/as/Desktop/Data')
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/as/Desktop/Data/Preprocessing.py", line 27, in <module>
from medcat.cat import CAT
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\medcat\cat.py", line 4, in <module>
from medcat.cdb import CDB
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\medcat\cdb.py", line 9, in <module>
from medcat.utils.loggers import basic_logger
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\medcat\utils\loggers.py", line 6, in <module>
logging.basicConfig(filename='/tmp/cat.log', level=logging.DEBUG)
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\logging\__init__.py", line 1900, in basicConfig
h = FileHandler(filename, mode)
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\logging\__init__.py", line 1092, in __init__
StreamHandler.__init__(self, self._open())
File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\logging\__init__.py", line 1121, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\tmp\\cat.log'
我运行的代码是:
from medcat.cat import CAT
from medcat.utils.vocab import Vocab
from medcat.prepare_cdb import PrepareCDB
from medcat.cdb import CDB
vocab = Vocab()
#Load the vocab model
vocab.load_dict('C:/Users/as/Desktop/Data/med_ann_norm_dict.dat')
#build a special CDB from a .csv file
preparator = PrepareCDB(vocab=vocab)
csv_paths = ['C:/Users/as/Desktop/Data/codes.csv']
cdb = preparator.prepare_csvs(csv_paths)
#Annotate the text
doc = text
cat = CAT(cdb=cdb, vocab=vocab)
我也试图找到该文件,所以我搜索了%tmp%
目录。搜索返回了Temp目录,没有名为cat.log的文件。