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: #300, dict for 抄查,不怀好意 #313

Merged
merged 3 commits into from
Feb 21, 2022
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: 1 addition & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run test-npm
- run: npm run test-cli
- run: npm run benchmark
- run: make test

- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
4 changes: 2 additions & 2 deletions data/phrases-dict.js
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ module.exports = {
"倡优": [["chàng"], ["yōu"]],
"唱和": [["chàng"], ["hè"]],
"唱头": [["chàng"], ["tóu"]],
"抄查": [["chāo"], ["zhā"]],
"抄查": [["chāo"], ["chá"]],
"抄家": [["chāo"], ["jiā"]],
"钞票": [["chāo"], ["piào"]],
"抄没": [["chāo"], ["méi"]],
Expand Down Expand Up @@ -18863,7 +18863,7 @@ module.exports = {
"不合时宜": [["bù"], ["hé"], ["shí"], ["yí"]],
"不哼不哈": [["bù"], ["hēng"], ["bù"], ["hā"]],
"不护细行": [["bù"], ["hù"], ["xì"], ["xíng"]],
"不怀好意": [["bù"], ["huái"], ["hào"], ["yì"]],
"不怀好意": [["bù"], ["huái"], ["hǎo"], ["yì"]],
"不欢而散": [["bù"], ["huān"], ["ér"], ["sàn"]],
"不慌不忙": [["bù"], ["huāng"], ["bù"], ["máng"]],
"不遑枚举": [["bù"], ["huáng"], ["méi"], ["jǔ"]],
Expand Down
10 changes: 5 additions & 5 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ function combo(arr) {

/**
* 组合两个拼音数组,形成一个新的二维数组
* @param {string[]|string[][]} arr1 eg: ['hai', 'huan']
* @param {Array<String>} arr2 eg: ['qian']
* @returns {string[][]} 组合后的二维数组,eg: [ ['hai', 'qian'], ['huan', 'qian'] ]
* @param {string[]|string[][]} arr1 eg: ["hai", "huan"]
* @param {Array<String>} arr2 eg: ["qian"]
* @returns {string[][]} 组合后的二维数组,eg: [ ["hai", "qian"], ["huan", "qian"] ]
*/
function compact2array(a1, a2) {
if (!Array.isArray(a1) || !Array.isArray(a2)) {
throw new Error("compact2array expect two array as parameters");
}
if (!a1.length) {
a1 = [''];
a1 = [""];
}
if (!a2.length) {
a2 = [''];
a2 = [""];
}
const result = [];
for (let i = 0, l = a1.length; i < l; i++) {
Expand Down
12 changes: 6 additions & 6 deletions tests/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ describe("test/util.test.js", function() {

describe("compact2array", function() {
it("compact2array([], [])", function() {
expect(util.compact2array([], [])).to.eql([['', '']]);
expect(util.compact2array([], [])).to.eql([["", ""]]);
});

it("compact2array([a], [])", function() {
expect(util.compact2array(["a"], [])).to.eql([["a", '']]);
expect(util.compact2array(["a"], [])).to.eql([["a", ""]]);
});

it("compact2array([], [1])", function() {
expect(util.compact2array([], ["1"])).to.eql([['', "1"]]);
expect(util.compact2array([], ["1"])).to.eql([["", "1"]]);
});

it("compact2array([a, b, c], [])", function() {
expect(util.compact2array(["a", "b", "c"], [])).to.eql([["a", ''], ["b", ''], ["c", '']]);
expect(util.compact2array(["a", "b", "c"], [])).to.eql([["a", ""], ["b", ""], ["c", ""]]);
});

it("compact2array([], [a, b, c])", function() {
expect(util.compact2array([], ["a", "b", "c"])).to.eql([['', "a"], ['', "b"], ['', "c"]]);
expect(util.compact2array([], ["a", "b", "c"])).to.eql([["", "a"], ["", "b"], ["", "c"]]);
});

it("compact2array([a], [1])", function() {
Expand Down Expand Up @@ -144,7 +144,7 @@ describe("test/util.test.js", function() {
});

it("compact([[ni],[],[hao, hai]])", function() {
expect(util.compact([["ni"], [], ["hao", "hai"]])).to.eql([["ni", '', "hao"], ["ni", '', "hai"]]);
expect(util.compact([["ni"], [], ["hao", "hai"]])).to.eql([["ni", "", "hao"], ["ni", "", "hai"]]);
});
});
});