This commit is contained in:
PASSER-BY 2023-01-03 01:00:23 +08:00
commit 318e79bbae
5 changed files with 12 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,12 @@ var getOptimal = function(options){
sex = from_chain[i].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;
continue;
}else{
if(getGenById(from_chain[i])==getGenById(to_chain[i])&&from_chain[i].match(/^[xol][bs]|^[sd]/)){
if(getGenById(from_chain[i])==getGenById(to_chain[i])&&from_chain[i].match(/^[xol][bs]|^[sd]/)&&to_chain[i].match(/^[xol][bs]|^[sd]/)){
var form_type = from_chain[i].replace(/&([ol\d]+)/,'').replace(/^[xol]([bs])/,'$1');
var to_type = to_chain[i].replace(/&([ol\d]+)/,'').replace(/^[xol]([bs])/,'$1');
if(form_type!=to_type){
break;
}
var from_match = from_chain[i].match(/&([ol\d]+)/);
var to_match = to_chain[i].match(/&([ol\d]+)/);
if(!from_match){

View File

@ -33,7 +33,7 @@ var relationship = function (parameter){
sex:options.sex,
optimal:options.optimal
}).forEach(function(data){
// console.log('[data]',from_selector,to_selector,data);
// console.log('[data]',from_selector,to_selector,options.optimal,data);
var ids = data?selector2id(data['selector'],data['sex']):[];
// console.log('[ids]',data['selector'],data['sex'],ids);
ids.forEach(function(id){

View File

@ -3,7 +3,8 @@ var test = require('tape');
var relationship = require('..');
test('relationship.js show to be tested', function (t) {
// console.log('[test]',relationship({text:'爸爸的妹妹的女儿的老公'}));
// console.log('[test]',relationship({text:'舅妈',target:'二舅',type:'pair'}));
// console.log('[test]',relationship({text:'姑姑',target:'叔叔',optimal:true}));
t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']);
t.deepEqual(relationship({text:'爱人',sex:1}),['老婆']);
@ -37,6 +38,7 @@ test('relationship.js show to be tested', function (t) {
t.deepEqual(relationship({text:'舅妈',target:'二舅',type:'pair'}),['叔嫂','夫妻']);
t.deepEqual(relationship({text:'二舅妈',target:'三舅'}),['二嫂']);
t.deepEqual(relationship({text:'爸爸的二爸'}),['二爷爷']);
t.deepEqual(relationship({text:'姑姑',target:'叔叔',optimal:true}),['姐姐','妹妹']);
t.deepEqual(relationship({text:'大舅',target:'二舅的儿子'}),['伯父']);
t.deepEqual(relationship({text:'堂哥',target:'叔叔',type:'pair'}),['叔侄','父子']);
t.deepEqual(relationship({text:'爸爸的妹妹的女儿的老公'}),['姑表姐夫','姑表妹夫']);