From c16938b1618d6eabff6cc446f129a1e8cf1d2a09 Mon Sep 17 00:00:00 2001 From: PASSER-BY Date: Wed, 21 Feb 2024 22:39:46 +0800 Subject: [PATCH] =?UTF-8?q?updated=20=E5=8E=8B=E7=BC=A9=E5=88=86=E6=94=AF?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/lang/relationship-mode.zh-HK.min.js | 4 +- dist/lang/relationship-mode.zh-HK.min.mjs | 4 +- dist/lang/relationship.zh-HK.min.js | 6 +- dist/lang/relationship.zh-HK.min.mjs | 6 +- dist/relationship-mode.min.js | 4 +- dist/relationship-mode.min.mjs | 4 +- dist/relationship.min.js | 6 +- dist/relationship.min.mjs | 6 +- package.json | 4 +- src/module/data/branch.js | 168 ++++++++-------------- src/module/map.js | 26 ++-- 11 files changed, 93 insertions(+), 145 deletions(-) diff --git a/dist/lang/relationship-mode.zh-HK.min.js b/dist/lang/relationship-mode.zh-HK.min.js index 24707287..c935a85a 100644 --- a/dist/lang/relationship-mode.zh-HK.min.js +++ b/dist/lang/relationship-mode.zh-HK.min.js @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ !function(f,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(f="undefined"!=typeof globalThis?globalThis:f||self).relationshipMode=s()}(this,(function(){"use strict";function f(s){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(f){return typeof f}:function(f){return f&&"function"==typeof Symbol&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},f(s)}function s(s){var m=function(s,m){if("object"!==f(s)||null===s)return s;var o=s[Symbol.toPrimitive];if(void 0!==o){var d=o.call(s,m||"default");if("object"!==f(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===m?String:Number)(s)}(s,"string");return"symbol"===f(m)?m:String(m)}function m(f,m,o){return(m=s(m))in f?Object.defineProperty(f,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):f[m]=o,f}var o;return{guangdong:{name:"廣東",data:(o={f:["老竇"],"f,f":["阿爺"],"f,f,f":["太公"],"f,f,m":["太婆"],"f,m":["阿嫲"],"f,m,f":["太外公"],"f,m,m":["太外婆"],"f,ob":["伯伯"],"f,ob,w":["伯娘"],"f,lb":["阿叔"],"f,lb,w":["阿嬸"],"0,f,xb,d,s":["堂姨甥"],"1,f,xb,d,s":["堂外甥"],"0,f,xb,d,d":["堂姨甥女"],"1,f,xb,d,d":["堂外甥女"],"f,os":["姑母"],"f,ls":["姑姐"],"f,xs,h":["姑丈"],"0,f,xs,d,s":["姑表姨甥"],"1,f,xs,d,s":["姑表外甥"],"0,f,xs,d,d":["姑表姨甥女"],"1,f,xs,d,d":["姑表外甥女"],m:["老母"],"m,f":["阿公"],"m,f,f":["外太公"],"m,f,m":["外太婆"],"m,m":["阿婆"],"m,m,f":["外太外公"],"m,m,m":["外太外婆"],"m,ob":["舅父"],"m,lb":["舅仔"],"m,xb,w":["舅母"],"0,m,xb,d,s":["舅表姨甥"],"1,m,xb,d,s":["舅表外甥"],"0,m,xb,d,d":["舅表姨甥女"],"1,m,xb,d,d":["舅表外甥女"],"m,os":["姨媽"],"m,ls":["姨仔"],"m,xs,h":["姨丈"]},m(o,"0,m,xb,d,s",["姨姨甥"]),m(o,"1,m,xb,d,s",["姨外甥"]),m(o,"0,m,xb,d,d",["姨姨甥女"]),m(o,"1,m,xb,d,d",["姨外甥女"]),m(o,"ob",["大佬"]),m(o,"ob,w",["阿嫂"]),m(o,"lb",["細佬"]),m(o,"lb,w",["弟婦"]),m(o,"xb,s",["侄"]),m(o,"xb,d",["侄女"]),m(o,"os",["家姐"]),m(o,"os,h",["姐夫"]),m(o,"ls",["阿妹"]),m(o,"ls,h",["妹夫"]),m(o,"0,xs,s",["姨甥"]),m(o,"1,xs,s",["外甥"]),m(o,"0,xs,d",["姨甥女"]),m(o,"1,xs,d",["外甥女"]),m(o,"s",["仔"]),m(o,"s,w",["新婦"]),m(o,"s,s",["孫"]),m(o,"s,s,w",["孫新婦"]),m(o,"s,s,s",["息仔"]),m(o,"s,s,d",["息女"]),m(o,"s,d",["孫女"]),m(o,"s,d,h",["孫女婿"]),m(o,"s,d,s",["外息仔"]),m(o,"s,d,d",["外息女"]),m(o,"d",["女"]),m(o,"d,s",["外孫"]),m(o,"d,s,w",["外孫新婦"]),m(o,"d,s,s",["外息仔"]),m(o,"d,s,d",["外息女"]),m(o,"d,d",["外孫女"]),m(o,"d,d,h",["外孫女婿"]),m(o,"d,d,s",["外息仔"]),m(o,"d,d,d",["外息女"]),o)},north:{name:"北方",data:{"m,m":["姥姥"],"m,m,xs":["姨姥姥"],"m,m,xs,h":["姨姥爺"],"m,m,xb":["舅姥爺"],"m,m,xb,w":["舅姥姥"],"m,f":["姥爺"],"m,f,xs":["姑姥姥"],"m,f,xs,h":["姑姥爺"],"m,f,ob":["大姥爺"],"m,f,ob,w":["大姥姥"],"m,f,lb":["小姥爺"],"m,f,lb,w":["小姥姥"],"f,ob":["大爺"],"f,ob,w":["大娘"]}}}})); diff --git a/dist/lang/relationship-mode.zh-HK.min.mjs b/dist/lang/relationship-mode.zh-HK.min.mjs index 86f0d296..96db2d82 100644 --- a/dist/lang/relationship-mode.zh-HK.min.mjs +++ b/dist/lang/relationship-mode.zh-HK.min.mjs @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ function m(s){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(m){return typeof m}:function(m){return m&&"function"==typeof Symbol&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},m(s)}function s(s){var f=function(s,f){if("object"!==m(s)||null===s)return s;var d=s[Symbol.toPrimitive];if(void 0!==d){var o=d.call(s,f||"default");if("object"!==m(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(s)}(s,"string");return"symbol"===m(f)?f:String(f)}function f(m,f,d){return(f=s(f))in m?Object.defineProperty(m,f,{value:d,enumerable:!0,configurable:!0,writable:!0}):m[f]=d,m}var d,o={guangdong:{name:"廣東",data:(d={f:["老竇"],"f,f":["阿爺"],"f,f,f":["太公"],"f,f,m":["太婆"],"f,m":["阿嫲"],"f,m,f":["太外公"],"f,m,m":["太外婆"],"f,ob":["伯伯"],"f,ob,w":["伯娘"],"f,lb":["阿叔"],"f,lb,w":["阿嬸"],"0,f,xb,d,s":["堂姨甥"],"1,f,xb,d,s":["堂外甥"],"0,f,xb,d,d":["堂姨甥女"],"1,f,xb,d,d":["堂外甥女"],"f,os":["姑母"],"f,ls":["姑姐"],"f,xs,h":["姑丈"],"0,f,xs,d,s":["姑表姨甥"],"1,f,xs,d,s":["姑表外甥"],"0,f,xs,d,d":["姑表姨甥女"],"1,f,xs,d,d":["姑表外甥女"],m:["老母"],"m,f":["阿公"],"m,f,f":["外太公"],"m,f,m":["外太婆"],"m,m":["阿婆"],"m,m,f":["外太外公"],"m,m,m":["外太外婆"],"m,ob":["舅父"],"m,lb":["舅仔"],"m,xb,w":["舅母"],"0,m,xb,d,s":["舅表姨甥"],"1,m,xb,d,s":["舅表外甥"],"0,m,xb,d,d":["舅表姨甥女"],"1,m,xb,d,d":["舅表外甥女"],"m,os":["姨媽"],"m,ls":["姨仔"],"m,xs,h":["姨丈"]},f(d,"0,m,xb,d,s",["姨姨甥"]),f(d,"1,m,xb,d,s",["姨外甥"]),f(d,"0,m,xb,d,d",["姨姨甥女"]),f(d,"1,m,xb,d,d",["姨外甥女"]),f(d,"ob",["大佬"]),f(d,"ob,w",["阿嫂"]),f(d,"lb",["細佬"]),f(d,"lb,w",["弟婦"]),f(d,"xb,s",["侄"]),f(d,"xb,d",["侄女"]),f(d,"os",["家姐"]),f(d,"os,h",["姐夫"]),f(d,"ls",["阿妹"]),f(d,"ls,h",["妹夫"]),f(d,"0,xs,s",["姨甥"]),f(d,"1,xs,s",["外甥"]),f(d,"0,xs,d",["姨甥女"]),f(d,"1,xs,d",["外甥女"]),f(d,"s",["仔"]),f(d,"s,w",["新婦"]),f(d,"s,s",["孫"]),f(d,"s,s,w",["孫新婦"]),f(d,"s,s,s",["息仔"]),f(d,"s,s,d",["息女"]),f(d,"s,d",["孫女"]),f(d,"s,d,h",["孫女婿"]),f(d,"s,d,s",["外息仔"]),f(d,"s,d,d",["外息女"]),f(d,"d",["女"]),f(d,"d,s",["外孫"]),f(d,"d,s,w",["外孫新婦"]),f(d,"d,s,s",["外息仔"]),f(d,"d,s,d",["外息女"]),f(d,"d,d",["外孫女"]),f(d,"d,d,h",["外孫女婿"]),f(d,"d,d,s",["外息仔"]),f(d,"d,d,d",["外息女"]),d)},north:{name:"北方",data:{"m,m":["姥姥"],"m,m,xs":["姨姥姥"],"m,m,xs,h":["姨姥爺"],"m,m,xb":["舅姥爺"],"m,m,xb,w":["舅姥姥"],"m,f":["姥爺"],"m,f,xs":["姑姥姥"],"m,f,xs,h":["姑姥爺"],"m,f,ob":["大姥爺"],"m,f,ob,w":["大姥姥"],"m,f,lb":["小姥爺"],"m,f,lb,w":["小姥姥"],"f,ob":["大爺"],"f,ob,w":["大娘"]}}};export{o as default}; diff --git a/dist/lang/relationship.zh-HK.min.js b/dist/lang/relationship.zh-HK.min.js index 0ee63bfa..e0b40443 100644 --- a/dist/lang/relationship.zh-HK.min.js +++ b/dist/lang/relationship.zh-HK.min.js @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ -!function(s,f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define(f):(s="undefined"!=typeof globalThis?globalThis:s||self).relationship=f()}(this,(function(){"use strict";function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(應該|得)?管(\S+?)叫(什麼|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|與)(\S+?)(之間)?是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)對於(\S+?)是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什麼|啥)(意思|關系|親戚關系|輩分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(應該|得)?(稱呼|叫|喊)(什麼|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(應該|得)?(如何|怎麼)(稱呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(誰|什麼|什麼親戚|啥親戚|什麼人|什麼輩分|啥輩分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,e=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){e=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(e)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&N[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var T=Object.assign({},S,{"f,xb":["伯叔父","幾爸爸","幾爸","幾爹"],"f,xb,w":["伯叔母","幾媽媽","幾媽","幾娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","嬸子"]}),C={},k=function(s){T[s].forEach((function(f){void 0===C[f]&&(C[f]=[]),C[f].push(s)}))};for(var U in T)k(U);function q(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return z(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return z(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function z(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=H(s.from,d),r=H(s.to,d);if(!o.length||!r.length)return[];var e=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+l?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+h<+l&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),e=b[o].match(/([xol])[bs]/),h=r?r[1]:"",l=e?e[1]:"","x"==h||"x"==l)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?j(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");e.push({selector:x,sex:m})}))}))})),e}function F(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=q(o);try{for(r.s();!(b=r.n()).done;){var e=b.value;if((d=d.replace(e.exp,e.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function H(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=F(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return E(x)}var J=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(S=Object.assign({},g),s&&y[s])for(var f in y[s])S[f]=[].concat(y[s][f],g[f]||[])}(f.mode);var b=B(f.text),o=B(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){D({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?H(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=j(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=I(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=j(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),e=f.replace(/&[ol]/,"");for(var h in t){var l=h.split("#");if(l.length>1){var w=H(l[0]),M=H(l[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(t[h][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(t[h][0]),(n.includes(r)&&a.includes(e)||n.includes(e)&&a.includes(r))&&m.push(t[h][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=A(s);f.length||(f=A(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};return J.data=S,J.dataCount=Object.keys(S).length,J.setMode=function(s,f){y[s]=Object.assign(y[s]||{},f)},J})); +!function(s,f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define(f):(s="undefined"!=typeof globalThis?globalThis:s||self).relationship=f()}(this,(function(){"use strict";function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(應該|得)?管(\S+?)叫(什麼|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|與)(\S+?)(之間)?是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)對於(\S+?)是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什麼|啥)(意思|關系|親戚關系|輩分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(應該|得)?(稱呼|叫|喊)(什麼|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(應該|得)?(如何|怎麼)(稱呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(誰|什麼|什麼親戚|啥親戚|什麼人|什麼輩分|啥輩分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,e=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){e=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(e)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&k[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var q=Object.assign({},A,{"f,xb":["伯叔父","幾爸爸","幾爸","幾爹"],"f,xb,w":["伯叔母","幾媽媽","幾媽","幾娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","嬸子"]}),z={},B=function(s){q[s].forEach((function(f){void 0===z[f]&&(z[f]=[]),z[f].push(s)}))};for(var D in q)B(D);function F(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return H(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return H(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function H(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=P(s.from,d),r=P(s.to,d);if(!o.length||!r.length)return[];var e=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+t?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+h<+t&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),e=b[o].match(/([xol])[bs]/),h=r?r[1]:"",t=e?e[1]:"","x"==h||"x"==t)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?N(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");e.push({selector:x,sex:m})}))}))})),e}function L(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=F(o);try{for(r.s();!(b=r.n()).done;){var e=b.value;if((d=d.replace(e.exp,e.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function P(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=L(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return I(x)}var Q=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(A=Object.assign({},j),s&&O[s])for(var f in O[s])A[f]=[].concat(O[s][f],j[f]||[])}(f.mode);var b=J(f.text),o=J(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){K({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?P(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=N(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=U(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=N(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),e=f.replace(/&[ol]/,"");for(var h in l){var t=h.split("#");if(t.length>1){var w=P(t[0]),M=P(t[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(l[h][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(l[h][0]),(n.includes(r)&&a.includes(e)||n.includes(e)&&a.includes(r))&&m.push(l[h][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=C(s);f.length||(f=C(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};return Q.data=A,Q.dataCount=Object.keys(A).length,Q.setMode=function(s,f){O[s]=Object.assign(O[s]||{},f)},Q})); diff --git a/dist/lang/relationship.zh-HK.min.mjs b/dist/lang/relationship.zh-HK.min.mjs index dc152ade..2b5fcb3d 100644 --- a/dist/lang/relationship.zh-HK.min.mjs +++ b/dist/lang/relationship.zh-HK.min.mjs @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ -function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(應該|得)?管(\S+?)叫(什麼|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|與)(\S+?)(之間)?是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)對於(\S+?)是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什麼|啥)(意思|關系|親戚關系|輩分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(應該|得)?(稱呼|叫|喊)(什麼|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(應該|得)?(如何|怎麼)(稱呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(誰|什麼|什麼親戚|啥親戚|什麼人|什麼輩分|啥輩分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,h=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){h=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(h)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&N[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var C=Object.assign({},S,{"f,xb":["伯叔父","幾爸爸","幾爸","幾爹"],"f,xb,w":["伯叔母","幾媽媽","幾媽","幾娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","嬸子"]}),T={},k=function(s){C[s].forEach((function(f){void 0===T[f]&&(T[f]=[]),T[f].push(s)}))};for(var U in C)k(U);function q(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return z(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return z(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function z(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=H(s.from,d),r=H(s.to,d);if(!o.length||!r.length)return[];var h=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+l?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+e<+l&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),h=b[o].match(/([xol])[bs]/),e=r?r[1]:"",l=h?h[1]:"","x"==e||"x"==l)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?E(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");h.push({selector:x,sex:m})}))}))})),h}function F(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=q(o);try{for(r.s();!(b=r.n()).done;){var h=b.value;if((d=d.replace(h.exp,h.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function H(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=F(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return j(x)}var J=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(S=Object.assign({},g),s&&y[s])for(var f in y[s])S[f]=[].concat(y[s][f],g[f]||[])}(f.mode);var b=B(f.text),o=B(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){D({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?H(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=E(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=I(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=E(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),h=f.replace(/&[ol]/,"");for(var e in t){var l=e.split("#");if(l.length>1){var w=H(l[0]),M=H(l[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(t[e][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(t[e][0]),(n.includes(r)&&a.includes(h)||n.includes(h)&&a.includes(r))&&m.push(t[e][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=A(s);f.length||(f=A(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};J.data=S,J.dataCount=Object.keys(S).length,J.setMode=function(s,f){y[s]=Object.assign(y[s]||{},f)};export{J as default}; +function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(應該|得)?管(\S+?)叫(什麼|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|與)(\S+?)(之間)?是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)對於(\S+?)是(什麼|啥)關系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什麼|啥)(意思|關系|親戚關系|輩分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(應該|得)?(稱呼|叫|喊)(什麼|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(應該|得)?(如何|怎麼)(稱呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(誰|什麼|什麼親戚|啥親戚|什麼人|什麼輩分|啥輩分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,h=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){h=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(h)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&k[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var q=Object.assign({},A,{"f,xb":["伯叔父","幾爸爸","幾爸","幾爹"],"f,xb,w":["伯叔母","幾媽媽","幾媽","幾娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","嬸子"]}),z={},B=function(s){q[s].forEach((function(f){void 0===z[f]&&(z[f]=[]),z[f].push(s)}))};for(var D in q)B(D);function F(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return H(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return H(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function H(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=P(s.from,d),r=P(s.to,d);if(!o.length||!r.length)return[];var h=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+l?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+e<+l&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),h=b[o].match(/([xol])[bs]/),e=r?r[1]:"",l=h?h[1]:"","x"==e||"x"==l)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?N(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");h.push({selector:x,sex:m})}))}))})),h}function L(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=F(o);try{for(r.s();!(b=r.n()).done;){var h=b.value;if((d=d.replace(h.exp,h.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function P(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=L(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return I(x)}var Q=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(A=Object.assign({},j),s&&O[s])for(var f in O[s])A[f]=[].concat(O[s][f],j[f]||[])}(f.mode);var b=J(f.text),o=J(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){K({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?P(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=N(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=U(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=N(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),h=f.replace(/&[ol]/,"");for(var e in t){var l=e.split("#");if(l.length>1){var w=P(l[0]),M=P(l[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(t[e][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(t[e][0]),(n.includes(r)&&a.includes(h)||n.includes(h)&&a.includes(r))&&m.push(t[e][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=T(s);f.length||(f=T(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};Q.data=A,Q.dataCount=Object.keys(A).length,Q.setMode=function(s,f){O[s]=Object.assign(O[s]||{},f)};export{Q as default}; diff --git a/dist/relationship-mode.min.js b/dist/relationship-mode.min.js index c8862f6e..a0e52659 100644 --- a/dist/relationship-mode.min.js +++ b/dist/relationship-mode.min.js @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ !function(f,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(f="undefined"!=typeof globalThis?globalThis:f||self).relationshipMode=s()}(this,(function(){"use strict";function f(s){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(f){return typeof f}:function(f){return f&&"function"==typeof Symbol&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},f(s)}function s(s){var m=function(s,m){if("object"!==f(s)||null===s)return s;var o=s[Symbol.toPrimitive];if(void 0!==o){var d=o.call(s,m||"default");if("object"!==f(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===m?String:Number)(s)}(s,"string");return"symbol"===f(m)?m:String(m)}function m(f,m,o){return(m=s(m))in f?Object.defineProperty(f,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):f[m]=o,f}var o;return{guangdong:{name:"广东",data:(o={f:["老窦"],"f,f":["阿爷"],"f,f,f":["太公"],"f,f,m":["太婆"],"f,m":["阿嫲"],"f,m,f":["太外公"],"f,m,m":["太外婆"],"f,ob":["伯伯"],"f,ob,w":["伯娘"],"f,lb":["阿叔"],"f,lb,w":["阿婶"],"0,f,xb,d,s":["堂姨甥"],"1,f,xb,d,s":["堂外甥"],"0,f,xb,d,d":["堂姨甥女"],"1,f,xb,d,d":["堂外甥女"],"f,os":["姑母"],"f,ls":["姑姐"],"f,xs,h":["姑丈"],"0,f,xs,d,s":["姑表姨甥"],"1,f,xs,d,s":["姑表外甥"],"0,f,xs,d,d":["姑表姨甥女"],"1,f,xs,d,d":["姑表外甥女"],m:["老母"],"m,f":["阿公"],"m,f,f":["外太公"],"m,f,m":["外太婆"],"m,m":["阿婆"],"m,m,f":["外太外公"],"m,m,m":["外太外婆"],"m,ob":["舅父"],"m,lb":["舅仔"],"m,xb,w":["舅母"],"0,m,xb,d,s":["舅表姨甥"],"1,m,xb,d,s":["舅表外甥"],"0,m,xb,d,d":["舅表姨甥女"],"1,m,xb,d,d":["舅表外甥女"],"m,os":["姨妈"],"m,ls":["姨仔"],"m,xs,h":["姨丈"]},m(o,"0,m,xb,d,s",["姨姨甥"]),m(o,"1,m,xb,d,s",["姨外甥"]),m(o,"0,m,xb,d,d",["姨姨甥女"]),m(o,"1,m,xb,d,d",["姨外甥女"]),m(o,"ob",["大佬"]),m(o,"ob,w",["阿嫂"]),m(o,"lb",["细佬"]),m(o,"lb,w",["弟妇"]),m(o,"xb,s",["侄"]),m(o,"xb,d",["侄女"]),m(o,"os",["家姐"]),m(o,"os,h",["姐夫"]),m(o,"ls",["阿妹"]),m(o,"ls,h",["妹夫"]),m(o,"0,xs,s",["姨甥"]),m(o,"1,xs,s",["外甥"]),m(o,"0,xs,d",["姨甥女"]),m(o,"1,xs,d",["外甥女"]),m(o,"s",["仔"]),m(o,"s,w",["新妇"]),m(o,"s,s",["孙"]),m(o,"s,s,w",["孙新妇"]),m(o,"s,s,s",["息仔"]),m(o,"s,s,d",["息女"]),m(o,"s,d",["孙女"]),m(o,"s,d,h",["孙女婿"]),m(o,"s,d,s",["外息仔"]),m(o,"s,d,d",["外息女"]),m(o,"d",["女"]),m(o,"d,s",["外孙"]),m(o,"d,s,w",["外孙新妇"]),m(o,"d,s,s",["外息仔"]),m(o,"d,s,d",["外息女"]),m(o,"d,d",["外孙女"]),m(o,"d,d,h",["外孙女婿"]),m(o,"d,d,s",["外息仔"]),m(o,"d,d,d",["外息女"]),o)},north:{name:"北方",data:{"m,m":["姥姥"],"m,m,xs":["姨姥姥"],"m,m,xs,h":["姨姥爷"],"m,m,xb":["舅姥爷"],"m,m,xb,w":["舅姥姥"],"m,f":["姥爷"],"m,f,xs":["姑姥姥"],"m,f,xs,h":["姑姥爷"],"m,f,ob":["大姥爷"],"m,f,ob,w":["大姥姥"],"m,f,lb":["小姥爷"],"m,f,lb,w":["小姥姥"],"f,ob":["大爷"],"f,ob,w":["大娘"]}}}})); diff --git a/dist/relationship-mode.min.mjs b/dist/relationship-mode.min.mjs index 2526b619..c06dde0a 100644 --- a/dist/relationship-mode.min.mjs +++ b/dist/relationship-mode.min.mjs @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ function m(s){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(m){return typeof m}:function(m){return m&&"function"==typeof Symbol&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},m(s)}function s(s){var f=function(s,f){if("object"!==m(s)||null===s)return s;var d=s[Symbol.toPrimitive];if(void 0!==d){var o=d.call(s,f||"default");if("object"!==m(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(s)}(s,"string");return"symbol"===m(f)?f:String(f)}function f(m,f,d){return(f=s(f))in m?Object.defineProperty(m,f,{value:d,enumerable:!0,configurable:!0,writable:!0}):m[f]=d,m}var d,o={guangdong:{name:"广东",data:(d={f:["老窦"],"f,f":["阿爷"],"f,f,f":["太公"],"f,f,m":["太婆"],"f,m":["阿嫲"],"f,m,f":["太外公"],"f,m,m":["太外婆"],"f,ob":["伯伯"],"f,ob,w":["伯娘"],"f,lb":["阿叔"],"f,lb,w":["阿婶"],"0,f,xb,d,s":["堂姨甥"],"1,f,xb,d,s":["堂外甥"],"0,f,xb,d,d":["堂姨甥女"],"1,f,xb,d,d":["堂外甥女"],"f,os":["姑母"],"f,ls":["姑姐"],"f,xs,h":["姑丈"],"0,f,xs,d,s":["姑表姨甥"],"1,f,xs,d,s":["姑表外甥"],"0,f,xs,d,d":["姑表姨甥女"],"1,f,xs,d,d":["姑表外甥女"],m:["老母"],"m,f":["阿公"],"m,f,f":["外太公"],"m,f,m":["外太婆"],"m,m":["阿婆"],"m,m,f":["外太外公"],"m,m,m":["外太外婆"],"m,ob":["舅父"],"m,lb":["舅仔"],"m,xb,w":["舅母"],"0,m,xb,d,s":["舅表姨甥"],"1,m,xb,d,s":["舅表外甥"],"0,m,xb,d,d":["舅表姨甥女"],"1,m,xb,d,d":["舅表外甥女"],"m,os":["姨妈"],"m,ls":["姨仔"],"m,xs,h":["姨丈"]},f(d,"0,m,xb,d,s",["姨姨甥"]),f(d,"1,m,xb,d,s",["姨外甥"]),f(d,"0,m,xb,d,d",["姨姨甥女"]),f(d,"1,m,xb,d,d",["姨外甥女"]),f(d,"ob",["大佬"]),f(d,"ob,w",["阿嫂"]),f(d,"lb",["细佬"]),f(d,"lb,w",["弟妇"]),f(d,"xb,s",["侄"]),f(d,"xb,d",["侄女"]),f(d,"os",["家姐"]),f(d,"os,h",["姐夫"]),f(d,"ls",["阿妹"]),f(d,"ls,h",["妹夫"]),f(d,"0,xs,s",["姨甥"]),f(d,"1,xs,s",["外甥"]),f(d,"0,xs,d",["姨甥女"]),f(d,"1,xs,d",["外甥女"]),f(d,"s",["仔"]),f(d,"s,w",["新妇"]),f(d,"s,s",["孙"]),f(d,"s,s,w",["孙新妇"]),f(d,"s,s,s",["息仔"]),f(d,"s,s,d",["息女"]),f(d,"s,d",["孙女"]),f(d,"s,d,h",["孙女婿"]),f(d,"s,d,s",["外息仔"]),f(d,"s,d,d",["外息女"]),f(d,"d",["女"]),f(d,"d,s",["外孙"]),f(d,"d,s,w",["外孙新妇"]),f(d,"d,s,s",["外息仔"]),f(d,"d,s,d",["外息女"]),f(d,"d,d",["外孙女"]),f(d,"d,d,h",["外孙女婿"]),f(d,"d,d,s",["外息仔"]),f(d,"d,d,d",["外息女"]),d)},north:{name:"北方",data:{"m,m":["姥姥"],"m,m,xs":["姨姥姥"],"m,m,xs,h":["姨姥爷"],"m,m,xb":["舅姥爷"],"m,m,xb,w":["舅姥姥"],"m,f":["姥爷"],"m,f,xs":["姑姥姥"],"m,f,xs,h":["姑姥爷"],"m,f,ob":["大姥爷"],"m,f,ob,w":["大姥姥"],"m,f,lb":["小姥爷"],"m,f,lb,w":["小姥姥"],"f,ob":["大爷"],"f,ob,w":["大娘"]}}};export{o as default}; diff --git a/dist/relationship.min.js b/dist/relationship.min.js index a74baa38..a6aeda89 100644 --- a/dist/relationship.min.js +++ b/dist/relationship.min.js @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ -!function(s,f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define(f):(s="undefined"!=typeof globalThis?globalThis:s||self).relationship=f()}(this,(function(){"use strict";function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(应该|得)?管(\S+?)叫(什么|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|与)(\S+?)(之间)?是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)对于(\S+?)是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什么|啥)(意思|关系|亲戚关系|辈分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(应该|得)?(称呼|叫|喊)(什么|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(应该|得)?(如何|怎么)(称呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(谁|什么|什么亲戚|啥亲戚|什么人|什么辈分|啥辈分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,e=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){e=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(e)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&N[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var T=Object.assign({},S,{"f,xb":["伯叔父","几爸爸","几爸","几爹"],"f,xb,w":["伯叔母","几妈妈","几妈","几娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","婶子"]}),C={},k=function(s){T[s].forEach((function(f){void 0===C[f]&&(C[f]=[]),C[f].push(s)}))};for(var U in T)k(U);function q(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return z(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return z(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function z(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=H(s.from,d),r=H(s.to,d);if(!o.length||!r.length)return[];var e=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+l?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+h<+l&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),e=b[o].match(/([xol])[bs]/),h=r?r[1]:"",l=e?e[1]:"","x"==h||"x"==l)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?j(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");e.push({selector:x,sex:m})}))}))})),e}function F(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=q(o);try{for(r.s();!(b=r.n()).done;){var e=b.value;if((d=d.replace(e.exp,e.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function H(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=F(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return E(x)}var J=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(S=Object.assign({},g),s&&y[s])for(var f in y[s])S[f]=[].concat(y[s][f],g[f]||[])}(f.mode);var b=B(f.text),o=B(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){D({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?H(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=j(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=I(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=j(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),e=f.replace(/&[ol]/,"");for(var h in t){var l=h.split("#");if(l.length>1){var w=H(l[0]),M=H(l[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(t[h][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(t[h][0]),(n.includes(r)&&a.includes(e)||n.includes(e)&&a.includes(r))&&m.push(t[h][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=A(s);f.length||(f=A(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};return J.data=S,J.dataCount=Object.keys(S).length,J.setMode=function(s,f){y[s]=Object.assign(y[s]||{},f)},J})); +!function(s,f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define(f):(s="undefined"!=typeof globalThis?globalThis:s||self).relationship=f()}(this,(function(){"use strict";function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(应该|得)?管(\S+?)叫(什么|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|与)(\S+?)(之间)?是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)对于(\S+?)是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什么|啥)(意思|关系|亲戚关系|辈分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(应该|得)?(称呼|叫|喊)(什么|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(应该|得)?(如何|怎么)(称呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(谁|什么|什么亲戚|啥亲戚|什么人|什么辈分|啥辈分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,e=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){e=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(e)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&k[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var q=Object.assign({},A,{"f,xb":["伯叔父","几爸爸","几爸","几爹"],"f,xb,w":["伯叔母","几妈妈","几妈","几娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","婶子"]}),z={},B=function(s){q[s].forEach((function(f){void 0===z[f]&&(z[f]=[]),z[f].push(s)}))};for(var D in q)B(D);function F(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return H(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return H(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function H(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=P(s.from,d),r=P(s.to,d);if(!o.length||!r.length)return[];var e=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+t?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+h<+t&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),e=b[o].match(/([xol])[bs]/),h=r?r[1]:"",t=e?e[1]:"","x"==h||"x"==t)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?N(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");e.push({selector:x,sex:m})}))}))})),e}function L(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=F(o);try{for(r.s();!(b=r.n()).done;){var e=b.value;if((d=d.replace(e.exp,e.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function P(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=L(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return I(x)}var Q=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(A=Object.assign({},j),s&&O[s])for(var f in O[s])A[f]=[].concat(O[s][f],j[f]||[])}(f.mode);var b=J(f.text),o=J(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){K({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?P(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=N(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=U(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=N(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),e=f.replace(/&[ol]/,"");for(var h in l){var t=h.split("#");if(t.length>1){var w=P(t[0]),M=P(t[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(l[h][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(l[h][0]),(n.includes(r)&&a.includes(e)||n.includes(e)&&a.includes(r))&&m.push(l[h][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=C(s);f.length||(f=C(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};return Q.data=A,Q.dataCount=Object.keys(A).length,Q.setMode=function(s,f){O[s]=Object.assign(O[s]||{},f)},Q})); diff --git a/dist/relationship.min.mjs b/dist/relationship.min.mjs index 24e06804..977e8334 100644 --- a/dist/relationship.min.mjs +++ b/dist/relationship.min.mjs @@ -1,5 +1,5 @@ /*! - * relationship.js v1.2.4 + * relationship.js v1.2.5 * Chinese kinship library * https://passer-by.com/relationship/ * @@ -8,6 +8,6 @@ * Released under the MIT License * https://github.com/mumuy/relationship * - * Created on: 2023-12-22 + * Created on: 2024-02-21 */ -function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(应该|得)?管(\S+?)叫(什么|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|与)(\S+?)(之间)?是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)对于(\S+?)是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什么|啥)(意思|关系|亲戚关系|辈分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(应该|得)?(称呼|叫|喊)(什么|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(应该|得)?(如何|怎么)(称呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(谁|什么|什么亲戚|啥亲戚|什么人|什么辈分|啥辈分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,h=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){h=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(h)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&N[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var C=Object.assign({},S,{"f,xb":["伯叔父","几爸爸","几爸","几爹"],"f,xb,w":["伯叔母","几妈妈","几妈","几娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","婶子"]}),T={},k=function(s){C[s].forEach((function(f){void 0===T[f]&&(T[f]=[]),T[f].push(s)}))};for(var U in C)k(U);function q(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return z(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return z(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function z(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=H(s.from,d),r=H(s.to,d);if(!o.length||!r.length)return[];var h=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+l?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+e<+l&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),h=b[o].match(/([xol])[bs]/),e=r?r[1]:"",l=h?h[1]:"","x"==e||"x"==l)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?E(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");h.push({selector:x,sex:m})}))}))})),h}function F(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=q(o);try{for(r.s();!(b=r.n()).done;){var h=b.value;if((d=d.replace(h.exp,h.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function H(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=F(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return j(x)}var J=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(S=Object.assign({},g),s&&y[s])for(var f in y[s])S[f]=[].concat(y[s][f],g[f]||[])}(f.mode);var b=B(f.text),o=B(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){D({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?H(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=E(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=I(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=E(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),h=f.replace(/&[ol]/,"");for(var e in t){var l=e.split("#");if(l.length>1){var w=H(l[0]),M=H(l[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(t[e][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(t[e][0]),(n.includes(r)&&a.includes(h)||n.includes(h)&&a.includes(r))&&m.push(t[e][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=A(s);f.length||(f=A(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};J.data=S,J.dataCount=Object.keys(S).length,J.setMode=function(s,f){y[s]=Object.assign(y[s]||{},f)};export{J as default}; +function s(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1?"default":"chain"}}},{exp:/^(\S+?)(应该|得)?管(\S+?)叫(什么|啥)??$/,opt:function(s){return{text:s[3],target:s[1]}}},{exp:/^(\S+?)(和|与)(\S+?)(之间)?是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[3],type:"pair"}}},{exp:/^(\S+?)对于(\S+?)是(什么|啥)关系??$/,opt:function(s){return{text:s[1],target:s[2],type:"chain"}}},{exp:/^(\S+?)(指的)?是(什么|啥)(意思|关系|亲戚关系|辈分|人)??$/,opt:function(s){return{text:s[1],type:"chain"}}},{exp:/^(\S+?)(应该|得)?(称呼|叫|喊)(什么|啥)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)(应该|得)?(如何|怎么)(称呼|叫|喊)??$/,opt:function(s){return{text:s[1]}}},{exp:/^(\S+?)是(谁|什么|什么亲戚|啥亲戚|什么人|什么辈分|啥辈分)??$/,opt:function(s){return{text:s[1],type:s[1].indexOf("的")>-1?"default":"chain"}}}];function m(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return b(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return b(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,h=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return r=s.done,s},e:function(s){h=!0,o=s},f:function(){try{r||null==x.return||x.return()}finally{if(h)throw o}}}}function b(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1&&k[f+","+s]&&(0==f?x="(女性)"+x:1==f&&(x="(男性)"+x)),x}var q=Object.assign({},A,{"f,xb":["伯叔父","几爸爸","几爸","几爹"],"f,xb,w":["伯叔母","几妈妈","几妈","几娘"],"h,xb":["伯叔"],"h,xb,w":["妯娌","娣姒","娣姒姊妹","婶子"]}),z={},B=function(s){q[s].forEach((function(f){void 0===z[f]&&(z[f]=[]),z[f].push(s)}))};for(var D in q)B(D);function F(s,f){var x="undefined"!=typeof Symbol&&s[Symbol.iterator]||s["@@iterator"];if(!x){if(Array.isArray(s)||(x=function(s,f){if(!s)return;if("string"==typeof s)return H(s,f);var x=Object.prototype.toString.call(s).slice(8,-1);"Object"===x&&s.constructor&&(x=s.constructor.name);if("Map"===x||"Set"===x)return Array.from(s);if("Arguments"===x||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x))return H(s,f)}(s))||f&&s&&"number"==typeof s.length){x&&(s=x);var d=0,m=function(){};return{s:m,n:function(){return d>=s.length?{done:!0}:{done:!1,value:s[d++]}},e:function(s){throw s},f:m}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b,o=!0,r=!1;return{s:function(){x=x.call(s)},n:function(){var s=x.next();return o=s.done,s},e:function(s){r=!0,b=s},f:function(){try{o||null==x.return||x.return()}finally{if(r)throw b}}}}function H(s,f){(null==f||f>s.length)&&(f=s.length);for(var x=0,d=new Array(f);x-1)d=m;else if(b>-1&&-1==m)d=b;else{if(b!=m)return[];d=b}}var o=P(s.from,d),r=P(s.to,d);if(!o.length||!r.length)return[];var h=[];return o.forEach((function(f){r.forEach((function(x){var m=d,b=","+x;if(b.match(/,([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?$/)&&(m=1),b.match(/,([mwd0](&[ol\d]+)?|[olx]s)(&[ol\d]+)?$/)&&(m=0),f&&x){var o=s.optimal;if((f.match(/&\d+/)||x.match(/&\d+/))&&(o=!0),o){var r=function(s){for(var f=s.from,x=s.to,d=s.sex,m=s.from.split(","),b=s.to.split(","),o=0;o+l?m[o]=m[o].replace(/^[xol]b|^s/,"lb").replace(/^[xol]s|^d/,"ls"):+e<+l&&(m[o]=m[o].replace(/^[xol]b|^s/,"ob").replace(/^[xol]s|^d/,"os")),f=m.slice(o).join(","),x=b.slice(o+1).join(","),d=b[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;else if(s.optimal&&(r=m[o].match(/([xol])[bs]/),h=b[o].match(/([xol])[bs]/),e=r?r[1]:"",l=h?h[1]:"","x"==e||"x"==l)){f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0;continue}}break}f=m.slice(o+1).join(","),x=b.slice(o+1).join(","),d=m[o].match(/^([fhs1](&[ol\d]+)?|[olx]b)(&[ol\d]+)?/)?1:0}return{from:f,to:x,sex:d}}({from:f,to:x,sex:d,optimal:s.optimal});f=r.from,x=r.to,d=r.sex}}(x?N(x,d):[""]).forEach((function(s){var x=(s?","+s:"")+(f?","+f:"");h.push({selector:x,sex:m})}))}))})),h}function L(s){var f=[],x={};return function s(d){var m="";if(!x[d]){x[d]=!0;do{m=d;var b,r=F(o);try{for(r.s();!(b=r.n()).done;){var h=b.value;if((d=d.replace(h.exp,h.str)).includes("#"))return d.split("#").forEach(s),!1}}catch(s){r.e(s)}finally{r.f()}}while(m!=d);if(d.match(/,[mwd0](&[ol\d+])?,w|,[hfs1](&[ol\d]+)?,h/))return!1;f.push(d)}}(s),f}function P(s,f){if(s.match(/^,/)||(s=","+s),f<0)s.match(/^,[w1]/)?f=1:s.match(/^,[h0]/)&&(f=0);else{if(1==f&&s.match(/^,[h0]/))return[];if(0==f&&s.match(/^,[w1]/))return[]}if(f>-1&&!s.includes(",1")&&!s.includes(",0")&&(s=","+f+s),s.match(/,[mwd0](&[ol\d]+)?,w|,[hfs1](&[ol\d]+)?,h/))return[];var x=L(s).map((function(s){return s.replace(/,[01]/,"").substr(1)}));return I(x)}var Q=function(s){"string"==typeof s&&(s=function(s){var f,x=m(d);try{for(x.s();!(f=x.n()).done;){var b=f.value,o=s.match(b.exp);if(o)return b.opt(o)}}catch(s){x.e(s)}finally{x.f()}return{}}(s));var f=Object.assign({text:"",target:"",sex:-1,type:"default",reverse:!1,mode:"default",optimal:!1},s);!function(s){if(A=Object.assign({},j),s&&O[s])for(var f in O[s])A[f]=[].concat(O[s][f],j[f]||[])}(f.mode);var b=J(f.text),o=J(f.target);o.length||(o=[""]);var r=[];return b.forEach((function(s){o.forEach((function(x){K({from:s,to:x,sex:f.sex,optimal:f.optimal}).forEach((function(s){(s?P(s.selector,s.sex):[]).forEach((function(x){var d=[x],m=s.sex;f.reverse&&(d=N(x,m),m=x.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)?1:0),"chain"==f.type?d.forEach((function(f){var x=U(f,s.sex);x&&r.push(x)})):"pair"==f.type?(d=N(x,s.sex)).forEach((function(s){var f=function(s,f){var x=[],d=[],m=[];s=s.replace(/&\d+/,""),f=f.replace(/&\d+/,"");var b=s.replace(/([ol])([bs])/,"x$2"),o=f.replace(/([ol])([bs])/,"x$2"),r=s.replace(/&[ol]/,""),h=f.replace(/&[ol]/,"");for(var e in t){var l=e.split("#");if(l.length>1){var w=P(l[0]),M=P(l[1]),n=w.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")})),a=M.map((function(s){return s.replace(/&[ol\d]+/,"").replace(/([ol])([bs])/,"x$2")}));(w.includes(s)&&M.includes(f)||w.includes(f)&&M.includes(s))&&x.push(t[e][0]),(n.includes(b)&&a.includes(o)||n.includes(o)&&a.includes(b))&&d.push(t[e][0]),(n.includes(r)&&a.includes(h)||n.includes(h)&&a.includes(r))&&m.push(t[e][0])}}return x.length||(x=d),x.length||(x=m),x}(x,s);r=r.concat(f)})):d.forEach((function(s){var f=T(s);f.length||(f=T(m+","+s)),r=r.concat(f)}))}))}))}))})),x(new Set(r))};Q.data=A,Q.dataCount=Object.keys(A).length,Q.setMode=function(s,f){O[s]=Object.assign(O[s]||{},f)};export{Q as default}; diff --git a/package.json b/package.json index 3335b5ef..06e4f566 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "relationship.js", - "version": "1.2.4", + "version": "1.2.5", "description": "Chinese kinship library", "author": "HaoLe Zheng", "license": "MIT", @@ -71,4 +71,4 @@ "directories": { "test": "test" } -} \ No newline at end of file +} diff --git a/src/module/data/branch.js b/src/module/data/branch.js index ea4a0e7f..57c00750 100644 --- a/src/module/data/branch.js +++ b/src/module/data/branch.js @@ -16,85 +16,47 @@ export default { '{G2},s,s,s':['男','子'], '{G2},s,s,d':['女'], // 高祖以上 - 'f,f,f,f,f,f,f,f,{G1M}':['鼻祖父'], - 'f,f,f,f,f,f,f,f,{G1M},w':['鼻祖母'], - 'f,f,f,f,f,f,f,f,{G1W}':['鼻祖母'], - 'f,f,f,f,f,f,f,f,{G1W},h':['鼻祖父'], - 'f,f,f,f,f,f,f,{G1M}':['远祖父'], - 'f,f,f,f,f,f,f,{G1M},w':['远祖母'], - 'f,f,f,f,f,f,f,{G1W}':['远祖母'], - 'f,f,f,f,f,f,f,{G1W},h':['远祖父'], - 'f,f,f,f,f,f,{G1M}':['太祖父'], - 'f,f,f,f,f,f,{G1M},w':['太祖母'], - 'f,f,f,f,f,f,{G1W}':['姑太祖母'], - 'f,f,f,f,f,f,{G1W},h':['姑太祖父'], - 'f,f,f,f,f,{G1M}':['烈祖父'], - 'f,f,f,f,f,{G1M},w':['烈祖母'], - 'f,f,f,f,f,{G1W}':['烈祖母'], - 'f,f,f,f,f,{G1W},h':['烈祖父'], - 'f,f,f,f,{G1M}':['天祖父'], - 'f,f,f,f,{G1M},w':['天祖母'], - 'f,f,f,f,{G1W}':['天祖母'], - 'f,f,f,f,{G1W},h':['天祖父'], + 'f,f,f,f,f,f,f,f,[{G1M}|{G1W},h]':['鼻祖父'], + 'f,f,f,f,f,f,f,f,[{G1M},w|{G1W}]':['鼻祖母'], + 'f,f,f,f,f,f,f,[{G1M}|{G1W},h]':['远祖父'], + 'f,f,f,f,f,f,f,[{G1M},w|{G1W}]':['远祖母'], + 'f,f,f,f,f,f,[{G1M}|{G1W},h]':['太祖父'], + 'f,f,f,f,f,f,[{G1M},w|{G1W}]':['太祖母'], + 'f,f,f,f,f,[{G1M}|{G1W},h]':['烈祖父'], + 'f,f,f,f,f,[{G1M},w|{G1W}]':['烈祖母'], + 'f,f,f,f,[{G1M}|{G1W},h]':['天祖父'], + 'f,f,f,f,[{G1M},w|{G1W}]':['天祖母'], // 高祖辈 - 'f,f,f,{G1M}':['高祖父','外曾外曾外毑父'], - 'f,f,f,{G1M},w':['高祖母','外曾外曾外毑母'], - 'f,f,f,{G1W}':['高祖母','外曾外曾外毑母'], - 'f,f,f,{G1W},h':['高祖父','外曾外曾外毑父'], - 'f,f,m,{G1M}':['高外祖父','外曾外曾毑父'], - 'f,f,m,{G1M},w':['高外祖母','外曾外曾毑母'], - 'f,f,m,{G1W}':['高外祖母','外曾外曾毑母'], - 'f,f,m,{G1W},h':['高外祖父','外曾外曾毑父'], - 'f,m,f,{G1M}':['曾外曾祖父','外高外毑父'], - 'f,m,f,{G1M},w':['曾外曾祖母','外高外毑母'], - 'f,m,f,{G1W}':['曾外曾祖母','外高外毑母'], - 'f,m,f,{G1W},h':['曾外曾祖父','外高外毑父'], - 'f,m,m,{G1M}':['曾外曾外祖父','外高毑父'], - 'f,m,m,{G1M},w':['曾外曾外祖母','外高毑母'], - 'f,m,m,{G1W}':['曾外曾外祖母','外高毑母'], - 'f,m,m,{G1W},h':['曾外曾外祖父','外高毑父'], - 'm,f,f,{G1M}':['外高祖父','曾外曾外毑父'], - 'm,f,f,{G1M},w':['外高祖母','曾外曾外毑母'], - 'm,f,f,{G1W}':['外高祖母','曾外曾外毑母'], - 'm,f,f,{G1W},h':['外高祖父','曾外曾外毑父'], - 'm,f,m,{G1M}':['外高外祖父','曾外曾祖毑父'], - 'm,f,m,{G1M},w':['外高外祖母','曾外曾祖毑母'], - 'm,f,m,{G1W}':['外高外祖母','曾外曾祖毑母'], - 'm,f,m,{G1W},h':['外高外祖父','曾外曾祖毑父'], - 'm,m,f,{G1M}':['外曾外曾祖父','高外毑父'], - 'm,m,f,{G1M},w':['外曾外曾祖母','高外毑母'], - 'm,m,f,{G1W}':['外曾外曾祖母','高外毑母'], - 'm,m,f,{G1W},h':['外曾外曾祖父','高外毑父'], - 'm,m,m,{G1M}':['外曾外曾外祖父','高毑父'], - 'm,m,m,{G1M},w':['外曾外曾外祖母','高毑母'], - 'm,m,m,{G1W}':['外曾外曾外祖母','高毑母'], - 'm,m,m,{G1W},h':['外曾外曾外祖父','高毑父'], + 'f,f,f,[{G1M}|{G1W},h]':['高祖父','外曾外曾外毑父'], + 'f,f,f,[{G1M},w|{G1W}]':['高祖母','外曾外曾外毑母'], + 'f,f,m,[{G1M}|{G1W},h]':['高外祖父','外曾外曾毑父'], + 'f,f,m,[{G1M},w|{G1W}]':['高外祖母','外曾外曾毑母'], + 'f,m,f,[{G1M}|{G1W},h]':['曾外曾祖父','外高外毑父'], + 'f,m,f,[{G1M},w|{G1W}]':['曾外曾祖母','外高外毑母'], + 'f,m,m,[{G1M}|{G1W},h]':['曾外曾外祖父','外高毑父'], + 'f,m,m,[{G1M},w|{G1W}]':['曾外曾外祖母','外高毑母'], + 'm,f,f,[{G1M}|{G1W},h]':['外高祖父','曾外曾外毑父'], + 'm,f,f,[{G1M},w|{G1W}]':['外高祖母','曾外曾外毑母'], + 'm,f,m,[{G1M}|{G1W},h]':['外高外祖父','曾外曾祖毑父'], + 'm,f,m,[{G1M},w|{G1W}]':['外高外祖母','曾外曾祖毑母'], + 'm,m,f,[{G1M}|{G1W},h]':['外曾外曾祖父','高外毑父'], + 'm,m,f,[{G1M},w|{G1W}]':['外曾外曾祖母','高外毑母'], + 'm,m,m,[{G1M}|{G1W},h]':['外曾外曾外祖父','高毑父'], + 'm,m,m,[{G1M},w|{G1W}]':['外曾外曾外祖母','高毑母'], // 曾祖辈 - 'f,f,{G1M}':['?曾祖父','曾?祖父','?太公','太?公','?公太','太?爷','?太爷','?太爷爷','太?爷爷'], - 'f,f,{G1M},w':['?曾祖母','曾?祖母','?太婆','太?婆','?婆太','太?奶','?太奶','?太奶奶','太?奶奶'], - 'f,f,{G1W}':['?曾祖母','曾?祖母','?太婆','太?婆','?婆太','太?奶','?太奶','?太奶奶','太?奶奶'], - 'f,f,{G1W},h':['?曾祖父','曾?祖父','?太公','太?公','?公太','太?爷','?太爷','?太爷爷','太?爷爷'], - 'f,m,{G1M}':['?曾外祖父','曾外?祖父','?太外公','太外?公','太外?爷','?太外爷','?太外爷爷','太外?爷爷'], - 'f,m,{G1M},w':['?曾外祖母','曾外?祖母','?太外婆','太外?婆','太外?奶','?太外奶','?太外奶奶','太外?奶奶'], - 'f,m,{G1W}':['?曾外祖母','曾外?祖母','?太外婆','太外?婆','太外?奶','?太外奶','?太外奶奶','太外?奶奶'], - 'f,m,{G1W},h':['?曾外祖父','曾外?祖父','?太外公','太外?公','太外?爷','?太外爷','?太外爷爷','太外?爷爷'], - 'm,f,{G1M}':['?外曾祖父','外曾?祖父','?外太公','外太?公','外太?爷','?外太爷','?外太爷爷','外太?爷爷'], - 'm,f,{G1M},w':['?外曾祖母','外曾?祖母','?外太婆','外太?婆','外太?奶','?外太奶','?外太奶奶','外太?奶奶'], - 'm,f,{G1W}':['?外曾祖母','外曾?祖母','?外太婆','外太?婆','外太?奶','?外太奶','?外太奶奶','外太?奶奶'], - 'm,f,{G1W},h':['?外曾祖父','外曾?祖父','?外太公','外太?公','外太?爷','?外太爷','?外太爷爷','外太?爷爷'], - 'm,m,{G1M}':['?外曾外祖父','外曾外?祖父','?外太外公','外太外?公','外太外?爷','?外太外爷','?外太外爷爷','外太外?爷爷'], - 'm,m,{G1M},w':['?外曾外祖母','外曾外?祖母','?外太外婆','外太外?婆','外太外?奶','?外太外奶','?外太外奶奶','外太外?奶奶'], - 'm,m,{G1W}':['?外曾外祖母','外曾外?祖母','?外太外婆','外太外?婆','外太外?奶','?外太外奶','?外太外奶奶','外太外?奶奶'], - 'm,m,{G1W},h':['?外曾外祖父','外曾外?祖父','?外太外公','外太外?公','外太外?爷','?外太外爷','?外太外爷爷','外太?外爷爷'], + 'f,f,[{G1M}|{G1W},h]':['?曾祖父','曾?祖父','?太公','太?公','?公太','太?爷','?太爷','?太爷爷','太?爷爷'], + 'f,f,[{G1M},w|{G1W}]':['?曾祖母','曾?祖母','?太婆','太?婆','?婆太','太?奶','?太奶','?太奶奶','太?奶奶'], + 'f,m,[{G1M}|{G1W},h]':['?曾外祖父','曾外?祖父','?太外公','太外?公','太外?爷','?太外爷','?太外爷爷','太外?爷爷'], + 'f,m,[{G1M},w|{G1W}]':['?曾外祖母','曾外?祖母','?太外婆','太外?婆','太外?奶','?太外奶','?太外奶奶','太外?奶奶'], + 'm,f,[{G1M}|{G1W},h]':['?外曾祖父','外曾?祖父','?外太公','外太?公','外太?爷','?外太爷','?外太爷爷','外太?爷爷'], + 'm,f,[{G1M},w|{G1W}]':['?外曾祖母','外曾?祖母','?外太婆','外太?婆','外太?奶','?外太奶','?外太奶奶','外太?奶奶'], + 'm,m,[{G1M}|{G1W},h]':['?外曾外祖父','外曾外?祖父','?外太外公','外太外?公','外太外?爷','?外太外爷','?外太外爷爷','外太外?爷爷'], + 'm,m,[{G1M},w|{G1W}]':['?外曾外祖母','外曾外?祖母','?外太外婆','外太外?婆','外太外?奶','?外太外奶','?外太外奶奶','外太外?奶奶'], // 祖辈 - 'f,{G1M}':['祖父','公','太?父','奶爷','爷爷','爷'], - 'f,{G1M},w':['祖母','婆','太?母','奶奶','奶'], - 'f,{G1W}':['祖母','婆','太?母','奶奶','奶'], - 'f,{G1W},h':['祖父','公','太?父','奶爷','爷爷','爷'], - 'm,{G1M}':['外祖父','外公','外爷','外?公','外?祖父','外太?父','太外?父','姥爷','姥公','毑公','毑爷','毑父','嘎公'], - 'm,{G1M},w':['外祖母','外婆','外奶','外?婆','外?祖母','外太?母','太外?母','姥姥','姥娘','姥婆','毑婆','毑毑','毑母','嘎嘎','嫏嫏','嫏娘','姥'], - 'm,{G1W}':['外祖母','外婆','外奶','外?婆','外?祖母','外太?母','太外?母','姥姥','姥娘','姥婆','毑婆','毑毑','毑母','嘎嘎','嫏嫏','嫏娘','姥'], - 'm,{G1W},h':['外祖父','外公','外爷','外?公','外?祖父','外太?父','太外?父','姥爷','姥公','毑公','毑爷','毑父','嘎公'], + 'f,[{G1M}|{G1W},h]':['祖父','公','太?父','奶爷','爷爷','爷'], + 'f,[{G1M},w|{G1W}]':['祖母','婆','太?母','奶奶','奶'], + 'm,[{G1M}|{G1W},h]':['外祖父','外公','外爷','外?公','外?祖父','外太?父','太外?父','姥爷','姥公','毑公','毑爷','毑父','嘎公'], + 'm,[{G1M},w|{G1W}]':['外祖母','外婆','外奶','外?婆','外?祖母','外太?母','太外?母','姥姥','姥娘','姥婆','毑婆','毑毑','毑母','嘎嘎','嫏嫏','嫏娘','姥'], 'f,f,{G1},s&o':['伯祖父','伯爷爷'], 'f,f,{G1},s&o,w':['伯祖母','伯奶奶'], 'f,f,{G1},s&l':['叔祖父','叔爷爷'], @@ -116,10 +78,8 @@ export default { 'm,m,{G1},d':['姨外祖母','姨外公','姨姥爷'], 'm,m,{G1},d,h':['姨外祖父','姨外婆','姨姥姥'], // 父辈 - '{G1M}':['父'], - '{G1M},w':['母'], - '{G1W}':['母'], - '{G1W},h':['父'], + '{G1M}#{G1W},h':['父'], + '{G1M},w#{G1W}':['母'], 'f,{G1},s&o':['伯父','伯伯','伯','大爷'], 'f,{G1},s&o,w':['伯母','大娘'], 'f,{G1},s&l':['叔父','叔爸','叔叔','叔'], @@ -176,18 +136,12 @@ export default { '{G1},d,d,d':['甥外孙女','外孙女'], '{G1},d,d,d,h':['甥外孙婿'], // 夫族 - 'h,f,{G1M}':['祖公父','祖公','祖翁','奶公'], - 'h,f,{G1M},w':['祖婆母','祖婆','祖姆','奶婆'], - 'h,f,{G1W}':['祖婆母','祖婆','祖姆','奶婆'], - 'h,f,{G1W},h':['祖公父','祖公','祖翁','奶公'], - 'h,m,{G1M}':['外祖公父','外祖公','外祖翁','姥公'], - 'h,m,{G1M},w':['外祖婆母','外祖婆','外祖姆','姥婆'], - 'h,m,{G1W}':['外祖婆母','外祖婆','外祖姆','姥婆'], - 'h,m,{G1W},h':['外祖公父','外祖公','外祖翁','姥公'], - 'h,{G1M}':['公父','公公'], - 'h,{G1M},w':['婆母','婆婆'], - 'h,{G1W}':['婆母','婆婆'], - 'h,{G1W},h':['公父','公公'], + 'h,f,[{G1M}|{G1W},h]':['祖公父','祖公','祖翁','奶公'], + 'h,f,[{G1M},w|{G1W}]':['祖婆母','祖婆','祖姆','奶婆'], + 'h,m,[{G1M}|{G1W},h]':['外祖公父','外祖公','外祖翁','姥公'], + 'h,m,[{G1M},w|{G1W}]':['外祖婆母','外祖婆','外祖姆','姥婆'], + 'h,[{G1M}|{G1W},h]':['公父','公公'], + 'h,[{G1M},w|{G1W}]':['婆母','婆婆'], 'h,{G1},s&o':['大伯子','大伯兄'], 'h,{G1},s&o,w':['大婶子','大伯嫂'], 'h,{G1},s&l':['小叔子','小叔弟'], @@ -201,18 +155,12 @@ export default { 'h,{G1},d':['姑子'], 'h,{G1},d,h':['姑夫'], // 妻族 - 'w,f,{G1M}':['祖岳父','太?岳','祖丈人','爷丈人','奶爷丈人'], - 'w,f,{G1M},w':['祖岳母','太?岳母','祖丈母','祖丈母娘','奶丈母娘','奶丈母'], - 'w,f,{G1W}':['祖岳母','太?岳母','祖丈母','祖丈母娘','奶丈母娘','奶丈母'], - 'w,f,{G1W},h':['祖岳父','太?岳父','祖丈人','爷丈人','奶爷丈人'], - 'w,m,{G1M}':['外祖岳父','外太?岳父','太外?岳父','外祖丈人','姥爷丈人'], - 'w,m,{G1M},w':['外祖岳母','外太?岳母','太外?岳母','外祖丈母','外祖丈母娘','姥丈母娘','姥丈母'], - 'w,m,{G1W}':['外祖岳母','外太?岳母','太外?岳母','外祖丈母','外祖丈母娘','姥丈母娘','姥丈母'], - 'w,m,{G1W},h':['外祖岳父','外太?岳父','太外?岳父','外祖丈人','外爷丈人','姥爷丈人'], - 'w,{G1M}':['岳父','丈人','丈人爹'], - 'w,{G1M},w':['岳母','丈母','丈母娘'], - 'w,{G1W}':['岳母','丈母','丈母娘'], - 'w,{G1W},h':['岳父','丈人','丈人爹'], + 'w,f,[{G1M}|{G1W},h]':['祖岳父','太?岳','祖丈人','爷丈人','奶爷丈人'], + 'w,f,[{G1M},w|{G1W}]':['祖岳母','太?岳母','祖丈母','祖丈母娘','奶丈母娘','奶丈母'], + 'w,m,[{G1M}|{G1W},h]':['外祖岳父','外太?岳父','太外?岳父','外祖丈人','姥爷丈人'], + 'w,m,[{G1M},w|{G1W}]':['外祖岳母','外太?岳母','太外?岳母','外祖丈母','外祖丈母娘','姥丈母娘','姥丈母'], + 'w,[{G1M}|{G1W},h]':['岳父','丈人','丈人爹'], + 'w,[{G1M},w|{G1W}]':['岳母','丈母','丈母娘'], 'w,{G1},s&o':['大舅子','大舅兄','舅兄'], 'w,{G1},s&o,w':['大舅妇','大舅姆','大舅兄妇','舅兄妇','舅姐','大舅姐','大妗子','大妗儿'], 'w,{G1},s&l':['小舅子','小舅弟','舅弟'], @@ -646,15 +594,11 @@ export default { '{M-1},xs,d':['外孙女'], '{M-1},xs,d,h':['外孙婿'], '{M-2},f':['男'], - '{M-2},f,f&o':['兄'], - '{M-2},f,f&l':['弟'], - '{M-2},f,m&o':['姊'], - '{M-2},f,m&l':['妹'], '{M-2},m':['女'], - '{M-2},m,f&o':['兄'], - '{M-2},m,f&l':['弟'], - '{M-2},m,m&o':['姊'], - '{M-2},m,m&l':['妹'], + '{M-2},[f|m],f&o':['兄'], + '{M-2},[f|m],f&l':['弟'], + '{M-2},[f|m],m&o':['姊'], + '{M-2},[f|m],m&l':['妹'], '{M-2},xb':['孙男'], '{M-2},xb,w':['孙妇'], '{M-2},xs':['孙女'], diff --git a/src/module/map.js b/src/module/map.js index 4aa4d3dd..0a3b6d4e 100644 --- a/src/module/map.js +++ b/src/module/map.js @@ -9,11 +9,11 @@ import _multipie from './data/multiple.js'; import {expandSelector} from './selector.js'; let _map = Object.assign({},_multipie); -let getMap = function(prefixMap,branch){ +let getMap = function(prefixMap,branchMap){ let map = {}; - for(let key in branch){ + for(let key in branchMap){ let tag = key.match(/\{.+?\}/)[0]; - let nameList = branch[key]; + let nameList = branchMap[key]; for(let k in prefixMap[tag]){ let prefixList = prefixMap[tag][k]; let newKey = key.replace(tag,k); @@ -38,21 +38,25 @@ let getMap = function(prefixMap,branch){ } return map; }; + // 分支前缀处理 let prefixMap = {}; for(let key in _prefix){ prefixMap[key] = {}; for(let selector in _prefix[key]){ - if(selector.indexOf(']')==-1){ - prefixMap[key][selector] = _prefix[key][selector]; - }else{ - expandSelector(selector).forEach(function(s){ - prefixMap[key][s] = _prefix[key][selector]; - }); - } + expandSelector(selector).forEach(function(s){ + prefixMap[key][s] = _prefix[key][selector]; + }); } } -_map = Object.assign({},_map,getMap(prefixMap,_branch)); +// 分支节点处理 +let branchMap = {}; +for(let selector in _branch){ + expandSelector(selector).forEach(function(s){ + branchMap[s] = _branch[selector]; + }); +} +_map = Object.assign({},_map,getMap(prefixMap,branchMap)); // 主要关系 for(let key in _main){ _map[key] = [].concat(_main[key],_map[key]||[]);