Skip to content

Commit

Permalink
Drop unnecessary ngram files for Chinese, Japanese and Korean (pemist…
Browse files Browse the repository at this point in the history
  • Loading branch information
pemistahl authored and Francesco Vasco committed Apr 28, 2022
1 parent a18acfc commit 4a13f7d
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,11 @@ class LanguageDetector internal constructor(
synchronized(modelCache) {
modelCache[language]?.let { return it }
}
val jsonLanguageModels: Sequence<JsonLanguageModel> = (1..5).asSequence().map { ngramLength ->
val fileName = "${Ngram.getNgramNameByLength(ngramLength)}s.json"
val filePath = "/language-models/${language.isoCode639_1}/$fileName"
val jsonLanguageModels: Sequence<JsonLanguageModel> = (1..5).asSequence().mapNotNull { ngramLength ->
val filePath =
"/language-models/${language.isoCode639_1}/${Ngram.getNgramNameByLength(ngramLength)}s.json"
Language::class.java.getResourceAsStream(filePath)
.use { Json.decodeFromStream(JsonLanguageModel.serializer(), it) }
?.use { Json.decodeFromStream(JsonLanguageModel.serializer(), it) }
}
val model = TrainingDataLanguageModel.fromJson(language, jsonLanguageModels)
synchronized(modelCache) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/language-models/ja/bigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/ja/fivegrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/ja/quadrigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/ja/trigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/ko/bigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/ko/fivegrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/ko/quadrigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/ko/trigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/zh/bigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/zh/fivegrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/zh/quadrigrams.json

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/language-models/zh/trigrams.json

This file was deleted.

0 comments on commit 4a13f7d

Please sign in to comment.