Add first pass at reducing non-confident guesses

This commit is contained in:
Jackson Kearl 2022-02-28 08:53:52 -08:00
parent 5696f5dfd4
commit 51702c7b5f
No known key found for this signature in database
GPG key ID: DA09A59C409FC400

View file

@ -56,10 +56,13 @@ export class LanguageDetectionSimpleWorker extends EditorSimpleWorker {
};
const historicalResolver = async () => {
if (langBiases) {
const regexpDetection = await this.runRegexpModel(documentTextSample, langBiases);
if (regexpDetection) {
return regexpDetection;
// only detect when we have at least a line of data
if (documentTextSample.length > 20 || documentTextSample.includes('\n')) {
if (langBiases) {
const regexpDetection = await this.runRegexpModel(documentTextSample, langBiases);
if (regexpDetection) {
return regexpDetection;
}
}
}
return undefined;