Skip to content

Commit d657c65

Browse files
committed
Hashtable is now prebuilt
1 parent 43338c3 commit d657c65

21 files changed

Lines changed: 112 additions & 223 deletions

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,20 @@ All notable changes to this project will be documented in this file.
1414
### Changed
1515
-
1616

17+
### Fixed
18+
-
19+
20+
## [0.2.0] - 2026-06-16
21+
22+
> **Important**: This is a 0.x release. The API and functions are **unstable** and may change in future versions.
23+
24+
### Added
25+
-
26+
27+
### Changed
28+
- Hashtable is now prebuilt
29+
- Hashtable is now 16MB instead of 32MB
30+
- set_faster function deleted
31+
1732
### Fixed
1833
-

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ $ffi = FFI::cdef('
115115
const char *eldc_set_languages(const char *codes);
116116
void eldc_set_scheme(const char *scheme);
117117
void eldc_set_scores(int n);
118-
void eldc_set_faster(int flag);
119118
', './libeldc.so'); // Windows: 'eldc.dll', macOS: './libeldc.dylib'
120119

121120
$ffi->eldc_init();
@@ -189,7 +188,6 @@ If we use `--scores` or `--reliable`, it will return JSON, if not, a simple unqu
189188
-h, --help This message
190189
--list-languages Print all supported codes and exit
191190
-v, --verbose Loading info, timing, throughput
192-
--faster Uses 2x hashtable (32 MB → 64 MB), minimal speedup
193191
-l, --languages CODES Restrict to a subset, e.g. -l "es,en,de,fr"
194192
Accepts ISO 639-1 or ISO 639-2/T codes.
195193
-s, --scores [N] Output compact JSON with top-N normalised [0,1] scores
@@ -294,10 +292,9 @@ It is the default ELD language scheme. `--scheme iso639-1`
294292
***
295293

296294
### More info
297-
* ELD-C executable is 26MB, and loads a 32MB hashtable (64MB if --faster), using a total of ~55MB of memory.
295+
* ELD-C executable is 24MB, memory use is arround ~30MB.
298296
* ELD-C only reads first 1000 bytes of the input string (benchmarks are fair, with all lines under), but could be modded, if you feel an increased `--limit` flag/option is necessary, open a discussion.
299297
* Unlike other versions of ELD, ELD-C only comes with the 'large' database size, as that is the optimal one, but other sizes could be added.
300-
* ELD-C is optimized for multi-detection, for single detection a B-tree would offer faster loading and lower memory usage than the current hashtable. I haven't anticipated this being the most common use case, but it could be optimized for.
301298
* Next improvement could be a better training data set, my own "small" 60GB of data are not as clean as I wish, `fineweb-2` looks good.
302299

303300
#### Donations and suggestions

examples/demo_eldc_lib.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@ static class Eldc {
3636
[DllImport(LIB, EntryPoint="eldc_set_languages")] public static extern IntPtr SetLanguages(string codes);
3737
[DllImport(LIB, EntryPoint="eldc_set_scheme")] public static extern void SetScheme(string scheme);
3838
[DllImport(LIB, EntryPoint="eldc_set_scores")] public static extern void SetScores(int n);
39-
[DllImport(LIB, EntryPoint="eldc_set_faster")] public static extern void SetFaster(int flag);
4039
}
4140

4241
static string S(IntPtr p) => p != IntPtr.Zero ? Marshal.PtrToStringAnsi(p)! : "und";
4342

44-
// ── 0. set_faster (Not worth it. Call before init()) ─────────────────────────
45-
// Eldc.SetFaster(1); // 64 MB table (32MB default) Minimal speedup.
46-
4743
// ── 1. init ──────────────────────────────────────────────────────────────────
4844
Eldc.Init();
4945
Console.WriteLine("=== eldc .NET demo ===\n");

examples/demo_eldc_lib.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extern const char *eldc_detect_details(const char *text, EldcDetectResult *r);
2929
extern const char *eldc_set_languages(const char *codes);
3030
extern void eldc_set_scheme(const char *scheme);
3131
extern void eldc_set_scores(int n);
32-
extern void eldc_set_faster(int flag);
3332
*/
3433
import "C"
3534
import (
@@ -42,8 +41,6 @@ func gs(p *C.char) string { return C.GoString(p) }
4241
func free(p *C.char) { C.free(unsafe.Pointer(p)) }
4342

4443
func main() {
45-
// ── 0. set_faster (Not worth it. Call before init()) ─────────────────────
46-
// C.eldc_set_faster(1) // 64 MB table (32MB default) Minimal speedup.
4744

4845
// ── 1. init ──────────────────────────────────────────────────────────────
4946
C.eldc_init()

examples/demo_eldc_lib.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ public interface EldcLib extends Library {
4040
String eldc_set_languages(String codes);
4141
void eldc_set_scheme(String scheme);
4242
void eldc_set_scores(int n);
43-
void eldc_set_faster(int flag);
4443
}
4544

4645
static String lang(Pointer p) { return p != null ? p.getString(0) : "und"; }
4746

4847
public static void main(String[] args) {
4948
var lib = EldcLib.LIB;
5049

51-
// ── 0. set_faster (Not worth it. Call before init()) ─────────────────
52-
// lib.eldc_set_faster(1); // 64 MB table (32MB default) Minimal speedup
53-
5450
// ── 1. init ──────────────────────────────────────────────────────────
5551
lib.eldc_init();
5652
System.out.println("=== eldc Java demo ===\n");

examples/demo_eldc_lib.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@
3030
const char *eldc_set_languages(const char *codes);
3131
void eldc_set_scheme(const char *scheme);
3232
void eldc_set_scores(int n);
33-
void eldc_set_faster(int flag);
3433
', $lib_name);
3534

36-
// ── 0. set_faster (Not worth it. Call before init()) ─────────────────────────
37-
// $ffi->eldc_set_faster(1); // 64 MB table (32MB default) Minimal speedup.
38-
3935
// ── 1. init ──────────────────────────────────────────────────────────────────
4036
$ffi->eldc_init();
4137
echo "=== eldc PHP demo ===\n\n";

examples/demo_eldc_lib.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,10 @@ class EldcDetectResult(ctypes.Structure):
6666
lib.eldc_set_scores.restype = None
6767
lib.eldc_set_scores.argtypes = [ctypes.c_int]
6868

69-
lib.eldc_set_faster.restype = None
70-
lib.eldc_set_faster.argtypes = [ctypes.c_int]
7169

7270
# ── Helper: decode c_char_p safely ───────────────────────────────────────────
7371
def s(b): return b.decode("utf-8") if b else ""
7472

75-
# ── 0. eldc_set_faster() — larger hash table, call before init() ─────────────
76-
# 0 → 32 MB (default). 1 → 64 MB. Not recommended, minimal speedup.
77-
# lib.eldc_set_faster(1)
78-
7973
# ── 1. Initialise ────────────────────────────────────────────────────────────
8074
# eldc_init() is the only required call before detection.
8175
lib.eldc_init()

examples/demo_eldc_lib.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ class DetectResult < FFI::Struct
3737
attach_function :eldc_set_languages, [:string], :string
3838
attach_function :eldc_set_scheme, [:string], :void
3939
attach_function :eldc_set_scores, [:int], :void
40-
attach_function :eldc_set_faster, [:int], :void
4140

4241
def self.lang(ptr) = ptr.null? ? 'und' : ptr.read_string
4342
end
4443

45-
# ── 0. set_faster (Not worth it. Call before init) ─────────────────────────
46-
# ELD.eldc_set_faster(1) # 64 MB table
47-
4844
# ── 1. init ──────────────────────────────────────────────────────────────────
4945
ELD.eldc_init
5046
puts "=== eldc Ruby demo ===\n\n"

examples/demo_eldc_lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ fn main() {
4545
let set_lang: Symbol<unsafe extern "C" fn(*const c_char) -> *const c_char> = lib.get(b"eldc_set_languages\0").unwrap();
4646
let set_scheme:Symbol<unsafe extern "C" fn(*const c_char)> = lib.get(b"eldc_set_scheme\0").unwrap();
4747
let set_scores:Symbol<unsafe extern "C" fn(c_int)> = lib.get(b"eldc_set_scores\0").unwrap();
48-
let set_faster:Symbol<unsafe extern "C" fn(c_int)> = lib.get(b"eldc_set_faster\0").unwrap();
49-
50-
// ── 0. set_faster (Not worth it. Call before init()) ─────────────────
51-
// set_faster(1); // 64 MB table (32MB default) Minimal speedup.
5248

5349
// ── 1. init ──────────────────────────────────────────────────────────
5450
init();

examples/demo_eldc_lib.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ const eldc_detect_details = lib.func('const char *eldc_detect_details(const char
4343
const eldc_set_languages = lib.func('const char *eldc_set_languages(const char *codes)');
4444
const eldc_set_scheme = lib.func('void eldc_set_scheme(const char *scheme)');
4545
const eldc_set_scores = lib.func('void eldc_set_scores(int n)');
46-
const eldc_set_faster = lib.func('void eldc_set_faster(int flag)');
47-
48-
// ── 0. set_faster (Not worth it. Call before init()) ─────────────────────────
49-
// eldc_set_faster(1); // 64 MB table (32MB default) Minimal speedup.
5046

5147
// ── 1. init ──────────────────────────────────────────────────────────────────
5248
eldc_init();

0 commit comments

Comments
 (0)