mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-17 22:47:59 +01:00
17 lines
610 B
TypeScript
17 lines
610 B
TypeScript
import { defaultMatcher } from './query/matcher';
|
|
import { generateLexArray, generateLexResult } from './query/lex';
|
|
import { parseTokens } from './query/parse';
|
|
import { getAstMatcherForTerm } from './query/term';
|
|
|
|
function parseWithDefaultMatcher(term: string, fuzz: number) {
|
|
return getAstMatcherForTerm(term, fuzz, defaultMatcher);
|
|
}
|
|
|
|
export function parseSearch(query: string) {
|
|
const tokens = generateLexArray(query, parseWithDefaultMatcher);
|
|
return parseTokens(tokens);
|
|
}
|
|
|
|
export function getTermContexts(query: string) {
|
|
return generateLexResult(query, parseWithDefaultMatcher).termContexts;
|
|
}
|