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

fix: 修复 surname:head 对于复姓开头不生效的问题 #240

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/common/segmentit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class AC {
if (surname === "off") {
return item.priority !== Priority.Surname;
} else if (surname === "head") {
return i === 0;
return item.length - 1 - i === 0;
} else {
return true;
}
Expand All @@ -193,7 +193,7 @@ export class AC {
if (surname === "off") {
return item.priority !== Priority.Surname;
} else if (surname === "head") {
return i === 0;
return item.length - 1 - i === 0;
} else {
return true;
}
Expand Down
8 changes: 8 additions & 0 deletions test/surname.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ describe("surname", () => {
"zēng jīng cāng hǎi nán wèi shuǐ hǎo hǎo xué xí lè"
);
});

it("[surname]surname head double", () => {
const result = pinyin("令狐冲", { surname: "head" });
expect(result).to.be.equal("líng hú chōng");

const result1 = pinyin("万俟英", { surname: "head" });
expect(result1).to.be.equal("mò qí yīng");
});
});
Loading