├── .gitattributes ├── logo.png ├── banner.png ├── .eslintignore ├── .gitignore ├── playground ├── src │ ├── style.css │ ├── main.js │ └── App.vue ├── .postcssrc.cjs ├── vite.config.js ├── tailwind.config.cjs ├── index.html └── package.json ├── .prettierrc ├── .prettierignore ├── .editorconfig ├── tests-integration ├── node │ ├── package.json │ └── index.js ├── deno │ └── index.ts ├── node-esm │ ├── index.js │ └── package.json └── run.sh ├── .npmignore ├── index.html ├── src ├── benchmark │ ├── tinyld.ts │ ├── tinyld_heavy.ts │ ├── tinyld_light.ts │ ├── languagedetect.ts │ ├── langdetect.ts │ ├── franc.ts │ ├── franc-all.ts │ ├── franc-min.ts │ ├── cld.ts │ └── bench.ts ├── clean │ └── index.ts ├── index.ts ├── index_heavy.ts ├── index_light.ts ├── train │ └── splitter.ts ├── tokenizer.ts ├── train.ts └── core.ts ├── .github └── workflows │ ├── main.yml │ └── playground.yml ├── docs ├── light.md ├── install.md ├── api.md ├── dev.md ├── cli.md ├── langs.md ├── algorithm.md ├── faq.md ├── benchmark.md ├── overall.svg └── language.svg ├── tsconfig.json ├── tests ├── light.js ├── locale.js ├── clean.js └── detect.js ├── bin ├── tinyld.js ├── tinyld-heavy.js └── tinyld-light.js ├── .eslintrc ├── license ├── utils ├── overall.js ├── index.js ├── exectime.js ├── language.js ├── length.js └── mkdown.js ├── data └── bench │ ├── langdetect.json │ ├── tinyld-light.json │ ├── tinyld.json │ ├── franc-all.json │ ├── tinyld-heavy.json │ ├── franc.json │ ├── cld.json │ ├── languagedetect.json │ └── franc-min.json ├── Readme.md └── package.json /.gitattributes: -------------------------------------------------------------------------------- 1 | package-lock.json binary 2 | yarn.lock binary 3 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komodojp/tinyld/HEAD/logo.png -------------------------------------------------------------------------------- /banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komodojp/tinyld/HEAD/banner.png -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | bin 3 | dist 4 | tests 5 | tests-integration 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | data/tmp 3 | data/udhr 4 | data/tatoeba.csv 5 | node_modules 6 | -------------------------------------------------------------------------------- /playground/src/style.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /playground/.postcssrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "trailingComma": "none", 4 | "singleQuote": true, 5 | "semi": false 6 | } 7 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .quasar 2 | node_modules 3 | dist 4 | public 5 | coverage 6 | build 7 | SteamCI 8 | config 9 | *.log 10 | package.json 11 | package-lock.json 12 | tests-integration 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /tests-integration/node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-detect-node", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "author": "", 7 | "license": "ISC" 8 | } 9 | -------------------------------------------------------------------------------- /playground/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()] 7 | }) 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .git 2 | .github 3 | data 4 | docs 5 | src 6 | tests 7 | utils 8 | 9 | .editorconfig 10 | .eslintignore 11 | .eslintrc 12 | .prettierignore 13 | .prettierrc 14 | 15 | tsconfig.json 16 | .gitattributes 17 | -------------------------------------------------------------------------------- /tests-integration/deno/index.ts: -------------------------------------------------------------------------------- 1 | import { detect } from '../../dist/tinyld.normal.node.mjs' 2 | 3 | const language = detect('これは日本語です.') 4 | console.log(`Detect Language ${language}`) 5 | Deno.exit(language === 'ja' ? 0 : 1) 6 | -------------------------------------------------------------------------------- /tests-integration/node-esm/index.js: -------------------------------------------------------------------------------- 1 | import { detect } from '../../dist/tinyld.normal.node.mjs' 2 | 3 | const language = detect('これは日本語です.') 4 | console.log(`Detect Language ${language}`) 5 | process.exit(language === 'ja' ? 0 : 1) 6 | -------------------------------------------------------------------------------- /tests-integration/node/index.js: -------------------------------------------------------------------------------- 1 | const { detect } = require('../../dist/tinyld.normal.node.js') 2 | 3 | const language = detect('これは日本語です.') 4 | console.log(`Detect Language ${language}`) 5 | process.exit(language === 'ja' ? 0 : 1) 6 | -------------------------------------------------------------------------------- /tests-integration/node-esm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-detect-node-esm", 3 | "type": "module", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "index.js", 7 | "author": "", 8 | "license": "ISC" 9 | } 10 | -------------------------------------------------------------------------------- /tests-integration/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "$(dirname "$0")" 4 | 5 | echo "> Check DENO" 6 | deno run ./deno/index.ts 7 | 8 | echo "> Check NODE" 9 | node ./node/index.js 10 | 11 | echo "> Check NODE ESM" 12 | node ./node-esm/index.js 13 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /playground/tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | './index.html', 5 | './public/**/*.html', 6 | './src/**/*.{vue,js,ts,jsx,tsx}' 7 | ], 8 | theme: { 9 | extend: {}, 10 | }, 11 | plugins: [], 12 | } 13 | -------------------------------------------------------------------------------- /src/benchmark/tinyld.ts: -------------------------------------------------------------------------------- 1 | import { detect } from '../index' 2 | import { benchmark } from './bench' 3 | import fs from 'fs' 4 | ;(async () => { 5 | const res = await benchmark(detect) 6 | if (!fs.existsSync('./data/bench')) fs.mkdirSync('./data/bench') 7 | fs.writeFileSync('./data/bench/tinyld.json', JSON.stringify(res, null, 2)) 8 | })() 9 | -------------------------------------------------------------------------------- /src/benchmark/tinyld_heavy.ts: -------------------------------------------------------------------------------- 1 | import { detect } from '../index_heavy' 2 | import { benchmark } from './bench' 3 | import fs from 'fs' 4 | ;(async () => { 5 | const res = await benchmark(detect) 6 | if (!fs.existsSync('./data/bench')) fs.mkdirSync('./data/bench') 7 | fs.writeFileSync('./data/bench/tinyld-heavy.json', JSON.stringify(res, null, 2)) 8 | })() 9 | -------------------------------------------------------------------------------- /src/benchmark/tinyld_light.ts: -------------------------------------------------------------------------------- 1 | import { detect } from '../index_light' 2 | import { benchmark } from './bench' 3 | import fs from 'fs' 4 | ;(async () => { 5 | const res = await benchmark(detect) 6 | if (!fs.existsSync('./data/bench')) fs.mkdirSync('./data/bench') 7 | fs.writeFileSync('./data/bench/tinyld-light.json', JSON.stringify(res, null, 2)) 8 | })() 9 | -------------------------------------------------------------------------------- /playground/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |