Skip to content

Commit

Permalink
more 得 improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
peterolson committed Dec 11, 2019
1 parent 84542f6 commit 8bbd17b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hanzi-tools",
"version": "1.2.13",
"version": "1.2.14",
"author": "Peter Olson <[email protected]>",
"description": "Converts from Chinese characters to pinyin, between simplified and traditional, and does word segmentation.",
"license": "Unlicense",
Expand Down
1 change: 1 addition & 0 deletions spec/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe("Pinyinify", () => {
expect("你得做个决定。").becomes("nǐ děi zuò gè jué​dìng.");
expect("你得在这儿休息。").becomes("nǐ děi zài zhè​r xiū​xi.");
expect("我现在富得能买我想要的任何东西。").becomes("wǒ xiàn​zài fù de néng mǎi wǒ xiǎng​yào de rèn​hé dōng​xi.");
expect("我们就得这么做。").becomes("wǒ​men jiù děi zhè​me zuò.");
// 还
expect("我有钱了就还你。").becomes("wǒ yǒu​qián le jiù huán nǐ.");
expect("我还给你。").becomes("wǒ huán​gěi nǐ.");
Expand Down
3 changes: 3 additions & 0 deletions src/pinyinify.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ function decideAmbiguousChar(char, cuts, cutIndex) {
if (prevTag === "a" || prevTag === "b" || prevTag === "nr") {
break;
}
if (prevTag === "d") {
return "děi";
}

if (nextTags[0].word === "还" || nextTags[0].word === "還") {
if (nextTags[1] && nextTags[1].tag[0] === "r" || nextTags[1].tag[0] === "n") {
Expand Down

0 comments on commit 8bbd17b

Please sign in to comment.