morpheme-match-all
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.0.5](https://github.com/azu/morpheme-match-all/compare/v2.0.4...v2.0.5) (2019-10-20) | ||
### Bug Fixes | ||
* **morpheme-match-all:** fix generics type ([283f0fd](https://github.com/azu/morpheme-match-all/commit/283f0fd)) | ||
## [2.0.4](https://github.com/azu/morpheme-match-all/compare/v2.0.3...v2.0.4) (2019-10-20) | ||
@@ -8,0 +19,0 @@ |
@@ -7,6 +7,6 @@ import { Token, ExpectedToken, MatchResult } from "morpheme-match"; | ||
}; | ||
export declare class Expector<T extends ExpectedToken> { | ||
dict: ExpectedDictionary<T>; | ||
export declare class Expector<T extends ExpectedToken, Dictionary extends ExpectedDictionary<T>> { | ||
dict: Dictionary; | ||
private matcher; | ||
constructor(dict: ExpectedDictionary<T>); | ||
constructor(dict: Dictionary); | ||
/** | ||
@@ -13,0 +13,0 @@ * match and return results |
import { ExpectedDictionary } from "./Expector"; | ||
import { ExpectedToken, Token } from "morpheme-match"; | ||
export declare type ExpectedDictionaries<T extends ExpectedToken> = ExpectedDictionary<T>[]; | ||
export declare type ExpectedDictionaries<T extends ExpectedToken, Dictionary extends ExpectedDictionary<T>> = Dictionary[]; | ||
export { ExpectedDictionary }; | ||
export declare type MatchResult<T extends ExpectedToken> = { | ||
export declare type MatchResult<T extends ExpectedToken, Dictionary extends ExpectedDictionary<T>> = { | ||
tokens: Token[]; | ||
index: number; | ||
skipped: boolean[]; | ||
dict: ExpectedDictionary<T>; | ||
dict: Dictionary & ExpectedDictionary<T>; | ||
}; | ||
@@ -14,2 +14,2 @@ /** | ||
*/ | ||
export declare function createMatcher<T extends ExpectedToken>(dictionaries: ExpectedDictionaries<T & ExpectedToken>): (actualTokens: Token[]) => MatchResult<T>[]; | ||
export declare function createMatcher<T extends Partial<ExpectedToken>, Dictionary extends Partial<ExpectedDictionary<T>>>(dictionaries: ExpectedDictionaries<T & ExpectedToken, Dictionary & ExpectedDictionary<T>>): (tokens: Token[]) => MatchResult<T & ExpectedToken, Dictionary & ExpectedDictionary<T>>[]; |
{ | ||
"name": "morpheme-match-all", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "A wrapper of morpheme-match API. Match all kuromoji's tokens.", | ||
@@ -52,3 +52,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "e04dd2b7ba05005a3c8bd8eae81803e0ca77a95f" | ||
"gitHead": "dd31f48045233f08a65adc5d9d774f65615c3874" | ||
} |
@@ -12,6 +12,6 @@ // MIT © 2016 azu | ||
export class Expector<T extends ExpectedToken> { | ||
export class Expector<T extends ExpectedToken, Dictionary extends ExpectedDictionary<T>> { | ||
private matcher: any; | ||
constructor(public dict: ExpectedDictionary<T>) { | ||
constructor(public dict: Dictionary) { | ||
assert.ok(Array.isArray(dict["tokens"]), `"tokens" property is required. ${dict}`); | ||
@@ -18,0 +18,0 @@ this.matcher = createTokenMatcher(dict.tokens); |
// MIT © 2016 azu | ||
"use strict"; | ||
import {ExpectedDictionary, Expector} from "./Expector"; | ||
import {ExpectedToken, Token} from "morpheme-match"; | ||
import { ExpectedDictionary, Expector } from "./Expector"; | ||
import { ExpectedToken, Token } from "morpheme-match"; | ||
export type ExpectedDictionaries<T extends ExpectedToken> = ExpectedDictionary<T>[] | ||
export {ExpectedDictionary}; | ||
export type MatchResult<T extends ExpectedToken> = { | ||
export type ExpectedDictionaries<T extends ExpectedToken, Dictionary extends ExpectedDictionary<T>> = Dictionary[] | ||
export { ExpectedDictionary }; | ||
export type MatchResult<T extends ExpectedToken, Dictionary extends ExpectedDictionary<T>> = { | ||
tokens: Token[]; | ||
index: number; | ||
skipped: boolean[]; | ||
dict: ExpectedDictionary<T>; | ||
dict: Dictionary & ExpectedDictionary<T>; | ||
}; | ||
@@ -18,5 +18,7 @@ | ||
*/ | ||
export function createMatcher<T extends ExpectedToken>(dictionaries: ExpectedDictionaries<T & ExpectedToken>) { | ||
export function createMatcher<T extends Partial<ExpectedToken>, | ||
Dictionary extends Partial<ExpectedDictionary<T>>>(dictionaries: ExpectedDictionaries<T & ExpectedToken, Dictionary & ExpectedDictionary<T>>) | ||
: (tokens: Token[]) => MatchResult<T & ExpectedToken, Dictionary & ExpectedDictionary<T>>[] { | ||
const expectors = dictionaries.map(dict => { | ||
return new Expector(dict); | ||
return new Expector<T & ExpectedToken, Dictionary & ExpectedDictionary<T>>(dict); | ||
}); | ||
@@ -31,3 +33,3 @@ /** | ||
return function morphemeMatchAll(actualTokens: Token[]) { | ||
const matchResults: MatchResult<T>[] = []; | ||
const matchResults: MatchResult<T & ExpectedToken, Dictionary & ExpectedDictionary<T>>[] = []; | ||
actualTokens.forEach(actualToken => { | ||
@@ -34,0 +36,0 @@ expectors.forEach(expector => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18368
174