Ex. word is an instance variable. When we create NerToken class object then the instance variable word, will be copied inside the object of NerToken class. If we assign word inside the constructor, then the compiler knows that the constructor will be invoked only once, so there is no problem assigning it inside the constructor as in current implementation.
If we assign word inside a method, the compiler knows that a method can be called multiple times, which means the value will have to be changed multiple times, which is not allowed for a final variable.
There are multiple assignment operations in "ner" classes that breaks the compilation for the same reason.
public class NerToken {
public final int index;
public final String word;
public final String normalized;
public final String type;
public final String tokenId;
public final NePosition position;
public NerToken(int index, String word, String normalized, String type, NePosition position) {
this.index = index;
this.word = word;
this.normalized = normalized;
this.type = type;
this.position = position;
this.tokenId = getTokenId();
}
public NerToken(int index, String word, String type, NePosition position) {
this.index = index;
this.word = word;
this.normalized = word;
this.type = type;
this.position = position;
this.tokenId = getTokenId();
}
....
Thanks for the report. Indeed I did not compile the project after the changes. Thanks for the patch. However I will make a slight modification as it is not advised to make non final variables public.
Ex. word is an instance variable. When we create NerToken class object then the instance variable word, will be copied inside the object of NerToken class. If we assign word inside the constructor, then the compiler knows that the constructor will be invoked only once, so there is no problem assigning it inside the constructor as in current implementation.
If we assign word inside a method, the compiler knows that a method can be called multiple times, which means the value will have to be changed multiple times, which is not allowed for a final variable.
There are multiple assignment operations in "ner" classes that breaks the compilation for the same reason.