Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static SmoothingModel fromXContent(XContentParser parser) throws IOExcept

@Override
public WordScorerFactory buildWordScorerFactory() {
return (IndexReader reader, Terms terms, String field, double realWordLikelyhood, BytesRef separator)
-> new LaplaceScorer(reader, terms, field, realWordLikelyhood, separator, alpha);
return (IndexReader reader, Terms terms, String field, double realWordLikelihood, BytesRef separator)
-> new LaplaceScorer(reader, terms, field, realWordLikelihood, separator, alpha);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ final class LaplaceScorer extends WordScorer {
private double alpha;

LaplaceScorer(IndexReader reader, Terms terms, String field,
double realWordLikelyhood, BytesRef separator, double alpha) throws IOException {
super(reader, terms, field, realWordLikelyhood, separator);
double realWordLikelihood, BytesRef separator, double alpha) throws IOException {
super(reader, terms, field, realWordLikelihood, separator);
this.alpha = alpha;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public final class LinearInterpolatingScorer extends WordScorer {
private final double bigramLambda;
private final double trigramLambda;

public LinearInterpolatingScorer(IndexReader reader, Terms terms, String field, double realWordLikelyhood, BytesRef separator,
public LinearInterpolatingScorer(IndexReader reader, Terms terms, String field, double realWordLikelihood, BytesRef separator,
double trigramLambda, double bigramLambda, double unigramLambda) throws IOException {
super(reader, terms, field, realWordLikelyhood, separator);
super(reader, terms, field, realWordLikelihood, separator);
double sum = unigramLambda + bigramLambda + trigramLambda;
this.unigramLambda = unigramLambda / sum;
this.bigramLambda = bigramLambda / sum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public static LinearInterpolation fromXContent(XContentParser parser) throws IOE

@Override
public WordScorerFactory buildWordScorerFactory() {
return (IndexReader reader, Terms terms, String field, double realWordLikelyhood, BytesRef separator) ->
new LinearInterpolatingScorer(reader, terms, field, realWordLikelyhood, separator, trigramLambda, bigramLambda,
return (IndexReader reader, Terms terms, String field, double realWordLikelihood, BytesRef separator) ->
new LinearInterpolatingScorer(reader, terms, field, realWordLikelihood, separator, trigramLambda, bigramLambda,
unigramLambda);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@

//TODO public for tests
public final class NoisyChannelSpellChecker {
public static final double REAL_WORD_LIKELYHOOD = 0.95d;
public static final double REAL_WORD_LIKELIHOOD = 0.95d;
public static final int DEFAULT_TOKEN_LIMIT = 10;
private final double realWordLikelihood;
private final boolean requireUnigram;
private final int tokenLimit;

public NoisyChannelSpellChecker() {
this(REAL_WORD_LIKELYHOOD);
this(REAL_WORD_LIKELIHOOD);
}

public NoisyChannelSpellChecker(double nonErrorLikelihood) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private PhraseSuggester() {}
@Override
public Suggestion<? extends Entry<? extends Option>> innerExecute(String name, PhraseSuggestionContext suggestion,
IndexSearcher searcher, CharsRefBuilder spare) throws IOException {
double realWordErrorLikelihood = suggestion.realworldErrorLikelyhood();
double realWordErrorLikelihood = suggestion.realworldErrorLikelihood();
final PhraseSuggestion response = new PhraseSuggestion(name, suggestion.getSize());
final IndexReader indexReader = searcher.getIndexReader();
List<PhraseSuggestionContext.DirectCandidateGenerator> generators = suggestion.generators();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class PhraseSuggestionContext extends SuggestionContext {
static final float DEFAULT_RWE_ERRORLIKELIHOOD = 0.95f;
static final float DEFAULT_MAX_ERRORS = 0.5f;
static final String DEFAULT_SEPARATOR = " ";
static final WordScorer.WordScorerFactory DEFAULT_SCORER = (IndexReader reader, Terms terms, String field, double realWordLikelyhood,
BytesRef separator) -> new StupidBackoffScorer(reader, terms, field, realWordLikelyhood, separator, 0.4f);
static final WordScorer.WordScorerFactory DEFAULT_SCORER = (IndexReader reader, Terms terms, String field, double realWordLikelihood,
BytesRef separator) -> new StupidBackoffScorer(reader, terms, field, realWordLikelihood, separator, 0.4f);

private float maxErrors = DEFAULT_MAX_ERRORS;
private BytesRef separator = new BytesRef(DEFAULT_SEPARATOR);
Expand Down Expand Up @@ -78,7 +78,7 @@ public void setSeparator(BytesRef separator) {
this.separator = separator;
}

public Float realworldErrorLikelyhood() {
public Float realworldErrorLikelihood() {
return realworldErrorLikelihood;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static SmoothingModel fromXContent(XContentParser parser) throws IOExcept

@Override
public WordScorerFactory buildWordScorerFactory() {
return (IndexReader reader, Terms terms, String field, double realWordLikelyhood, BytesRef separator)
-> new StupidBackoffScorer(reader, terms, field, realWordLikelyhood, separator, discount);
return (IndexReader reader, Terms terms, String field, double realWordLikelihood, BytesRef separator)
-> new StupidBackoffScorer(reader, terms, field, realWordLikelihood, separator, discount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class StupidBackoffScorer extends WordScorer {
private final double discount;

StupidBackoffScorer(IndexReader reader, Terms terms,String field,
double realWordLikelyhood, BytesRef separator, double discount) throws IOException {
super(reader, terms, field, realWordLikelyhood, separator);
double realWordLikelihood, BytesRef separator, double discount) throws IOException {
super(reader, terms, field, realWordLikelihood, separator);
this.discount = discount;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ public abstract class WordScorer {
protected final String field;
protected final Terms terms;
protected final long vocabluarySize;
protected final double realWordLikelyhood;
protected final double realWordLikelihood;
protected final BytesRefBuilder spare = new BytesRefBuilder();
protected final BytesRef separator;
protected final long numTerms;
private final TermsEnum termsEnum;
private final boolean useTotalTermFreq;

public WordScorer(IndexReader reader, String field, double realWordLikelyHood, BytesRef separator) throws IOException {
this(reader, MultiTerms.getTerms(reader, field), field, realWordLikelyHood, separator);
public WordScorer(IndexReader reader, String field, double realWordLikelihood, BytesRef separator) throws IOException {
this(reader, MultiTerms.getTerms(reader, field), field, realWordLikelihood, separator);
}

public WordScorer(IndexReader reader, Terms terms, String field, double realWordLikelyHood, BytesRef separator) throws IOException {
public WordScorer(IndexReader reader, Terms terms, String field, double realWordLikelihood, BytesRef separator) throws IOException {
this.field = field;
if (terms == null) {
throw new IllegalArgumentException("Field: [" + field + "] does not exist");
Expand All @@ -65,7 +65,7 @@ public WordScorer(IndexReader reader, Terms terms, String field, double realWord
this.termsEnum = new FreqTermsEnum(reader, field, !useTotalTermFreq, useTotalTermFreq, null,
BigArrays.NON_RECYCLING_INSTANCE); // non recycling for now
this.reader = reader;
this.realWordLikelyhood = realWordLikelyHood;
this.realWordLikelihood = realWordLikelihood;
this.separator = separator;
}

Expand All @@ -78,7 +78,7 @@ public long frequency(BytesRef term) throws IOException {

protected double channelScore(Candidate candidate, Candidate original) throws IOException {
if (candidate.stringDistance == 1.0d) {
return realWordLikelyhood;
return realWordLikelihood;
}
return candidate.stringDistance;
}
Expand Down Expand Up @@ -117,6 +117,6 @@ public static BytesRef join(BytesRef separator, BytesRefBuilder result, BytesRef

public interface WordScorerFactory {
WordScorer newScorer(IndexReader reader, Terms terms,
String field, double realWordLikelyhood, BytesRef separator) throws IOException;
String field, double realWordLikelihood, BytesRef separator) throws IOException;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected void assertSuggestionContext(PhraseSuggestionBuilder builder, Suggesti
assertOptionalEquals(builder.confidence(), phraseSuggesterCtx.confidence(), PhraseSuggestionContext.DEFAULT_CONFIDENCE);
assertOptionalEquals(builder.collatePrune(), phraseSuggesterCtx.collatePrune(), PhraseSuggestionContext.DEFAULT_COLLATE_PRUNE);
assertEquals(builder.separator(), phraseSuggesterCtx.separator().utf8ToString());
assertOptionalEquals(builder.realWordErrorLikelihood(), phraseSuggesterCtx.realworldErrorLikelyhood(),
assertOptionalEquals(builder.realWordErrorLikelihood(), phraseSuggesterCtx.realworldErrorLikelihood(),
PhraseSuggestionContext.DEFAULT_RWE_ERRORLIKELIHOOD);
assertOptionalEquals(builder.maxErrors(), phraseSuggesterCtx.maxErrors(), PhraseSuggestionContext.DEFAULT_MAX_ERRORS);
assertOptionalEquals(builder.forceUnigrams(), phraseSuggesterCtx.getRequireUnigram(),
Expand Down