Merge branch 'master' of https://github.com/mumuy/relationship
This commit is contained in:
commit
318e79bbae
2
dist/relationship.min.js
vendored
2
dist/relationship.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/relationship.zh-HK.min.js
vendored
2
dist/relationship.zh-HK.min.js
vendored
File diff suppressed because one or more lines are too long
@ -21,7 +21,12 @@ var getOptimal = function(options){
|
|||||||
sex = from_chain[i].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;
|
sex = from_chain[i].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}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 from_match = from_chain[i].match(/&([ol\d]+)/);
|
||||||
var to_match = to_chain[i].match(/&([ol\d]+)/);
|
var to_match = to_chain[i].match(/&([ol\d]+)/);
|
||||||
if(!from_match){
|
if(!from_match){
|
||||||
|
@ -33,7 +33,7 @@ var relationship = function (parameter){
|
|||||||
sex:options.sex,
|
sex:options.sex,
|
||||||
optimal:options.optimal
|
optimal:options.optimal
|
||||||
}).forEach(function(data){
|
}).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']):[];
|
var ids = data?selector2id(data['selector'],data['sex']):[];
|
||||||
// console.log('[ids]',data['selector'],data['sex'],ids);
|
// console.log('[ids]',data['selector'],data['sex'],ids);
|
||||||
ids.forEach(function(id){
|
ids.forEach(function(id){
|
||||||
|
@ -3,7 +3,8 @@ 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:'舅妈',target:'二舅',type:'pair'}));
|
||||||
|
// console.log('[test]',relationship({text:'姑姑',target:'叔叔',optimal:true}));
|
||||||
|
|
||||||
t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']);
|
t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']);
|
||||||
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:'二舅',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:'叔叔',optimal:true}),['姐姐','妹妹']);
|
||||||
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:'爸爸的妹妹的女儿的老公'}),['姑表姐夫','姑表妹夫']);
|
t.deepEqual(relationship({text:'爸爸的妹妹的女儿的老公'}),['姑表姐夫','姑表妹夫']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user