mirror of
https://github.com/BigMarc/grammargem.git
synced 2026-10-13 17:01:55 +02:00
Replace the NSSpellChecker + regex-stub engine with harper-core 2.5.0: real subject-verb agreement, verb forms, punctuation, repetition and spelling. New harper-ffi crate (staticlib) exposes harper_check over a C ABI; the CHarper module bridges it to Swift; HarperEngine maps Harper's char spans onto UTF-16 ranges and de-dups overlapping lints. NSSpellChecker stays only as a case-preserving spelling supplement, which fixes the problemm->Problem mis-casing. Bulk apply now skips no-op suggestions. build.sh / scripts/build.sh build the universal static lib; target/ and lib/ are gitignored (regenerate via harper-ffi/build.sh). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
/*
|
|
* harper.h — C ABI for the harper-ffi static library (harper-core 2.5.0).
|
|
*
|
|
* Symbols are provided by libharper_ffi.a (linked via -lharper_ffi). All
|
|
* strings are UTF-8. See harper-ffi/ for the Rust source.
|
|
*/
|
|
#ifndef HARPER_FFI_H
|
|
#define HARPER_FFI_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* Check `text` for grammar/spelling issues using harper-core.
|
|
*
|
|
* Returns a malloc'd, NUL-terminated UTF-8 JSON C string the caller MUST free
|
|
* with harper_free(). The JSON is an array of objects:
|
|
* [{ "start": <char offset>, "len": <char count>,
|
|
* "replacement": "<string>", "message": "<string>", "kind": "<string>" }]
|
|
*
|
|
* - "start"/"len" are CHAR (Unicode scalar) offsets, NOT bytes/UTF-16.
|
|
* - "kind" is one of: spelling, grammar, punctuation, repetition,
|
|
* capitalization, phrasing.
|
|
*
|
|
* On null/invalid input or any internal error, returns "[]". Thread-safe.
|
|
*/
|
|
char *harper_check(const char *text);
|
|
|
|
/* Free a string previously returned by harper_check(). NULL is a no-op. */
|
|
void harper_free(char *ptr);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* HARPER_FFI_H */
|