updated bug修复
This commit is contained in:
parent
cd19e1888a
commit
59fd3eb5c4
4
dist/relationship.min.js
vendored
4
dist/relationship.min.js
vendored
File diff suppressed because one or more lines are too long
4
dist/relationship.zh-HK.min.js
vendored
4
dist/relationship.zh-HK.min.js
vendored
File diff suppressed because one or more lines are too long
@ -246,7 +246,7 @@ export default {
|
|||||||
'w,{G1},d':['姨子'],
|
'w,{G1},d':['姨子'],
|
||||||
'w,{G1},d,h':['连襟','连桥'],
|
'w,{G1},d,h':['连襟','连桥'],
|
||||||
// 子辈及以下
|
// 子辈及以下
|
||||||
'{G0},s':['男','男儿','儿','子'],
|
'{G0},s':['男','男儿','儿','子','儿子'],
|
||||||
'{G0},s,w':['媳妇','媳','妇'],
|
'{G0},s,w':['媳妇','媳','妇'],
|
||||||
'{G0},s,s':['孙','孙男','孙子'],
|
'{G0},s,s':['孙','孙男','孙子'],
|
||||||
'{G0},s,s,w':['孙妇'],
|
'{G0},s,s,w':['孙妇'],
|
||||||
|
@ -426,8 +426,12 @@ export default {
|
|||||||
// 兄弟姐妹系
|
// 兄弟姐妹系
|
||||||
'ob':['哥哥','哥','胞兄','亲哥','老哥','依哥','阿哥','家兄','兄长','大佬','元兄','长兄','几哥'],
|
'ob':['哥哥','哥','胞兄','亲哥','老哥','依哥','阿哥','家兄','兄长','大佬','元兄','长兄','几哥'],
|
||||||
'ob,w':['嫂子','嫂','嫂嫂','阿嫂','家嫂','兄姊','兄嫂','兄妇','兄妻','几嫂'],
|
'ob,w':['嫂子','嫂','嫂嫂','阿嫂','家嫂','兄姊','兄嫂','兄妇','兄妻','几嫂'],
|
||||||
|
'ob,s':['侄子','兄子'],
|
||||||
|
'ob,d':['侄女','兄女'],
|
||||||
'lb':['弟弟','弟','胞弟','亲弟','老弟','阿弟','细佬','依弟','小弟','幺弟','细弟','满弟','幼弟','几弟'],
|
'lb':['弟弟','弟','胞弟','亲弟','老弟','阿弟','细佬','依弟','小弟','幺弟','细弟','满弟','幼弟','几弟'],
|
||||||
'lb,w':['弟妹','弟媳','弟媳妇','弟媳妇子','弟新妇','老弟嫂'],
|
'lb,w':['弟妹','弟媳','弟媳妇','弟媳妇子','弟新妇','老弟嫂'],
|
||||||
|
'lb,s':['侄子','弟子'],
|
||||||
|
'lb,d':['侄女','弟女'],
|
||||||
'xb,s':['侄子','侄男','侄儿','侄儿子','侄','侄仔','阿侄'],
|
'xb,s':['侄子','侄男','侄儿','侄儿子','侄','侄仔','阿侄'],
|
||||||
'xb,s,w':['侄媳妇','侄媳','侄嫂','侄妇'],
|
'xb,s,w':['侄媳妇','侄媳','侄嫂','侄妇'],
|
||||||
'xb,d':['侄女','侄囡','侄女儿','侄闺女'],
|
'xb,d':['侄女','侄囡','侄女儿','侄闺女'],
|
||||||
|
@ -14,8 +14,8 @@ for(var key in _branch){
|
|||||||
var newKey = key.replace(tag,k);
|
var newKey = key.replace(tag,k);
|
||||||
var isFilter = ['h,h','w,w','w,h','h,w'].some(pair=>(newKey.indexOf(pair)>-1));
|
var isFilter = ['h,h','w,w','w,h','h,w'].some(pair=>(newKey.indexOf(pair)>-1));
|
||||||
var newList = [];
|
var newList = [];
|
||||||
if(!isFilter){
|
if(!isFilter){
|
||||||
prefixList.forEach(function(prefix){
|
prefixList.forEach(function(prefix){
|
||||||
nameList.forEach(function(name){
|
nameList.forEach(function(name){
|
||||||
if(name.indexOf('?')>-1){
|
if(name.indexOf('?')>-1){
|
||||||
newList.push(name.replace('?',prefix));
|
newList.push(name.replace('?',prefix));
|
||||||
@ -32,6 +32,7 @@ for(var key in _branch){
|
|||||||
for(var key in _main){
|
for(var key in _main){
|
||||||
_map[key] = [].concat(_main[key],_map[key]||[]);
|
_map[key] = [].concat(_main[key],_map[key]||[]);
|
||||||
}
|
}
|
||||||
|
// 版权彩蛋
|
||||||
_map['o']=['passer-by.com','\u4f5c\u8005'];
|
_map['o']=['passer-by.com','\u4f5c\u8005'];
|
||||||
// 配偶关系
|
// 配偶关系
|
||||||
var branch = {
|
var branch = {
|
||||||
|
@ -68,12 +68,14 @@ var getGen = function(id){
|
|||||||
var getOptimal = function(options){
|
var getOptimal = function(options){
|
||||||
var from = options['from'];
|
var from = options['from'];
|
||||||
var to = options['to']
|
var to = options['to']
|
||||||
|
var sex = options['sex'];
|
||||||
var from_chain = options['from'].split(',');
|
var from_chain = options['from'].split(',');
|
||||||
var to_chain = options['to'].split(',');
|
var to_chain = options['to'].split(',');
|
||||||
for(var i=0;i<from_chain.length&&i<to_chain.length;i++){
|
for(var i=0;i<from_chain.length&&i<to_chain.length;i++){
|
||||||
if(from_chain[i]==to_chain[i]){
|
if(from_chain[i]==to_chain[i]){
|
||||||
from = from_chain.slice(i+1).join(',');
|
from = from_chain.slice(i+1).join(',');
|
||||||
to = to_chain.slice(i+1).join(',');
|
to = to_chain.slice(i+1).join(',');
|
||||||
|
sex = from_chain[i].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
if(getGen(from_chain[i])==getGen(to_chain[i])&&from_chain[i].match(/^[xol][bs]|^[sd]/)){
|
if(getGen(from_chain[i])==getGen(to_chain[i])&&from_chain[i].match(/^[xol][bs]|^[sd]/)){
|
||||||
@ -90,29 +92,25 @@ var getOptimal = function(options){
|
|||||||
if(!isNaN(from_attr)&&!isNaN(to_attr)){
|
if(!isNaN(from_attr)&&!isNaN(to_attr)){
|
||||||
if(from_attr>to_attr){
|
if(from_attr>to_attr){
|
||||||
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'lb').replace(/^[xol]s|^d/,'ls');
|
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'lb').replace(/^[xol]s|^d/,'ls');
|
||||||
from = from_chain.slice(i).join(',');
|
|
||||||
to = to_chain.slice(i+1).join(',');
|
|
||||||
}else if(from_attr<to_attr){
|
}else if(from_attr<to_attr){
|
||||||
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'ob').replace(/^[xol]s|^d/,'os');
|
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'ob').replace(/^[xol]s|^d/,'os');
|
||||||
from = from_chain.slice(i).join(',');
|
|
||||||
to = to_chain.slice(i+1).join(',');
|
|
||||||
}
|
}
|
||||||
}else if(!isNaN(from_attr)&&to_attr=='o'||from_attr=='l'&&!isNaN(to_attr)){
|
}else if(!isNaN(from_attr)&&to_attr=='o'||from_attr=='l'&&!isNaN(to_attr)){
|
||||||
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'lb').replace(/^[xol]s|^d/,'ls');
|
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'lb').replace(/^[xol]s|^d/,'ls');
|
||||||
from = from_chain.slice(i).join(',');
|
|
||||||
to = to_chain.slice(i+1).join(',');
|
|
||||||
}else if(!isNaN(from_attr)&&to_attr=='l'||from_attr=='o'&&!isNaN(to_attr)){
|
}else if(!isNaN(from_attr)&&to_attr=='l'||from_attr=='o'&&!isNaN(to_attr)){
|
||||||
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'ob').replace(/^[xol]s|^d/,'os');
|
from_chain[i] = from_chain[i].replace(/^[xol]b|^s/,'ob').replace(/^[xol]s|^d/,'os');
|
||||||
from = from_chain.slice(i).join(',');
|
|
||||||
to = to_chain.slice(i+1).join(',');
|
|
||||||
}
|
}
|
||||||
|
from = from_chain.slice(i).join(',');
|
||||||
|
to = to_chain.slice(i+1).join(',');
|
||||||
|
sex = to_chain[i].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
'from':from,
|
'from':from,
|
||||||
'to':to
|
'to':to,
|
||||||
|
'sex':sex
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -173,7 +171,6 @@ export function getSelectors(str){
|
|||||||
'祖$':['祖父'],
|
'祖$':['祖父'],
|
||||||
'嫂$':['兄妇'],
|
'嫂$':['兄妇'],
|
||||||
'女儿$':['女'],
|
'女儿$':['女'],
|
||||||
'外甥$':['甥'],
|
|
||||||
};
|
};
|
||||||
while(lists.length){
|
while(lists.length){
|
||||||
var name = lists.shift(); //当前匹配词
|
var name = lists.shift(); //当前匹配词
|
||||||
@ -310,10 +307,12 @@ export function mergeSelector(param){
|
|||||||
if(isOptimal){
|
if(isOptimal){
|
||||||
var ops = getOptimal({
|
var ops = getOptimal({
|
||||||
'from':from,
|
'from':from,
|
||||||
'to':to
|
'to':to,
|
||||||
|
'sex':my_sex
|
||||||
});
|
});
|
||||||
from = ops['from'];
|
from = ops['from'];
|
||||||
to = ops['to'];
|
to = ops['to'];
|
||||||
|
my_sex = ops['sex'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var to_rids = to?reverseId(to,my_sex):[''];
|
var to_rids = to?reverseId(to,my_sex):[''];
|
||||||
@ -472,7 +471,7 @@ export function getItemsById(id){
|
|||||||
if(_data[id]){
|
if(_data[id]){
|
||||||
var item = '';
|
var item = '';
|
||||||
var gen = getGen(id);
|
var gen = getGen(id);
|
||||||
if(gen<3){
|
if(gen<3&&!id.match(/[hw],/)){
|
||||||
_data[id].forEach(function(name){
|
_data[id].forEach(function(name){
|
||||||
if(!item&&name.indexOf('几')>-1){
|
if(!item&&name.indexOf('几')>-1){
|
||||||
item = name.replace('几',zh);
|
item = name.replace('几',zh);
|
||||||
|
@ -83,7 +83,7 @@ var prefix = {
|
|||||||
'1,f,f,xb,s,s':['三从'],
|
'1,f,f,xb,s,s':['三从'],
|
||||||
'h,xb':['叔侄','叔伯'],
|
'h,xb':['叔侄','叔伯'],
|
||||||
'w,xb':['舅侄'],
|
'w,xb':['舅侄'],
|
||||||
'xs':['甥'],
|
'xs':['甥','外甥'],
|
||||||
'0,xs':['从'],
|
'0,xs':['从'],
|
||||||
'0,m,xs,d':['再从'],
|
'0,m,xs,d':['再从'],
|
||||||
'0,m,m,xs,d,d':['三从'],
|
'0,m,m,xs,d,d':['三从'],
|
||||||
|
@ -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:'大舅',target:'二舅的儿子'}));
|
||||||
t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']);
|
t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']);
|
||||||
t.deepEqual(relationship({text:'爱人',sex:1}),['老婆']);
|
t.deepEqual(relationship({text:'爱人',sex:1}),['老婆']);
|
||||||
t.deepEqual(relationship({text:'爱人的爱人',sex:1}),['自己']);
|
t.deepEqual(relationship({text:'爱人的爱人',sex:1}),['自己']);
|
||||||
@ -34,5 +34,6 @@ test('relationship.js show to be tested', function (t) {
|
|||||||
t.deepEqual(relationship({text:'二舅妈',target:'大舅',type:'pair'}),['叔嫂']);
|
t.deepEqual(relationship({text:'二舅妈',target:'大舅',type:'pair'}),['叔嫂']);
|
||||||
t.deepEqual(relationship({text:'二舅妈',target:'三舅'}),['二嫂']);
|
t.deepEqual(relationship({text:'二舅妈',target:'三舅'}),['二嫂']);
|
||||||
t.deepEqual(relationship({text:'爸爸的二爸'}),['二爷爷']);
|
t.deepEqual(relationship({text:'爸爸的二爸'}),['二爷爷']);
|
||||||
|
t.deepEqual(relationship({text:'大舅',target:'二舅的儿子'}),['大伯']);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user