mirror of https://github.com/apache/lucene.git
no Jira - minor generics / code constructs fixes in MLT
This commit is contained in:
parent
f1bb914784
commit
f9f6d3a3ac
|
@ -782,11 +782,7 @@ public final class MoreLikeThis {
|
||||||
* @param vector List of terms and their frequencies for a doc/field
|
* @param vector List of terms and their frequencies for a doc/field
|
||||||
*/
|
*/
|
||||||
private void addTermFrequencies(Map<String, Map<String, Int>> field2termFreqMap, Terms vector, String fieldName) throws IOException {
|
private void addTermFrequencies(Map<String, Map<String, Int>> field2termFreqMap, Terms vector, String fieldName) throws IOException {
|
||||||
Map<String, Int> termFreqMap = field2termFreqMap.get(fieldName);
|
Map<String, Int> termFreqMap = field2termFreqMap.computeIfAbsent(fieldName, k -> new HashMap<>());
|
||||||
if (termFreqMap == null) {
|
|
||||||
termFreqMap = new HashMap<>();
|
|
||||||
field2termFreqMap.put(fieldName, termFreqMap);
|
|
||||||
}
|
|
||||||
final TermsEnum termsEnum = vector.iterator();
|
final TermsEnum termsEnum = vector.iterator();
|
||||||
final CharsRefBuilder spare = new CharsRefBuilder();
|
final CharsRefBuilder spare = new CharsRefBuilder();
|
||||||
BytesRef text;
|
BytesRef text;
|
||||||
|
@ -823,11 +819,7 @@ public final class MoreLikeThis {
|
||||||
throw new UnsupportedOperationException("To use MoreLikeThis without " +
|
throw new UnsupportedOperationException("To use MoreLikeThis without " +
|
||||||
"term vectors, you must provide an Analyzer");
|
"term vectors, you must provide an Analyzer");
|
||||||
}
|
}
|
||||||
Map<String, Int> termFreqMap = perFieldTermFrequencies.get(fieldName);
|
Map<String, Int> termFreqMap = perFieldTermFrequencies.computeIfAbsent(fieldName, k -> new HashMap<>());
|
||||||
if (termFreqMap == null) {
|
|
||||||
termFreqMap = new HashMap<>();
|
|
||||||
perFieldTermFrequencies.put(fieldName, termFreqMap);
|
|
||||||
}
|
|
||||||
try (TokenStream ts = analyzer.tokenStream(fieldName, r)) {
|
try (TokenStream ts = analyzer.tokenStream(fieldName, r)) {
|
||||||
int tokenCount = 0;
|
int tokenCount = 0;
|
||||||
// for every token
|
// for every token
|
||||||
|
@ -906,7 +898,7 @@ public final class MoreLikeThis {
|
||||||
* @see #retrieveInterestingTerms(java.io.Reader, String)
|
* @see #retrieveInterestingTerms(java.io.Reader, String)
|
||||||
*/
|
*/
|
||||||
public String[] retrieveInterestingTerms(int docNum) throws IOException {
|
public String[] retrieveInterestingTerms(int docNum) throws IOException {
|
||||||
ArrayList<Object> al = new ArrayList<>(maxQueryTerms);
|
ArrayList<String> al = new ArrayList<>(maxQueryTerms);
|
||||||
PriorityQueue<ScoreTerm> pq = retrieveTerms(docNum);
|
PriorityQueue<ScoreTerm> pq = retrieveTerms(docNum);
|
||||||
ScoreTerm scoreTerm;
|
ScoreTerm scoreTerm;
|
||||||
int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
|
int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
|
||||||
|
@ -929,7 +921,7 @@ public final class MoreLikeThis {
|
||||||
* @see #setMaxQueryTerms
|
* @see #setMaxQueryTerms
|
||||||
*/
|
*/
|
||||||
public String[] retrieveInterestingTerms(Reader r, String fieldName) throws IOException {
|
public String[] retrieveInterestingTerms(Reader r, String fieldName) throws IOException {
|
||||||
ArrayList<Object> al = new ArrayList<>(maxQueryTerms);
|
ArrayList<String> al = new ArrayList<>(maxQueryTerms);
|
||||||
PriorityQueue<ScoreTerm> pq = retrieveTerms(r, fieldName);
|
PriorityQueue<ScoreTerm> pq = retrieveTerms(r, fieldName);
|
||||||
ScoreTerm scoreTerm;
|
ScoreTerm scoreTerm;
|
||||||
int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
|
int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
|
||||||
|
|
Loading…
Reference in New Issue