Skip to content

Commit

Permalink
Jackson/lang-detect-min-text (#144105)
Browse files Browse the repository at this point in the history
* Add first pass at reducing non-confident guesses

* Swap ordering of conditions
  • Loading branch information
Jackson Kearl committed Feb 28, 2022
1 parent 1943737 commit 5db76fd
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ export class LanguageDetectionSimpleWorker extends EditorSimpleWorker {
};

const historicalResolver = async () => {
// only detect when we have at least a line of data
if (langBiases) {
const regexpDetection = await this.runRegexpModel(documentTextSample, langBiases);
if (regexpDetection) {
return regexpDetection;
if (documentTextSample.length > 20 || documentTextSample.includes('\n')) {
const regexpDetection = await this.runRegexpModel(documentTextSample, langBiases);
if (regexpDetection) {
return regexpDetection;
}
}
}
return undefined;
Expand Down

0 comments on commit 5db76fd

Please sign in to comment.