kfind문서

참조 · API

JavaScript API

`@kfind/kfind`는 browser bundler와 Node.js에서 같은 Kfind·Matcher API를 제공합니다.

package export

Browser condition은 bundler ESM WASM을, Node condition은 CommonJS WASM target을 선택합니다. TypeScript declaration은 두 target이 공유합니다.

Static asset은 @kfind/kfind/assets/predicates.enriched.tsv와 compact component subpath로 export합니다.

Kfind와 Matcher

Kfind.withResources({ fullPos?, enrichedPredicates?, component? })가 전체 profile 생성 API입니다. compile(query, options)은 재사용 가능한 Matcher를 반환합니다.

API는 filesystem과 URL을 추정하지 않습니다. Caller가 resource string 또는 Uint8Array를 전달합니다.

import { Kfind } from '@kfind/kfind';

const engine = new Kfind();
const matcher = engine.compile('걷다', { pos: 'verb' });
const matches = matcher.findAll('길을 걸어 갔다.');

UTF-16 span

Match와 atom의 start·end는 UTF-16 code unit이며 JavaScript slice에 바로 사용할 수 있습니다. Emoji 앞의 offset도 code point 수가 아니라 code unit 수입니다.

각 atom은 core, token과 모든 analysisIndex, rulePath origin을 보존합니다.