protected TokenStreamComponents createComponents(String fieldName) {
// TODO Auto-generated method stub
Tokenizer _IKTokenizer = null;
try {
_IKTokenizer = new IKTokenizer(fieldName, this.useSmart);
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Analy" + e);
}
return new TokenStreamComponents(_IKTokenizer);
}
public IKTokenizer(String fieldname,boolean useSmart) throws IOException{
super();
this.input=new StringReader(fieldname);
offsetAtt = addAttribute(OffsetAttribute.class);
termAtt = addAttribute(CharTermAttribute.class);
typeAtt = addAttribute(TypeAttribute.class);
_IKImplement = new IKSegmenter(input , useSmart);
}
但是会报TokenStream contract violation: close() call missing
protected TokenStreamComponents createComponents(String fieldName) { // TODO Auto-generated method stub Tokenizer _IKTokenizer = null; try { _IKTokenizer = new IKTokenizer(fieldName, this.useSmart); } catch (IOException e) { // TODO Auto-generated catch block System.out.println("Analy" + e); }
public IKTokenizer(String fieldname,boolean useSmart) throws IOException{ super(); this.input=new StringReader(fieldname); offsetAtt = addAttribute(OffsetAttribute.class); termAtt = addAttribute(CharTermAttribute.class); typeAtt = addAttribute(TypeAttribute.class); _IKImplement = new IKSegmenter(input , useSmart); }但是会报TokenStream contract violation: close() call missing