我试图在Macbook中安装crf ++。我从https://taku910.github.io/crfpp/#download下载了CRF ++-0.58。然后我按照crf ++的官方网站上的说明进行操作。
我首先进入名为CRF ++-0.58的文件夹。然后我在终端中输入以下代码:
make
sudo make install
cd python
这些命令运行良好。然后我输入
python setup.py install
输出如下:
running build
running build_py
running build_ext
building '_CRFPP' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -I/anaconda3/include/python3.7m -c CRFPP_wrap.cxx -o build/temp.macosx-10.7-x86_64-3.7/CRFPP_wrap.o
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on
the command line to use the libc++ standard library instead
[-Wstdlibcxx-not-found]
CRFPP_wrap.cxx:2375:23: warning: explicitly assigning value of variable of type
'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
CRFPP_wrap.cxx:2378:23: warning: explicitly assigning value of variable of type
'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
CRFPP_wrap.cxx:2900:9: warning: variable 'res' is used uninitialized whenever
'if' condition is true [-Wsometimes-uninitialized]
if (PyType_Ready(tp) < 0)
^~~~~~~~~~~~~~~~~~~~
CRFPP_wrap.cxx:2924:10: note: uninitialized use occurs here
return res;
^~~
CRFPP_wrap.cxx:2900:5: note: remove the 'if' if its condition is always false
if (PyType_Ready(tp) < 0)
^~~~~~~~~~~~~~~~~~~~~~~~~
CRFPP_wrap.cxx:2881:10: note: initialize the variable 'res' to silence this
warning
int res;
^
= 0
CRFPP_wrap.cxx:2981:10: fatal error: 'stdexcept' file not found
#include <stdexcept>
^~~~~~~~~~~
4 warnings and 1 error generated.
error: command 'gcc' failed with exit status 1
然后,我在线搜索错误“错误:命令'gcc'失败,退出状态为1”。我发现遇到类似问题的人。我尝试了一些解决方案,但没有一个起作用。
我试图安装python-dev来解决此问题,但失败了。
(base) localhost:python dxm$ brew install python3-dev
Error: No available formula with the name "python3-dev"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...`enter code here`
==> Searching taps on GitHub...
Error: No formulae found in taps.
那我该如何解决这个问题?
答案 0 :(得分:0)
我发现Apple提供了一种安装crf ++的方法,该方法与我尝试的方法完全不同:http://macappstore.org/crf/
通过这种方式安装后,我可以像这样使用crf ++:
crf_train = "crf_learn -f 3 template.txt dg_train.txt dg_model"
os.system(crf_train)
crf_test = "crf_test -m dg_model dg_test.txt -o dg_result.txt"
os.system(crf_test)