lng.c is a minimalist C library and CLI for detecting the language of the given text using internal language profiles. It is designed as a composable native primitive for the KaisarCode ecosystem.
Detect the language of text provided as an argument or via standard input.
Single language detection:
./bin/x86_64/linux/lng "Hello world"Ranked detection with threshold and limit:
./bin/x86_64/linux/lng "Hello world" -l 3 -t 0.1Standard input processing:
printf 'hola mundo' | ./bin/x86_64/linux/lng| Flag | Description |
|---|---|
-t, --threshold <n> |
Minimum score threshold |
-l, --limit <n> |
Maximum number of results |
-h, --help |
Show help and usage |
-v, --version |
Show version |
Results are printed as the language code (for single match) or code and score (for ranked results):
en
en: 0.9500
es: 0.0400
#include "lng.h"
kc_lng_init();
const char *code = kc_lng_detect("Hello world");
kc_lng_result_t results[3];
int count = kc_lng_detect_top("Hello world", results, 3, 0.1);kc_lng_init()- initializes internal language profiles. This call is idempotent and thread-safe.kc_lng_detect()andkc_lng_detect_top()- perform language detection. Both callkc_lng_init()internally if not yet initialized. Once initialized, all state is read-only and safe for concurrent access.
Compiled artifacts are generated under bin/{arch}/{platform}/ for the host architecture running the build.
make clean && makeThe project is prepared to build artifacts for multiple architectures under bin/{arch}/{platform}/. A plain make builds only the current host architecture, while the targets below build the full matrix or a specific target.
make all
make x86_64/linux
make x86_64/windows
make i686/linux
make i686/windows
make aarch64/linux
make aarch64/android
make armv7/linux
make armv7/android
make armv7hf/linux
make riscv64/linux
make powerpc64le/linux
make mips/linux
make mipsel/linux
make mips64el/linux
make s390x/linux
make loongarch64/linuxThis project is distributed under the GNU General Public License version 3 (GPLv3).
