WIP - Kotlin CLD3 - Google's Compact Language Detector 3
Bridge from c++ to Kotlin using Java Abstracted Foreign Function Layer
Job | OS | State | Shared Objects |
---|---|---|---|
47.1 | macOS | passed | dylib |
47.2 | Linux | passed | so |
- | windows | not supported | - |
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
...
<dependency>
<groupId>com.github.ntedgi</groupId>
<artifactId>cld3-kotlin</artifactId>
<version>1.0.2</version>
</dependency>
download os shred objects and add them under src/lib/(os-name)
val ld = LangDetect()
val englishText = "This piece of text is in English";
var result = ld.detect(englishText)
assert(result.language == "English")
assert(result.isReliable)
assert(result.proportion == 1f)
val ld = LangDetect()
val englishBulgarianText = "This piece of text is in English Този текст е на Български";
val results = ld.findTopNMostFreqLangs(englishBulgarianText, 3)
val languages = results.map { it.language }
assert(languages.size == 3)
assert(languages.contains("English"))
assert(languages.contains("Bulgarian"))
assert(languages.contains("UNKNOWN"))
std::vector<Result> FindTopNMostFreqLangs(const string &text, int num_langs);
Result FindLanguage(const string &text);
fun findTopNMostFreqLangs(text: String, n: Int): List<LangDetectResponse>
fun detect(text: String): LangDetectResponse
data class LangDetectResponse(
val probability: Float,
val proportion: Float,
val isReliable: Boolean,
val language: String
)
if (this.repo.isAwesome || this.repo.isHelpful) {
Star(this.repo);
}