Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Typings #148

Merged
merged 1 commit into from
Jan 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
declare module "nodejieba" {
export function load(dict: object): void;
export function cut(sentence: string, strict?: boolean): any;
export function cutHMM(sentence: string): any;
export function cutAll(sentence: string): any;
export function cutForSearch(sentence: string, strict?: boolean): any;
export function tag(sentence: string): any;
export function extract(sentence: string, threshold: number): any;
export function insertWord(sentence: string): any;
export function cutSmall(sentence: string, small: number): any;
export interface LoadOptions {
dict?: string;
hmmDict?: string;
userDict?: string;
idfDict?: string;
stopWordDict?: string;
}

export interface TagResult {
word: string;
tag: string;
}

export interface ExtractResult {
word: string;
weight: number;
}

export function load(dict?: LoadOptions): void;
export function cut(sentence: string, strict?: boolean): string[];
export function cutHMM(sentence: string): string[];
export function cutAll(sentence: string): string[];
export function cutForSearch(sentence: string, strict?: boolean): string[];
export function tag(sentence: string): TagResult[];
export function extract(sentence: string, threshold: number): ExtractResult[];
export function insertWord(sentence: string): boolean;
export function cutSmall(sentence: string, small: number): boolean;
}