updated 性别识别bug修复
This commit is contained in:
parent
d5b731dda3
commit
fac0ddc0cc
2
dist/relationship.min.js
vendored
2
dist/relationship.min.js
vendored
File diff suppressed because one or more lines are too long
@ -382,7 +382,7 @@
|
|||||||
'f,f,f,xs,d,s&l,w':['姑表姑表叔母'],
|
'f,f,f,xs,d,s&l,w':['姑表姑表叔母'],
|
||||||
'f,f,f,xs,d,d':['姑表姑表姑母'],
|
'f,f,f,xs,d,d':['姑表姑表姑母'],
|
||||||
'f,f,f,xs,d,d,h':['姑表姑表姑父'],
|
'f,f,f,xs,d,d,h':['姑表姑表姑父'],
|
||||||
'f,f,m':['曾祖母','太奶奶','太婆','祖婆','祖奶奶'],
|
'f,f,m':['曾祖母','太婆','祖婆','太奶奶','祖奶奶'],
|
||||||
'f,f,m,f':['高外祖父','老太姥爷','祖太姥爷','祖太公','高王父'],
|
'f,f,m,f':['高外祖父','老太姥爷','祖太姥爷','祖太公','高王父'],
|
||||||
'f,f,m,m':['高外祖母','老太姥姥','祖太姥姥','祖太姥娘','祖太婆','高王母'],
|
'f,f,m,m':['高外祖母','老太姥姥','祖太姥姥','祖太姥娘','祖太婆','高王母'],
|
||||||
// 舅表*
|
// 舅表*
|
||||||
@ -2435,24 +2435,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 合并选择器,查找两个对象之间的关系
|
// 合并选择器,查找两个对象之间的关系
|
||||||
function mergeSelector(from,to){
|
function mergeSelector(from,to,mid_sex){
|
||||||
var mid_sex = -1;
|
|
||||||
if(mid_sex<0){
|
|
||||||
mid_sex = from.match(/^,w/)?1:0;
|
|
||||||
}
|
|
||||||
if(mid_sex<0){
|
|
||||||
mid_sex = to.match(/^,w/)?1:0;
|
|
||||||
}
|
|
||||||
mid_sex = mid_sex?1:0;
|
|
||||||
var sex = -1;
|
var sex = -1;
|
||||||
if(to){
|
if(to){
|
||||||
sex = to.match(/([fhs1](&[ol])?|[olx]b)$/)?1:0;
|
sex = to.match(/([fhs1](&[ol])?|[olx]b)$/)?1:0;
|
||||||
}
|
}
|
||||||
|
if(mid_sex==-1){
|
||||||
|
return {
|
||||||
|
'selector':(to?','+reverseId(to.substr(1),1):'')+from+'#'+(to?','+reverseId(to.substr(1),0):'')+from,
|
||||||
|
'sex':sex
|
||||||
|
};
|
||||||
|
}else{
|
||||||
return {
|
return {
|
||||||
'selector':(to?','+reverseId(to.substr(1),mid_sex):'')+from,
|
'selector':(to?','+reverseId(to.substr(1),mid_sex):'')+from,
|
||||||
'sex':sex
|
'sex':sex
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var relationship = function (parameter){
|
var relationship = function (parameter){
|
||||||
var options = Object.assign({
|
var options = Object.assign({
|
||||||
@ -2478,7 +2477,7 @@
|
|||||||
var result = []; //匹配结果
|
var result = []; //匹配结果
|
||||||
from_selectors.forEach(function(from){
|
from_selectors.forEach(function(from){
|
||||||
to_selectors.forEach(function(to){
|
to_selectors.forEach(function(to){
|
||||||
var data = mergeSelector(from,to);
|
var data = mergeSelector(from,to,options.sex);
|
||||||
// console.log('[data]',data);
|
// console.log('[data]',data);
|
||||||
sex = data['sex']>-1?data['sex']:options.sex;
|
sex = data['sex']>-1?data['sex']:options.sex;
|
||||||
var ids = selector2id(data['selector'],sex);
|
var ids = selector2id(data['selector'],sex);
|
||||||
|
@ -20,6 +20,7 @@ test('relationship.js show to be tested', function (t) {
|
|||||||
t.deepEqual(relationship({text:'堂兄弟的孩子',sex:1}),['堂侄','堂侄女']);
|
t.deepEqual(relationship({text:'堂兄弟的孩子',sex:1}),['堂侄','堂侄女']);
|
||||||
t.deepEqual(relationship({text:'岳母',target:'女儿',reverse:true}),['外孙女']);
|
t.deepEqual(relationship({text:'岳母',target:'女儿',reverse:true}),['外孙女']);
|
||||||
t.deepEqual(relationship({text:'姑妈',target:'舅妈',reverse:true}),['兄弟眷兄妇','兄弟眷弟妇']);
|
t.deepEqual(relationship({text:'姑妈',target:'舅妈',reverse:true}),['兄弟眷兄妇','兄弟眷弟妇']);
|
||||||
|
t.deepEqual(relationship({text:'舅妈',target:'女儿',reverse:true}),['姑甥孙女','姑甥外孙女']);
|
||||||
|
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user