1

我试图在我的 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.

那么我该如何解决这个问题呢?

4

1 回答 1

0

我发现苹果提供了一种安装 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)
于 2019-07-24T08:59:05.990 回答