Added a label bias functionality in tag mode#8
Conversation
There was a problem hiding this comment.
Why not simply add the bias weights to the state table?
There was a problem hiding this comment.
I agree that your approach is better than my code.
I will fix it and re-commit soon.
Include calloc() etc. Wasn't compiling with recent GCC versions.
…y removed when crfsuite is synched with its upstream master from chokkan/crfsuite.
| """ | ||
|
|
||
| x_range = list(range(len(X))) | ||
| x_range_set = set(x_range) |
There was a problem hiding this comment.
I'm not sure if I understand the rationale behind this. The list cast effectively pre-allocates the list, which seems unnecessary - and the named variable declaration seems like an unnecessary change.
| @@ -1,5 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
There was a problem hiding this comment.
Can you explain why these were changed?
| if (opt->probability) { | ||
| floatval_t lognorm; | ||
| tagger->lognorm(tagger, &lognorm); | ||
| fprintf(fpo, "@score\t%f\t%f\n", score, lognorm); |
There was a problem hiding this comment.
Indentation does not match surrounding code.
|
|
||
| if (tr == NULL) { | ||
| std::stringstream ss; | ||
| ss << "The trainer is not initialized. Call Trainer::select before Trainer::train."; |
There was a problem hiding this comment.
This is a constant string. Why is a stream being used?
|
|
||
| if (data->attrs == NULL || data->labels == NULL) { | ||
| std::stringstream ss; | ||
| ss << "The data is empty. Call Trainer::append before Trainer::train."; |
There was a problem hiding this comment.
Ditto the constant remark above.
You can specify a label bias weight in tag mode.
Passed test with a small sample data.
Run crfsuite tag -h for help