morpheme-match
Version:
match function that match token(形態素解析) with sentence.
49 lines (48 loc) • 1.39 kB
TypeScript
export declare type Token = {
word_id: number;
word_type: "KNOWN" | "UNKNOWN";
surface_form: string;
pos: string;
pos_detail_1: string;
pos_detail_2: string;
pos_detail_3: string;
conjugated_type: string;
conjugated_form: string;
basic_form: string;
reading: string;
pronunciation: string;
word_position: number;
};
export declare type ExpectedTokenAdditional = {
_skippable?: boolean;
};
export declare type ExpectedToken = {
word_id?: number | number[];
word_type?: "KNOWN" | "UNKNOWN";
surface_form?: string | string[];
pos?: string | string[];
pos_detail_1?: string | string[];
pos_detail_2?: string | string[];
pos_detail_3?: string | string[];
conjugated_type?: string | string[];
conjugated_form?: string | string[];
basic_form?: string | string[];
reading?: string | string[];
pronunciation?: string | string[];
word_position?: number | number[];
} & ExpectedTokenAdditional & {
[index: string]: any;
};
export declare type MatchResult = {
match: boolean;
tokens: Token[];
skipped: boolean[];
};
/**
* Create matcher function that return { match : true , tokens []} if match the `token`.
*/
export declare function createTokenMatcher(expectedTokens: ExpectedToken[]): (token: Token) => {
match: boolean;
tokens: Token[];
skipped: boolean[];
};