Git Product home page Git Product logo

language-detection's Introduction

language-detection


Language detection for Android: Given a string of text, identify what language the text is written in.

This project is a fork of an excellent Java language detection library (language-detection) written by Nakatani Shuyo. The original git version control history and commit messages are retained in this project.

NO LONGER MAINTAINED

There are no plans to update this project, but feel free to fork the repo and have at it.

2017-05-23 Update: Android O has introduced on-device language detection! See the TextClassificationManager.detectLanguages() method in the text classification service.

Changes

I've made two significant changes to the original code:

  1. Speed enhancements. As an alternative to using JSON-based text files for storing language profiles, a Python script is used to convert language profiles into Java code that can be bundled with an app. With the resulting performance improvement, language detection is fast enough to run acceptably on Android devices.

  2. Additional language profiles:

  • Aragonese
  • Asturian
  • Basque
  • Belarusian
  • Breton
  • Catalan
  • Galician
  • Haitian
  • Icelandic
  • Irish
  • Malay
  • Maltese
  • Occitan
  • Serbian (Cyrillic alphabet)
  • Welsh
  • Yiddish

Download

git clone [email protected]:rmtheis/language-detection.git

Sample usage

See the original project on Google Code.

Set up the language profile list in DetectorFactory.java.

Training: Generating language profiles

To generate a language profile, download a Wikipedia abstract file to use as a training data set.

For example, click anwiki and download anwiki-20121227-abstract.xml to language-detection/abstracts/ and do:

cd language-detection
mkdir abstracts/profiles
java -jar lib/langdetect.jar --genprofile -d language-detection/abstracts an
python scripts/genprofile.py -i abstracts/profiles/an > AN.java

Maven

Maven repository:

<repository>
    <id>nitin.public.maven.repository.release</id>
    <name>Nitin's Public Release Repository</name>
    <url>https://raw.github.com/nitinverma/public.maven.repository/master/releases/</url>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

Maven dependency:

    <dependency>
        <groupId>com.cybozu.labs</groupId>
        <artifactId>langdetect</artifactId>
        <version>${com.cybozu.labs.version}</version>
    </dependency>

Android settings

The hard-coded n-grams hashmap language profiles in this project may lead to memory problems during the build of an Android project containing the language profiles.

To work around this, change the default max heap size setting for dx to

defaultMx="-Xmx2048M" 

in android-sdk/platform-tools/dx (or dx.bat on Windows).

Building with ant may give better results than Eclipse.

License

Apache 2.0

language-detection's People

Contributors

rmtheis avatar nitinverma avatar

Stargazers

Serhii Shyran avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.