word-break-trie
Advanced tools
+3
-3
@@ -5,3 +5,3 @@ interface HasWordFunction { | ||
| declare function wordBreakTrie( | ||
| declare function wordBreak( | ||
| s: string, | ||
@@ -11,5 +11,5 @@ dict: HasWordFunction, | ||
| ): string[]; | ||
| declare namespace wordBreakTrie {} | ||
| declare namespace wordBreak {} | ||
| export = wordBreakTrie; | ||
| export = wordBreak; | ||
+3
-3
@@ -1,2 +0,2 @@ | ||
| function wordBreakTrie(s, hasWord, longestWordLength) { | ||
| function wordBreak(s, hasWord, longestWordLength) { | ||
| const size = s.length; | ||
@@ -13,3 +13,3 @@ if (size === 0) return []; | ||
| const end = i === s.length; | ||
| const words = !end ? wordBreakTrie(s.substring(i), hasWord, max) : []; | ||
| const words = !end ? wordBreak(s.substring(i), hasWord, max) : []; | ||
| ret.push(...words); | ||
@@ -22,3 +22,3 @@ return ret; | ||
| module.exports = wordBreakTrie; | ||
| module.exports = wordBreak; | ||
+1
-1
| { | ||
| "name": "word-break-trie", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "word-break util using trie-search dictionary", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+3
-3
@@ -8,11 +8,11 @@ # word-break-trie | ||
| ```ts | ||
| import wordBreakTrie from "word-break-trie"; | ||
| import wordBreak from "word-break-trie"; | ||
| import trie from "trie-prefix-tree"; | ||
| test("wordBreakTrie", () => { | ||
| test("wordBreak", () => { | ||
| const input = "ilikesamsung"; | ||
| const dict = trie(["samsung", "like", "i"]); | ||
| const list = wordBreakTrie(input, dict.hasWord); | ||
| const list = wordBreak(input, dict.hasWord); | ||
| expect(list.join("|")).toBe("i|like|samsung"); | ||
| }); | ||
| ``` |
3941
-0.91%