crfsuite icon indicating copy to clipboard operation
crfsuite copied to clipboard

Unable to load model from Python, while OK from the CLI.

Open adurieux opened this issue 12 years ago • 5 comments

Hi all,

I am trying to load a model from Python and it yields the following error :

>>> import crfsuite
>>> t = crfsuite.Tagger()
>>> t.open("/.../my.crf.model")
Assertion failed: (false), function crf1dm_initialize_header, file /SourceCache/CRFSuite/CRFSuite-33/crfsuite/lib/crf/src/crf1d_model.c, line 990.
Abort trap: 6

The strange thing is that the same model works perfectly when loaded from the CLI :

crfsuite tag -m /.../my.crf.model test.txt

I have tried to reinstall swig, but it does not change anything. Any clue of what I should try next ?

Thanks in advance and Happy New Year !

adurieux avatar Jan 06 '13 11:01 adurieux

Have you solved it?

xwzhu avatar May 04 '13 21:05 xwzhu

Pitifully not... I switched to an ubuntu-based VM, but I would be happy to know if you make any progress.

adurieux avatar May 06 '13 07:05 adurieux

Me too. Tried to work around it for several hours but with no success. The python binding for CRFsuite works under linux, but has very strange problems on a Mac. It says assertion failed, but I cannot even find the line of assertion in the code.

On May 6, 2013, at 8:33 AM, Antoine DURIEUX [email protected] wrote:

Pitifully not... I switched to an ubuntu-based VM, but I would be happy to know if you make any progress.

— Reply to this email directly or view it on GitHub.

xwzhu avatar May 06 '13 13:05 xwzhu

Just to potentially mark this as "solved": The confusion/problem arises because OSX comes with its own CRF Suite installed (in /usr/lib/libCRFSuite.dylib), and that Apple-hacked version does have said assertion, explaining why you guys are not finding it. (EDIT: I assume, that is...)

So if you are getting this error on a Mac, your dependent binary (e.g., Python wrapper for CRF Suite, NER Suite - which wraps CRF Suite, etc.) is compiled against the wrong dynamic library (the one by Apple just mentioned, instead of whatever you installed). To check if that is the case, use otool -L /path/to/your/binary and see which CRF Suite library it is linked to. If it is the one quoted above, your binary is linked to the wrong target.

fnl avatar Oct 22 '14 10:10 fnl

@fnl , thank you very much! That was the case. Just wondering why there is a pre-installed CRFSuite in OSX...

rgareev avatar Sep 06 '15 21:09 rgareev