updated 代码优化

This commit is contained in:
zhenghaole
2024-04-30 11:50:52 +08:00
parent 27d424aace
commit 1148b0bea2
7 changed files with 16 additions and 16 deletions

View File

@@ -47,8 +47,8 @@ export default {
'm,m,f':['外曾外祖父','外曾外祖','曾毑父','外太外公','外太外爷','外太外翁','外太外爷爷','外太姥爷'],
'm,m,m':['外曾外祖母','曾毑母','外太外婆','外太外奶','外太外嬷','外太外姆','外太外奶奶','外太姥姥'],
// 祖父辈
'f,f':['爷爷','祖父','奶爷','奶爹','阿爷','阿公','亚爷','亚公','依爷','嗲嗲','大父','王父','祖君','爷','爷儿','爷老','爷老子','爷老倌','二世祖'],
'f,m':['奶奶','祖母','阿奶','奶娘','阿姆','阿婆','亚嬷','亚婆','依奶','阿嬷','大母','王母','重慈','奶','嫲嫲','婻婻','娭毑','嗯奶','娘姆','媪婆','亲婆'],
'f,f':['爷爷','祖父','奶爷','奶爹','阿爷','阿公','亚爷','亚公','依爷','嗲嗲','大父','祖君','爷','爷儿','爷老','爷老子','爷老倌','二世祖'],
'f,m':['奶奶','祖母','阿奶','奶娘','阿姆','阿婆','亚嬷','亚婆','依奶','阿嬷','大母','重慈','奶','嫲嫲','婻婻','娭毑','嗯奶','娘姆','媪婆','亲婆'],
'm,f':['外公','外祖父','姥爷','阿公','外爷','客公','毑父','毑公','姥公','舅家爷','嘎公','嘎爹',,'嘎嘎爹','嘎爷爷','尕公','毑爹','毑爷','外大父','姥爹','魏公','魏爷'],
'm,m':['外婆','外祖母','姥姥','阿婆','外奶','客婆','毑母','毑婆','姥婆','舅家婆','嘎嘎','嘎婆','嘎嘎婆','嘎奶奶','尕婆','毑娘','毑毑','外大母','姥娘','魏婆','魏奶','阿嬷','外嬷','嫲嫲','好婆','嫏嫏','嫏娘'],
'f,f,ob':['伯公','伯祖','伯翁','大爷爷','大嗲','大爷','大公','大阿爷'],

View File

@@ -68,14 +68,14 @@ for(let key in _main){
_map['o']=['passer-by.com','\u4f5c\u8005'];
// 配偶关系
const branch = {
const mateMap = {
'w':['妻','内','岳','岳家','丈人'],
'h':['夫','外','公','婆家','婆婆'],
};
let nameSet = new Set(Object.values(_map).flat());
for(let key in _map){
if(key.match(/^[fm]/)||key.match(/^[olx][bs]$|^[olx][bs],[^mf]/)){ // 只对长辈或者兄弟辈匹配
for(let k in branch){
for(let k in mateMap){
let newKey = k+','+key;
if(key.match(/[fm]/)){
let newKey_x = newKey.replace(/,[ol]([sb])(,[wh])?$/,',x$1$2').replace(/(,[sd])&[ol](,[wh])?$/,'$1$2');
@@ -86,12 +86,12 @@ for(let key in _map){
if(!_map[newKey]){
_map[newKey] = [];
}
let prefixList = branch[k];
let prefixList = mateMap[k];
let nameList = _map[key];
prefixList.forEach(function(prefix){
nameList.forEach(function(name){
let newName = prefix+name;
if(!nameSet.has(newName)){ // 配偶组合的称呼不得原有称呼冲突(如:妻舅!=妻子的舅舅;外舅公!=老公的舅公)
if(!nameSet.has(newName)){ // 配偶组合的称呼不得原有称呼冲突(如:妻舅!=妻子的舅舅;外舅公!=老公的舅公)
_map[newKey].push(newName);
}
});

View File

@@ -21,7 +21,7 @@ export default [
opt:match=>({
text:match[1],
target:match[2],
type:match[1].indexOf('的')>-1?'default':'chain'
type:match[1].includes('的')?'default':'chain'
})
},
{
@@ -70,7 +70,7 @@ export default [
exp:/^(\S+?)是(谁|什么|什么亲戚|啥亲戚|什么人|什么辈分|啥辈分)?$/,
opt:match=>({
text:match[1],
type:match[1].indexOf('的')>-1?'default':'chain'
type:match[1].includes('的')?'default':'chain'
})
},
];