All Projects → ntedgi → cld3-kotlin

ntedgi / cld3-kotlin

Licence: MIT license
Bindings to Google's Compact Language Detector 3 to JVM Based Languages

Programming Languages

kotlin
9241 projects
C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to cld3-kotlin

pycld3
Python3 bindings for the Compact Language Detector v3 (CLD3)
Stars: ✭ 122 (+510%)
Mutual labels:  cld3

Build Status codecov codebeat badge

cld3-kotlin

WIP - Kotlin CLD3 - Google's Compact Language Detector 3

Bridge from c++ to Kotlin using Java Abstracted Foreign Function Layer

Operations Systems Support:

Job OS State Shared Objects
47.1 macOS passed dylib
47.2 Linux passed so
- windows not supported -

Usage Examples:

add maven dependencies

<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"))

The Bridge Interface Implemantation:

from (C++)

std::vector<Result> FindTopNMostFreqLangs(const string &text, int num_langs);
Result FindLanguage(const string &text);

to (Kotlin)

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);
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].