2012-09-19 2 views
4

ngram 주파수의 텍스트 본문을 필터링 할 때 현재 사용자에게 중지 단어를 포함 할 것인지 또는 포함하지 않을 것인지를 선택하고 있습니다.Lucene의 밑줄은 ngram 주파수를 얻을 때 정지 단어로 출력됩니다.

snowballAnalyzer = new SnowballAnalyzer(Version.LUCENE_30, "English", stopWords);    
shingleAnalyzer = new ShingleAnalyzerWrapper(snowballAnalyzer, this.getnGramLength()); 

중지 단어가 ngrams에 포함하거나에서 제거 할 단어의 전체 목록 중 하나에 설정되어 다음과 같이 일반적으로이 수행됩니다. this.getnGramLength()); 현재 최대 Ngram 길이가 최대 3 개까지 포함됩니다.

No=1, Key=to, Freq=1 
No=2, Key=definitely, Freq=1 
No=3, Key=falling to earth, Freq=1 
No=4, Key=satellite, Freq=1 
No=5, Key=is, Freq=1 
No=6, Key=definitely falling to, Freq=1 
No=7, Key=definitely falling, Freq=1 
No=8, Key=falling, Freq=1 
No=9, Key=to earth, Freq=1 
No=10, Key=satellite is, Freq=1 
No=11, Key=is definitely, Freq=1 
No=12, Key=falling to, Freq=1 
No=13, Key=is definitely falling, Freq=1 
No=14, Key=earth, Freq=1 
No=15, Key=satellite is definitely, Freq=1 

하지만 괘에 대한 ​​중지 단어를 사용하지 않는 경우, 출력은 이것이다 :

내가 필터링 텍스트 중지 단어를 사용하는 경우 괘는 "위성은 확실히 지구로 떨어지는", 출력은

No=1, Key=satellite, Freq=1 
No=2, Key=falling _, Freq=1 
No=3, Key=satellite _ _, Freq=1 
No=4, Key=_ earth, Freq=1 
No=5, Key=falling, Freq=1 
No=6, Key=satellite _, Freq=1 
No=7, Key=_ _, Freq=1 
No=8, Key=_ falling _, Freq=1 
No=9, Key=falling _ earth, Freq=1 
No=10, Key=_, Freq=3 
No=11, Key=earth, Freq=1 
No=12, Key=_ _ falling, Freq=1 
No=13, Key=_ falling, Freq=1 

왜 밑줄이 표시됩니까? 나는 단순한 유니 그램, "위성 떨어짐", "떨어지는 지구"및 "위성 떨어지는 지구"를 보았을 것이라고 생각했을까요? 확실히 내가 사용하는 불용어 집합에 있습니다.

난 그냥

답변

3

밑줄은 '실종 중지 단어/s'를 대표하는 ... 밑줄 결과를 필터링 할 수 있지만. 이 동작을 피하려면 enablePositionIncrementsfalse으로 설정해야하지만 SnowballAnalyzer (현재 4.0.0-Beta에서는 사용되지 않음)으로 설정할 수 없습니다.

하나의 해결 방법은 StopAnalyzer를 먼저 사용하지 않고 출력을 StopFilter, SnowballFilterShingleFilter으로 꾸미는 것입니다. 루씬 4.0.0 베타에서 양방향 그램의 예 :이 바른 길에 당신을두고 있음을

Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40, CharArraySet.EMPTY_SET); 
TokenStream tokenStream = analyzer.tokenStream("content", new StringReader(input)); 
StopFilter stopFilter = new StopFilter(Version.LUCENE_40, tokenStream, stopWords); 
stopFilter.setEnablePositionIncrements(false); 
SnowballFilter snowballFilter = new SnowballFilter(stopFilter, "English"); 
ShingleFilter bigramShingleFilter = new ShingleFilter(snowballFilter, 2, 2); 

희망!

EDIT +, 여전히 좋은 대안을 찾고 루씬의 V4.4에 더 이상

가능하지 ...