updated 姑表姐妹夫bug修复

This commit is contained in:
PASSER-BY
2022-12-28 22:08:47 +08:00
parent da7bd9058f
commit 5cbd9e9dca
4 changed files with 15 additions and 13 deletions
+2 -2
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+8 -7
View File
@@ -91,20 +91,21 @@ export function getItemsById(id){
res.push(_data[key][0]); res.push(_data[key][0]);
}else{ }else{
var ids = []; var ids = [];
if(_data[key+'&o']){
ids.push(key+'&o');
}
if(_data[key+'&l']){
ids.push(key+'&l');
}
var k = key.replace(/[ol](b|s)/,'x$1'); var k = key.replace(/[ol](b|s)/,'x$1');
if(_data[k]){ if(_data[k]){
ids.push(k); ids.push(k);
} }
k = key.replace(/(.+)(,[hw])$/,'$1&o$2').replace(/(,[^hw])$/,'$1&o');
if(_data[k]){
ids.push(k);
}
k = key.replace(/(.+)(,[hw])$/,'$1&l$2').replace(/(,[^hw])$/,'$1&l');
if(_data[k]){
ids.push(k);
}
res = filterId(ids).map(function(id){ res = filterId(ids).map(function(id){
return _data[id][0]; return _data[id][0];
}); });
} }
return res; return res;
}; };
+3 -2
View File
@@ -3,7 +3,7 @@ var test = require('tape');
var relationship = require('..'); var relationship = require('..');
test('relationship.js show to be tested', function (t) { test('relationship.js show to be tested', function (t) {
// console.log('[test]',relationship({text:'舅舅家哥哥的老'})); // console.log('[test]',relationship({text:'爸爸的妹妹的女儿的老'}));
t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']); t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']);
t.deepEqual(relationship({text:'爱人',sex:1}),['老婆']); t.deepEqual(relationship({text:'爱人',sex:1}),['老婆']);
@@ -39,7 +39,8 @@ test('relationship.js show to be tested', function (t) {
t.deepEqual(relationship({text:'爸爸的二爸'}),['二爷爷']); t.deepEqual(relationship({text:'爸爸的二爸'}),['二爷爷']);
t.deepEqual(relationship({text:'大舅',target:'二舅的儿子'}),['伯父']); t.deepEqual(relationship({text:'大舅',target:'二舅的儿子'}),['伯父']);
t.deepEqual(relationship({text:'堂哥',target:'叔叔',type:'pair'}),['叔侄','父子']); t.deepEqual(relationship({text:'堂哥',target:'叔叔',type:'pair'}),['叔侄','父子']);
t.deepEqual(relationship({text:'堂哥',target:'叔叔',type:'pair',optimal:true}),['父子']); t.deepEqual(relationship({text:'爸爸的妹妹的女儿的老公'}),['姑表姐夫','姑表妹夫']);
t.deepEqual(relationship('外婆和奶奶之间是什么关系?'),['儿女亲家']);
t.deepEqual(relationship('妈妈应该如何称呼姑姑'),['姑子']); t.deepEqual(relationship('妈妈应该如何称呼姑姑'),['姑子']);
t.deepEqual(relationship('姑奶奶是什么关系'),['爸爸的爸爸的姐妹']); t.deepEqual(relationship('姑奶奶是什么关系'),['爸爸的爸爸的姐妹']);
t.deepEqual(relationship('姑奶奶和爸爸是什么关系'),['姑侄']); t.deepEqual(relationship('姑奶奶和爸爸是什么关系'),['姑侄']);