├── favicon.ico
├── vercel.json
├── .gitignore
├── vue
├── favicon.ico
├── icons
│ ├── icon-48x48.png
│ ├── icon-72x72.png
│ ├── icon-96x96.png
│ ├── icon-144x144.png
│ ├── icon-192x192.png
│ └── icon-512x512.png
├── assets
│ └── favicon-CcRSb4Ef.ico
├── registerSW.js
├── manifest.webmanifest
├── index.html
├── sw.js
└── workbox-ffa4df14.js
├── static
├── image
│ ├── app.png
│ ├── scan.png
│ ├── qrcode.png
│ ├── icon
│ │ ├── miui.png
│ │ ├── qinqi.png
│ │ ├── quanneng.png
│ │ └── yuwendaren.png
│ ├── public
│ │ ├── logo.png
│ │ ├── qrcode.jpg
│ │ ├── icon-gotop.png
│ │ ├── icon-wechat.png
│ │ └── bg.svg
│ ├── qrcode-alipay.jpg
│ ├── qrcode-wechat.jpg
│ ├── summary-bg.svg
│ └── draw
│ │ ├── 4.svg
│ │ ├── 2.svg
│ │ ├── 1.svg
│ │ └── 3.svg
├── script
│ └── index.js
└── style
│ └── index.css
├── babel.config.js
├── src
├── relationship-mode.js
├── module
│ ├── data
│ │ ├── sort.js
│ │ ├── input.js
│ │ ├── pair.js
│ │ ├── multiple.js
│ │ ├── prefix.js
│ │ ├── main.js
│ │ └── branch.js
│ ├── options.js
│ ├── rule
│ │ ├── similar.js
│ │ ├── replace.js
│ │ ├── expression.js
│ │ └── filter.js
│ ├── mode.js
│ ├── cache.js
│ ├── unit.js
│ ├── map.js
│ ├── id.js
│ └── selector.js
├── locale
│ ├── north.js
│ └── guangdong.js
└── relationship.js
├── .github
└── workflows
│ └── test.yml
├── gulpfile.js
├── LICENSE
├── rollup.config.mjs
├── dist
├── relationship-mode.min.mjs
├── lang
│ ├── relationship-mode.zh-HK.min.mjs
│ └── relationship-mode.zh-HK.min.js
└── relationship-mode.min.js
├── package.json
├── test
└── index.js
└── readme.md
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/favicon.ico
--------------------------------------------------------------------------------
/vercel.json:
--------------------------------------------------------------------------------
1 | {
2 | "github": {
3 | "silent": true
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .settings
3 |
4 | node_modules/*
5 |
6 | /node_modules
7 |
--------------------------------------------------------------------------------
/vue/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/favicon.ico
--------------------------------------------------------------------------------
/static/image/app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/app.png
--------------------------------------------------------------------------------
/static/image/scan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/scan.png
--------------------------------------------------------------------------------
/static/image/qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/qrcode.png
--------------------------------------------------------------------------------
/vue/icons/icon-48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/icons/icon-48x48.png
--------------------------------------------------------------------------------
/vue/icons/icon-72x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/icons/icon-72x72.png
--------------------------------------------------------------------------------
/vue/icons/icon-96x96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/icons/icon-96x96.png
--------------------------------------------------------------------------------
/static/image/icon/miui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/icon/miui.png
--------------------------------------------------------------------------------
/static/image/icon/qinqi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/icon/qinqi.png
--------------------------------------------------------------------------------
/vue/icons/icon-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/icons/icon-144x144.png
--------------------------------------------------------------------------------
/vue/icons/icon-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/icons/icon-192x192.png
--------------------------------------------------------------------------------
/vue/icons/icon-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/icons/icon-512x512.png
--------------------------------------------------------------------------------
/static/image/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/public/logo.png
--------------------------------------------------------------------------------
/static/image/icon/quanneng.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/icon/quanneng.png
--------------------------------------------------------------------------------
/static/image/icon/yuwendaren.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/icon/yuwendaren.png
--------------------------------------------------------------------------------
/static/image/public/qrcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/public/qrcode.jpg
--------------------------------------------------------------------------------
/static/image/qrcode-alipay.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/qrcode-alipay.jpg
--------------------------------------------------------------------------------
/static/image/qrcode-wechat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/qrcode-wechat.jpg
--------------------------------------------------------------------------------
/vue/assets/favicon-CcRSb4Ef.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/vue/assets/favicon-CcRSb4Ef.ico
--------------------------------------------------------------------------------
/static/image/public/icon-gotop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/public/icon-gotop.png
--------------------------------------------------------------------------------
/static/image/public/icon-wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mumuy/relationship/HEAD/static/image/public/icon-wechat.png
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['@babel/preset-env'],
3 | plugins: [
4 | '@babel/plugin-transform-runtime'
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/src/relationship-mode.js:
--------------------------------------------------------------------------------
1 | import guangdong from './locale/guangdong.js';
2 | import north from './locale/north.js';
3 |
4 | export default {
5 | guangdong,
6 | north
7 | };
8 |
--------------------------------------------------------------------------------
/vue/registerSW.js:
--------------------------------------------------------------------------------
1 | if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('/relationship/vue/sw.js', { scope: '/relationship/vue/' })})}
--------------------------------------------------------------------------------
/static/image/summary-bg.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/module/data/sort.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 排序字段
3 | */
4 | export default {
5 | 'f,xb':['几爸爸','几爸','几爹'],
6 | 'f,xb,w':['几妈妈','几妈','几娘'],
7 | 'f,f,xb':['几爷爷','几大爷','几嗲','几爷','几公'],
8 | 'f,f,xb,w':['几奶奶','几大娘','几奶','几婆'],
9 | 'm,f,xb':['几外公','几姥爷','几外爷'],
10 | 'm,f,xb,w':['几外婆','几姥姥','几姥奶','几外奶','几姥'],
11 | };
--------------------------------------------------------------------------------
/src/module/options.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 通过表达式获取配置
3 | */
4 | import _expression from './rule/expression.js';
5 |
6 | export function getOptions(text){
7 | for(const item of _expression){
8 | const match = text.match(item['exp']);
9 | if(match){
10 | return item['opt'](match);
11 | }
12 | }
13 | return {};
14 | };
15 |
--------------------------------------------------------------------------------
/src/module/rule/similar.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 同义词替换 - 对称呼中的近义词进行替换
3 | */
4 | export default {
5 | '晜':'兄',
6 | '哥':'兄',
7 | '姐':'姊',
8 | '侄':'姪',
9 | '婿':'壻',
10 | '嬷':'嫲',
11 | '祖父':'王父',
12 | '祖母':'王母',
13 | '孙女婿':'孙婿',
14 | '甥女婿':'甥婿',
15 | '侄女婿':'侄婿',
16 | '孙媳妇':'孙妇',
17 | '甥媳妇':'甥妇',
18 | '侄媳妇':'侄妇',
19 | '弟媳妇':'弟妇',
20 | };
21 |
--------------------------------------------------------------------------------
/src/module/data/input.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 只作为输入关系链判断
3 | */
4 | export default {
5 | 'xb':['兄弟','亲兄弟','同胞兄弟'],
6 | 'xb,w':['兄弟媳妇','兄弟妇'],
7 | 'xs':['姐妹','亲姐妹','同胞姐妹'],
8 | 'xs,h':['姐妹夫','姊妹婿'],
9 | 'f,xb':['伯叔父'],
10 | 'f,xb,w':['伯叔母'],
11 | 'f,f,xb':['从祖祖父','从祖父'],
12 | 'f,f,xb,w':['从祖祖母','从祖母'],
13 | 'm,f,xb':['外从祖祖父'],
14 | 'm,f,xb,w':['外从祖祖母'],
15 | 'h,xb':['伯叔'],
16 | 'h,xb,w':['妯娌','娣姒','娣姒姊妹','婶子'],
17 | };
18 |
--------------------------------------------------------------------------------
/src/locale/north.js:
--------------------------------------------------------------------------------
1 | export default {
2 | 'name':'北方',
3 | 'data':{
4 | 'm,m':['姥姥'],
5 | 'm,m,xs':['姨姥姥'],
6 | 'm,m,xs,h':['姨姥爷'],
7 | 'm,m,xb':['舅姥爷'],
8 | 'm,m,xb,w':['舅姥姥'],
9 | 'm,f':['姥爷'],
10 | 'm,f,xs':['姑姥姥'],
11 | 'm,f,xs,h':['姑姥爷'],
12 | 'm,f,ob':['大姥爷'],
13 | 'm,f,ob,w':['大姥姥'],
14 | 'm,f,lb':['小姥爷'],
15 | 'm,f,lb,w':['小姥姥'],
16 | 'f,ob':['大爷'],
17 | 'f,ob,w':['大娘'],
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Project Build Test
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 | pull_request:
7 | branches: [ "master" ]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | strategy:
14 | matrix:
15 | node-version: [20.x, 22.x]
16 |
17 | steps:
18 | - uses: actions/checkout@v3
19 |
20 | - name: Use Node.js ${{ matrix.node-version }}
21 | uses: actions/setup-node@v3
22 | with:
23 | node-version: ${{ matrix.node-version }}
24 |
25 | - name: Build
26 | run: |
27 | npm install
28 | npm run build
29 |
--------------------------------------------------------------------------------
/src/module/mode.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 模式数据
3 | */
4 | import _map from './map.js';
5 |
6 | let _mode = {}; // 模式缓存
7 | let modeData = { ..._map }; // 最终数据
8 |
9 | // 设置模式数据
10 | export function setModeData(sign,data){
11 | _mode[sign] = { ...(_mode[sign] || {}), ...data };
12 | };
13 |
14 | // 获取模式数据
15 | export function getModeData(sign){
16 | modeData = { ..._map };
17 | if(sign&&_mode[sign]){
18 | for(const key in _mode[sign]){
19 | modeData[key] = [].concat(_mode[sign][key],_map[key]||[]);
20 | }
21 | }
22 | return modeData;
23 | };
24 |
25 | export {modeData};
--------------------------------------------------------------------------------
/src/module/cache.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 缓存数据
3 | */
4 | import _input from './data/input.js';
5 | import _sort from './data/sort.js';
6 | import {modeData} from './mode.js';
7 |
8 | function mergeValues(target, source) {
9 | Object.entries(source).forEach(([key, value]) => {
10 | target[key] = (target[key] || []).concat(value);
11 | });
12 | return target;
13 | }
14 | let _hash = mergeValues({...modeData }, _input);
15 | _hash = mergeValues(_hash, _sort);
16 |
17 | let cacheData = {};
18 | Object.entries(_hash).forEach(([key, names]) => {
19 | names.forEach((name) => {
20 | if (!cacheData[name]) {
21 | cacheData[name] = [];
22 | }
23 | cacheData[name].push(key);
24 | });
25 | });
26 |
27 | export {cacheData};
--------------------------------------------------------------------------------
/static/script/index.js:
--------------------------------------------------------------------------------
1 | // 特征选项卡
2 | (function(){
3 | let $mod_feature = document.querySelector('.mod-feature');
4 | let $nav = $mod_feature.querySelectorAll('.nav li');
5 | let $panels = $mod_feature.querySelectorAll('.panels .panel');
6 | let togglePanel = function(index = 0){
7 | $nav.forEach(function($li){
8 | $li.classList.remove('active');
9 | });
10 | $nav[index].classList.add('active');
11 | $panels.forEach(function($panel){
12 | $panel.classList.remove('active');
13 | });
14 | $panels[index].classList.add('active');
15 | };
16 | $nav.forEach(function($item,index){
17 | $item.addEventListener('click',function(){
18 | togglePanel(index);
19 | });
20 | });
21 | togglePanel(0);
22 | })();
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | const gulp = require('gulp');
2 | const rename = require("gulp-rename");
3 | const cht = require('gulp-cht');
4 | const replace = require('gulp-replace');
5 |
6 | gulp.task('localization', () => {
7 | // gulp.src('./index.html')
8 | // .pipe(cht())
9 | // .pipe(rename("zh-HK.html"))
10 | // .pipe(gulp.dest("./"));
11 |
12 | return gulp.src([
13 | 'dist/relationship.min.js',
14 | 'dist/relationship.min.mjs',
15 | 'dist/relationship-mode.min.js',
16 | 'dist/relationship-mode.min.mjs',
17 | ]).pipe(cht())
18 | .pipe(replace('嶽','岳'))
19 | .pipe(rename(function(path) {
20 | path.basename = path.basename.replace('.min','.zh-HK.min');
21 | }))
22 | .pipe(gulp.dest('dist/lang/'))
23 | });
24 |
25 | gulp.task('default', gulp.series(['localization']))
--------------------------------------------------------------------------------
/src/module/unit.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 数值转换
3 | */
4 |
5 | const textAttr = ['','一','二','三','四','五','六','七','八','九','十'];
6 |
7 | // 中文数字转阿拉伯数字
8 | export function zh2number(text){
9 | let num = 0;
10 | const map = {'大':1,'小':99};
11 | if(map[text]){
12 | num = map[text];
13 | }else{
14 | let [unit,dec=0] = text.replace(/^十/,'一十').split('十').map(word=> textAttr.indexOf(word)).reverse();
15 | num = dec*10+unit;
16 | }
17 | return num;
18 | };
19 |
20 | // 阿拉伯数字转中文数字
21 | export function number2zh(num){
22 | let text = '';
23 | const map = {1:'大',99:'小'};
24 | if(map[num]){
25 | text = map[num];
26 | }else{
27 | let dec = ~~(num/10);
28 | let unit = num%10;
29 | text = (dec?(textAttr[dec]+'十').replace('一十','十'):'')+textAttr[unit];
30 | }
31 | return text;
32 | };
33 |
--------------------------------------------------------------------------------
/vue/manifest.webmanifest:
--------------------------------------------------------------------------------
1 | {"name":"亲戚关系计算器","short_name":"亲戚关系","description":"通过关系查询亲戚程序,让你逢年过节走亲访友不再尴尬!","start_url":"/relationship/vue/","display":"standalone","background_color":"#ffffff","theme_color":"#e7763e","lang":"en","scope":"/relationship/vue/","orientation":"portrait","width":400,"height":800,"icons":[{"src":"icons/icon-48x48.png","sizes":"48x48","type":"image/png"},{"src":"icons/icon-72x72.png","sizes":"72x72","type":"image/png"},{"src":"icons/icon-96x96.png","sizes":"96x96","type":"image/png"},{"src":"icons/icon-144x144.png","sizes":"144x144","type":"image/png"},{"src":"icons/icon-192x192.png","sizes":"192x192","type":"image/png"},{"src":"icons/icon-512x512.png","sizes":"512x512","type":"image/png"},{"src":"icons/icon-192x192.png","sizes":"192x192","type":"image/png","purpose":"maskable"},{"src":"icons/icon-512x512.png","sizes":"512x512","type":"image/png","purpose":"maskable"}],"categories":["education","kids","lifestyle"]}
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Haole Zheng
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/module/data/pair.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 关系合称 - 两个人之间的关系合称
3 | */
4 | export default {
5 | 'f#s':['父子'],
6 | 'm#s':['母子'],
7 | 'f#d':['父女'],
8 | 'm#d':['母女'],
9 | 'h#w':['夫妻'],
10 | 'ob#lb':['兄弟'],
11 | 'ob#ls':['兄妹'],
12 | 'os#ls':['姐妹'],
13 | 'os#lb':['姐弟'],
14 | 'w,f#d,h':['翁婿'],
15 | 'w,m#d,h':['母婿'],
16 | 'h,f#s,w':['翁媳'],
17 | 'h,m#s,w':['婆媳'],
18 | 'f,[f|m]#s,[s|d]':['祖孙'],
19 | 'm,f#d,[s|d]':['公孙'],
20 | 'm,m#d,[s|d]':['婆孙'],
21 | 'f,[ob|ob,w]#[lb|h,lb],[s|d]':['伯侄'],
22 | 'f,lb#ob,[s|d]':['叔侄'],
23 | 'f,lb,w#h,ob,[s|d]':['婶侄'],
24 | 'f,[xs|xs,h]#[xb|w,xb],[s|d]':['姑侄'],
25 | 'm,[xb|xb,w]#[xs|h,xs],[s|d]':['舅甥'],
26 | 'm,[xs|xs,h]#[xs|w,xs],[s|d]':['姨甥'],
27 | 'f,xb,s&o#f,xb,s&l':['堂兄弟'],
28 | 'f,xb,s&o#f,xb,d&l':['堂兄妹'],
29 | 'f,xb,d&o#f,xb,s&l':['堂姐弟'],
30 | 'f,xb,d&o#f,xb,d&l':['堂姐妹'],
31 | 'f,xs,s&o#m,xb,s&l':['表兄弟'],
32 | 'm,xb,s&o#f,xs,s&l':['表兄弟'],
33 | 'f,xs,s&o#m,xb,d&l':['表兄妹'],
34 | 'm,xb,s&o#f,xs,d&l':['表兄妹'],
35 | 'f,xs,d&o#m,xb,d&l':['表姐妹'],
36 | 'm,xb,d&o#f,xs,d&l':['表姐妹'],
37 | 'f,xs,d&o#m,xb,s&l':['表姐弟'],
38 | 'm,xb,d&o#f,xs,s&l':['表姐弟'],
39 | 'm,xs,s&o#m,xs,s&l':['姨兄弟'],
40 | 'm,xs,s&o#m,xs,d&l':['姨兄妹'],
41 | 'm,xs,d&o#m,xs,s&l':['姨姐弟'],
42 | 'm,xs,d&o#m,xs,d&l':['姨姐妹'],
43 | 'h,ob,w#h,lb,w':['妯娌'],
44 | 'w,os,h#w,ls,h':['连襟'],
45 | 'w,os#ls,h':['襟姐弟'],
46 | 'w,ls#os,h':['襟兄妹'],
47 | 'xs,h#w,xb':['郎舅'],
48 | 'xs,h#w,xs':['郎姨'],
49 | 'lb,w#h,ob':['伯媳'],
50 | 'ob,w#h,lb':['叔嫂'],
51 | 'xb,w#h,xs':['姑嫂'],
52 | 'xs,h,xb#xb,w,xb':['姻兄弟'],
53 | 'd,h,[f|m]#s,w,[f|m]':['儿女亲家'],
54 | }
55 |
--------------------------------------------------------------------------------
/rollup.config.mjs:
--------------------------------------------------------------------------------
1 | import resolve from '@rollup/plugin-node-resolve'; // 使用node_modules包
2 | import terser from '@rollup/plugin-terser'; // 代码压缩
3 | import babel from '@rollup/plugin-babel'; // ECMAScript兼容
4 | import pkg from './package.json' with { type:'json' }; // 获取package信息
5 |
6 | // 版权信息
7 | const repository = pkg.repository.url.replace(/(.+)(:\/\/.+)\.git$/,'https$2');
8 | const now = new Date();
9 | const date = (new Date(now.getTime()-now.getTimezoneOffset()*60000)).toISOString().substr(0,10);
10 | const banner = `/*!
11 | * ${pkg.name} v${pkg.version}
12 | * ${pkg.description}
13 | * ${pkg.homepage}
14 | *
15 | * Copyright (c) 2016-present, ${pkg.author}
16 | *
17 | * Released under the ${pkg.license} License
18 | * ${repository}
19 | *
20 | * Created on: ${date}
21 | */`;
22 |
23 | const commonPlugins = [
24 | resolve(),
25 | terser(),
26 | babel({
27 | babelHelpers: 'runtime',
28 | exclude:'node_modules/**'
29 | })
30 | ];
31 |
32 | export default [{
33 | input: './src/relationship.js',
34 | output:[{
35 | file: pkg.main,
36 | format: 'umd',
37 | name: 'relationship',
38 | banner
39 | },{
40 | file: pkg.module,
41 | format: 'es',
42 | banner
43 | }],
44 | plugins: commonPlugins,
45 | watch: {
46 | exclude: 'node_modules/**'
47 | }
48 | },{
49 | input: './src/relationship-mode.js',
50 | output:[{
51 | file: './dist/relationship-mode.min.js',
52 | format: 'umd',
53 | name: 'relationshipMode'
54 | },{
55 | file: './dist/relationship-mode.min.mjs',
56 | format: 'es'
57 | }],
58 | plugins: commonPlugins,
59 | watch: {
60 | exclude: 'node_modules/**'
61 | }
62 | }];
63 |
--------------------------------------------------------------------------------
/vue/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 亲戚计算器手机版 亲戚称呼计算器APP
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/module/rule/replace.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 词义扩展 - 对称呼词义进行扩展
3 | */
4 | export default [
5 | {
6 | exp:/^从表/,
7 | arr:['从父姑表','从父舅表','从父姨表','从母姑表','从母舅表','从母叔表']
8 | },
9 | {
10 | exp:/^表表/,
11 | arr:['姑表叔表','姑表姑表','姑表舅表','姑表姨表','舅表叔表','舅表姑表','舅表舅表','舅表姨表']
12 | },
13 | {
14 | exp:/^([夫妻内外]?)表/,
15 | arr:['$1姑表','$1舅表']
16 | },
17 | {
18 | exp:/^([姑舅])表(?=[^伯叔])/,
19 | arr:['$1表伯','$1表叔']
20 | },
21 | {
22 | exp:/^姻/,
23 | arr:['姑姻','姨姻','姊妹姻','女姻']
24 | },
25 | {
26 | exp:/^眷/,
27 | arr:['叔眷','舅眷','兄弟眷','男眷']
28 | },
29 | {
30 | exp:/^亲家/,
31 | arr:['姊妹姻','兄弟眷']
32 | },
33 | {
34 | exp:/^([堂表姨]?)([曾高天烈太远鼻]?)(祖?)([伯叔姑舅姨])/,
35 | arr:['$1$4$2$3']
36 | },
37 | {
38 | exp:/^([曾高天烈太远鼻]?)祖?王姑/,
39 | arr:['姑$1祖母']
40 | },
41 | {
42 | exp:/^([曾玄元来晜仍云耳])([侄甥])/,
43 | arr:['$2$1']
44 | },
45 | {
46 | exp:/^外表([伯叔姑舅姨])/,
47 | arr:['姑表$1外','舅表$1外']
48 | },
49 | {
50 | exp:/([堂表姨]?)外甥/,
51 | arr:['$1甥']
52 | },
53 | {
54 | exp:/^([舅叔])([曾玄外]*)孙/,
55 | arr:['$1侄$2孙']
56 | },
57 | {
58 | exp:/^([姨姑])([曾玄外]*)孙/,
59 | arr:['$1甥$2孙']
60 | },
61 | {
62 | exp:/([孙甥侄])$/,
63 | arr:['$1男','$1女']
64 | },
65 | {
66 | exp:/([姑舅姨叔])([孙外]*)([男女])$/,
67 | arr:['$1表侄$2$3','$1表甥$2$3']
68 | },
69 | {
70 | exp:/(.+)父母$/,
71 | arr:['$1父','$1母']
72 | },
73 | {
74 | exp:/(.+)公婆$/,
75 | arr:['$1公','$1婆']
76 | },
77 | {
78 | exp:/祖$/,
79 | arr:['祖父']
80 | },
81 | {
82 | exp:/(新妇|媳)$/,
83 | arr:['媳妇']
84 | },
85 | {
86 | exp:/嫂$/,
87 | arr:['兄妇']
88 | },
89 | {
90 | exp:/女儿$/,
91 | arr:['女']
92 | },
93 | ];
94 |
--------------------------------------------------------------------------------
/src/module/rule/expression.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 自然语言表达 - 将【语言表达】转换成【参数调用】
3 | */
4 | export default [
5 | {
6 | exp:/^(\S+?)(应该|得)?(称呼|叫|喊)(\S+?)(什么|啥)??$/,
7 | opt:match=>({
8 | text:match[4],
9 | target:match[1]
10 | })
11 | },
12 | {
13 | exp:/^(\S+?)(应该|得)?(如何|怎么)(称呼|叫|喊)(\S+?)??$/,
14 | opt:match=>({
15 | text:match[5],
16 | target:match[1]
17 | })
18 | },
19 | {
20 | exp:/^(\S+?)是(\S+?)的(谁|什么|什么亲戚|啥亲戚|什么人)??$/,
21 | opt:match=>({
22 | text:match[1],
23 | target:match[2],
24 | type:match[1].includes('的')?'default':'chain'
25 | })
26 | },
27 | {
28 | exp:/^(\S+?)(应该|得)?管(\S+?)叫(什么|啥)??$/,
29 | opt:match=>({
30 | text:match[3],
31 | target:match[1]
32 | })
33 | },
34 | {
35 | exp:/^(\S+?)(和|与)(\S+?)(之间)?是(什么|啥)关系??$/,
36 | opt:match=>({
37 | text:match[1],
38 | target:match[3],
39 | type:'pair'
40 | })
41 | },
42 | {
43 | exp:/^(\S+?)对于(\S+?)是(什么|啥)关系??$/,
44 | opt:match=>({
45 | text:match[1],
46 | target:match[2],
47 | type:'chain'
48 | })
49 | },
50 | {
51 | exp:/^(\S+?)(指的)?是(什么|啥)(意思|关系|亲戚关系|辈分|人)??$/,
52 | opt:match=>({
53 | text:match[1],
54 | type:'chain'
55 | })
56 | },
57 | {
58 | exp:/^(\S+?)(应该|得)?(称呼|叫|喊)(什么|啥)??$/,
59 | opt:match=>({
60 | text:match[1]
61 | })
62 | },
63 | {
64 | exp:/^(\S+?)(应该|得)?(如何|怎么)(称呼|叫|喊)??$/,
65 | opt:match=>({
66 | text:match[1]
67 | })
68 | },
69 | {
70 | exp:/^(\S+?)是(谁|什么|什么亲戚|啥亲戚|什么人|什么辈分|啥辈分)??$/,
71 | opt:match=>({
72 | text:match[1],
73 | type:match[1].includes('的')?'default':'chain'
74 | })
75 | },
76 | ];
77 |
--------------------------------------------------------------------------------
/dist/relationship-mode.min.mjs:
--------------------------------------------------------------------------------
1 | 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)||!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: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(f(f(f(f(f(f(f(f(f(d,"0,m,xb,d,s",["姨姨甥"]),"1,m,xb,d,s",["姨外甥"]),"0,m,xb,d,d",["姨姨甥女"]),"1,m,xb,d,d",["姨外甥女"]),"ob",["大佬"]),"ob,w",["阿嫂"]),"lb",["细佬"]),"lb,w",["弟妇"]),"xb,s",["侄"]),"xb,d",["侄女"]),f(f(f(f(f(f(f(f(f(f(d,"os",["家姐"]),"os,h",["姐夫"]),"ls",["阿妹"]),"ls,h",["妹夫"]),"0,xs,s",["姨甥"]),"1,xs,s",["外甥"]),"0,xs,d",["姨甥女"]),"1,xs,d",["外甥女"]),"s",["仔"]),"s,w",["新妇"]),f(f(f(f(f(f(f(f(f(f(d,"s,s",["孙"]),"s,s,w",["孙新妇"]),"s,s,s",["息仔"]),"s,s,d",["息女"]),"s,d",["孙女"]),"s,d,h",["孙女婿"]),"s,d,s",["外息仔"]),"s,d,d",["外息女"]),"d",["女"]),"d,s",["外孙"]),f(f(f(f(f(f(f(d,"d,s,w",["外孙新妇"]),"d,s,s",["外息仔"]),"d,s,d",["外息女"]),"d,d",["外孙女"]),"d,d,h",["外孙女婿"]),"d,d,s",["外息仔"]),"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};
2 |
--------------------------------------------------------------------------------
/dist/lang/relationship-mode.zh-HK.min.mjs:
--------------------------------------------------------------------------------
1 | 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)||!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: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(f(f(f(f(f(f(f(f(f(d,"0,m,xb,d,s",["姨姨甥"]),"1,m,xb,d,s",["姨外甥"]),"0,m,xb,d,d",["姨姨甥女"]),"1,m,xb,d,d",["姨外甥女"]),"ob",["大佬"]),"ob,w",["阿嫂"]),"lb",["細佬"]),"lb,w",["弟婦"]),"xb,s",["侄"]),"xb,d",["侄女"]),f(f(f(f(f(f(f(f(f(f(d,"os",["家姐"]),"os,h",["姐夫"]),"ls",["阿妹"]),"ls,h",["妹夫"]),"0,xs,s",["姨甥"]),"1,xs,s",["外甥"]),"0,xs,d",["姨甥女"]),"1,xs,d",["外甥女"]),"s",["仔"]),"s,w",["新婦"]),f(f(f(f(f(f(f(f(f(f(d,"s,s",["孫"]),"s,s,w",["孫新婦"]),"s,s,s",["息仔"]),"s,s,d",["息女"]),"s,d",["孫女"]),"s,d,h",["孫女婿"]),"s,d,s",["外息仔"]),"s,d,d",["外息女"]),"d",["女"]),"d,s",["外孫"]),f(f(f(f(f(f(f(d,"d,s,w",["外孫新婦"]),"d,s,s",["外息仔"]),"d,s,d",["外息女"]),"d,d",["外孫女"]),"d,d,h",["外孫女婿"]),"d,d,s",["外息仔"]),"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};
2 |
--------------------------------------------------------------------------------
/vue/sw.js:
--------------------------------------------------------------------------------
1 | if(!self.define){let e,i={};const n=(n,c)=>(n=new URL(n+".js",c).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(c,o)=>{const s=e||("document"in self?document.currentScript.src:"")||location.href;if(i[s])return;let r={};const a=e=>n(e,s),d={module:{uri:s},exports:r,require:a};i[s]=Promise.all(c.map(e=>d[e]||a(e))).then(e=>(o(...e),r))}}define(["./workbox-ffa4df14"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"8cdabde7146a096cfeaeefeec8bdb33b"},{url:"index.html",revision:"95b4ef7816a2dd0705d2178a4db3b5e0"},{url:"favicon.ico",revision:"8a252401089c67ec6e6030835bbe7190"},{url:"icons/icon-96x96.png",revision:"6c0b0a3a5998044383e728dbd184bea2"},{url:"icons/icon-72x72.png",revision:"0a91e0612e6c0e6511159429dc5699bb"},{url:"icons/icon-512x512.png",revision:"203b9e4173cfa2768e61336406881726"},{url:"icons/icon-48x48.png",revision:"8244559f31798ebe3043e89a4b495aed"},{url:"icons/icon-192x192.png",revision:"5f4147d689cca6eccc43256e1ed87c51"},{url:"icons/icon-144x144.png",revision:"cd6b02f5424aa05f8a9db57b90da7605"},{url:"assets/index-CvPkaiGg.js",revision:null},{url:"assets/index-c03zNi4H.css",revision:null},{url:"assets/favicon-CcRSb4Ef.ico",revision:null},{url:"favicon.ico",revision:"8a252401089c67ec6e6030835bbe7190"},{url:"icons/icon-144x144.png",revision:"cd6b02f5424aa05f8a9db57b90da7605"},{url:"icons/icon-192x192.png",revision:"5f4147d689cca6eccc43256e1ed87c51"},{url:"icons/icon-48x48.png",revision:"8244559f31798ebe3043e89a4b495aed"},{url:"icons/icon-512x512.png",revision:"203b9e4173cfa2768e61336406881726"},{url:"icons/icon-72x72.png",revision:"0a91e0612e6c0e6511159429dc5699bb"},{url:"icons/icon-96x96.png",revision:"6c0b0a3a5998044383e728dbd184bea2"},{url:"manifest.webmanifest",revision:"6a17183ffcf28ffb5a90bea2bdc97ac6"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"))),e.registerRoute(({url:e})=>e.pathname.startsWith("/api/"),new e.NetworkFirst({cacheName:"api-cache",networkTimeoutSeconds:5,plugins:[new e.ExpirationPlugin({maxEntries:10,maxAgeSeconds:86400})]}),"GET")});
2 |
--------------------------------------------------------------------------------
/src/locale/guangdong.js:
--------------------------------------------------------------------------------
1 | export default {
2 | 'name':'广东',
3 | 'data':{
4 | 'f':['老窦'],
5 | 'f,f':['阿爷'],
6 | 'f,f,f':['太公'],
7 | 'f,f,m':['太婆'],
8 | 'f,m':['阿嫲'],
9 | 'f,m,f':['太外公'],
10 | 'f,m,m':['太外婆'],
11 | 'f,ob':['伯伯'],
12 | 'f,ob,w':['伯娘'],
13 | 'f,lb':['阿叔'],
14 | 'f,lb,w':['阿婶'],
15 | '0,f,xb,d,s':['堂姨甥'],
16 | '1,f,xb,d,s':['堂外甥'],
17 | '0,f,xb,d,d':['堂姨甥女'],
18 | '1,f,xb,d,d':['堂外甥女'],
19 | 'f,os':['姑母'],
20 | 'f,ls':['姑姐'],
21 | 'f,xs,h':['姑丈'],
22 | '0,f,xs,d,s':['姑表姨甥'],
23 | '1,f,xs,d,s':['姑表外甥'],
24 | '0,f,xs,d,d':['姑表姨甥女'],
25 | '1,f,xs,d,d':['姑表外甥女'],
26 | 'm':['老母'],
27 | 'm,f':['阿公'],
28 | 'm,f,f':['外太公'],
29 | 'm,f,m':['外太婆'],
30 | 'm,m':['阿婆'],
31 | 'm,m,f':['外太外公'],
32 | 'm,m,m':['外太外婆'],
33 | 'm,ob':['舅父'],
34 | 'm,lb':['舅仔'],
35 | 'm,xb,w':['舅母'],
36 | '0,m,xb,d,s':['舅表姨甥'],
37 | '1,m,xb,d,s':['舅表外甥'],
38 | '0,m,xb,d,d':['舅表姨甥女'],
39 | '1,m,xb,d,d':['舅表外甥女'],
40 | 'm,os':['姨妈'],
41 | 'm,ls':['姨仔'],
42 | 'm,xs,h':['姨丈'],
43 | '0,m,xb,d,s':['姨姨甥'],
44 | '1,m,xb,d,s':['姨外甥'],
45 | '0,m,xb,d,d':['姨姨甥女'],
46 | '1,m,xb,d,d':['姨外甥女'],
47 | 'ob':['大佬'],
48 | 'ob,w':['阿嫂'],
49 | 'lb':['细佬'],
50 | 'lb,w':['弟妇'],
51 | 'xb,s':['侄'],
52 | 'xb,d':['侄女'],
53 | 'os':['家姐'],
54 | 'os,h':['姐夫'],
55 | 'ls':['阿妹'],
56 | 'ls,h':['妹夫'],
57 | '0,xs,s':['姨甥'],
58 | '1,xs,s':['外甥'],
59 | '0,xs,d':['姨甥女'],
60 | '1,xs,d':['外甥女'],
61 | 's':['仔'],
62 | 's,w':['新妇'],
63 | 's,s':['孙'],
64 | 's,s,w':['孙新妇'],
65 | 's,s,s':['息仔'],
66 | 's,s,d':['息女'],
67 | 's,d':['孙女'],
68 | 's,d,h':['孙女婿'],
69 | 's,d,s':['外息仔'],
70 | 's,d,d':['外息女'],
71 | 'd':['女'],
72 | 'd,s':['外孙'],
73 | 'd,s,w':['外孙新妇'],
74 | 'd,s,s':['外息仔'],
75 | 'd,s,d':['外息女'],
76 | 'd,d':['外孙女'],
77 | 'd,d,h':['外孙女婿'],
78 | 'd,d,s':['外息仔'],
79 | 'd,d,d':['外息女'],
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/dist/relationship-mode.min.js:
--------------------------------------------------------------------------------
1 | !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)||!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: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(m(m(m(m(m(m(m(m(m(o,"0,m,xb,d,s",["姨姨甥"]),"1,m,xb,d,s",["姨外甥"]),"0,m,xb,d,d",["姨姨甥女"]),"1,m,xb,d,d",["姨外甥女"]),"ob",["大佬"]),"ob,w",["阿嫂"]),"lb",["细佬"]),"lb,w",["弟妇"]),"xb,s",["侄"]),"xb,d",["侄女"]),m(m(m(m(m(m(m(m(m(m(o,"os",["家姐"]),"os,h",["姐夫"]),"ls",["阿妹"]),"ls,h",["妹夫"]),"0,xs,s",["姨甥"]),"1,xs,s",["外甥"]),"0,xs,d",["姨甥女"]),"1,xs,d",["外甥女"]),"s",["仔"]),"s,w",["新妇"]),m(m(m(m(m(m(m(m(m(m(o,"s,s",["孙"]),"s,s,w",["孙新妇"]),"s,s,s",["息仔"]),"s,s,d",["息女"]),"s,d",["孙女"]),"s,d,h",["孙女婿"]),"s,d,s",["外息仔"]),"s,d,d",["外息女"]),"d",["女"]),"d,s",["外孙"]),m(m(m(m(m(m(m(o,"d,s,w",["外孙新妇"]),"d,s,s",["外息仔"]),"d,s,d",["外息女"]),"d,d",["外孙女"]),"d,d,h",["外孙女婿"]),"d,d,s",["外息仔"]),"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":["大娘"]}}}}));
2 |
--------------------------------------------------------------------------------
/dist/lang/relationship-mode.zh-HK.min.js:
--------------------------------------------------------------------------------
1 | !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)||!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: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(m(m(m(m(m(m(m(m(m(o,"0,m,xb,d,s",["姨姨甥"]),"1,m,xb,d,s",["姨外甥"]),"0,m,xb,d,d",["姨姨甥女"]),"1,m,xb,d,d",["姨外甥女"]),"ob",["大佬"]),"ob,w",["阿嫂"]),"lb",["細佬"]),"lb,w",["弟婦"]),"xb,s",["侄"]),"xb,d",["侄女"]),m(m(m(m(m(m(m(m(m(m(o,"os",["家姐"]),"os,h",["姐夫"]),"ls",["阿妹"]),"ls,h",["妹夫"]),"0,xs,s",["姨甥"]),"1,xs,s",["外甥"]),"0,xs,d",["姨甥女"]),"1,xs,d",["外甥女"]),"s",["仔"]),"s,w",["新婦"]),m(m(m(m(m(m(m(m(m(m(o,"s,s",["孫"]),"s,s,w",["孫新婦"]),"s,s,s",["息仔"]),"s,s,d",["息女"]),"s,d",["孫女"]),"s,d,h",["孫女婿"]),"s,d,s",["外息仔"]),"s,d,d",["外息女"]),"d",["女"]),"d,s",["外孫"]),m(m(m(m(m(m(m(o,"d,s,w",["外孫新婦"]),"d,s,s",["外息仔"]),"d,s,d",["外息女"]),"d,d",["外孫女"]),"d,d,h",["外孫女婿"]),"d,d,s",["外息仔"]),"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":["大娘"]}}}}));
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "relationship.js",
3 | "version": "1.2.7",
4 | "description": "Chinese kinship library",
5 | "author": "HaoLe Zheng",
6 | "license": "MIT",
7 | "keywords": [
8 | "relationship",
9 | "relationship.js",
10 | "chinese",
11 | "family",
12 | "kinship",
13 | "家庭亲戚称谓",
14 | "亲戚关系算法"
15 | ],
16 | "main": "./dist/relationship.min.js",
17 | "module": "./dist/relationship.min.mjs",
18 | "exports": {
19 | ".": {
20 | "import": "./dist/relationship.min.mjs",
21 | "require": "./dist/relationship.min.js",
22 | "default": "./dist/relationship.min.js"
23 | },
24 | "./mode": {
25 | "import": "./dist/relationship-mode.min.mjs",
26 | "require": "./dist/relationship-mode.min.js",
27 | "default": "./dist/relationship-mode.min.js"
28 | },
29 | "./zh-HK": {
30 | "import": "./dist/lang/relationship.zh-HK.min.mjs",
31 | "require": "./dist/lang/relationship.zh-HK.min.js",
32 | "default": "./dist/lang/relationship.zh-HK.min.js"
33 | },
34 | "./zh-HK/mode": {
35 | "import": "./dist/lang/relationship-mode.zh-HK.min.mjs",
36 | "require": "./dist/lang/relationship-mode.zh-HK.min.js",
37 | "default": "./dist/lang/relationship-mode.zh-HK.min.js"
38 | }
39 | },
40 | "repository": {
41 | "type": "git",
42 | "url": "git+https://github.com/mumuy/relationship.git"
43 | },
44 | "bugs": {
45 | "url": "https://github.com/mumuy/relationship/issues"
46 | },
47 | "engines": {
48 | "node": ">=20",
49 | "yarn": "please-use-npm",
50 | "npm": ">=8"
51 | },
52 | "files": [
53 | "dist"
54 | ],
55 | "devDependencies": {
56 | "@babel/core": "^7.26.0",
57 | "@babel/plugin-transform-runtime": "^7.25.9",
58 | "@babel/preset-env": "^7.26.0",
59 | "@babel/runtime": "^7.26.0",
60 | "@rollup/plugin-babel": "^6.0.4",
61 | "@rollup/plugin-node-resolve": "^15.3.0",
62 | "@rollup/plugin-terser": "^0.4.4",
63 | "gulp": "^5.0.0",
64 | "gulp-cht": "^2.0.20",
65 | "gulp-rename": "^2.0.0",
66 | "gulp-replace": "^1.1.4",
67 | "rollup": "^3.29.5",
68 | "tape": "^5.9.0",
69 | "through2": "^4.0.2"
70 | },
71 | "scripts": {
72 | "test": "node test/index.js",
73 | "build": "rollup -c && gulp && npm run test",
74 | "watch": "rollup -wc"
75 | },
76 | "homepage": "https://passer-by.com/relationship/",
77 | "directories": {
78 | "test": "test"
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/relationship.js:
--------------------------------------------------------------------------------
1 | import {getOptions} from './module/options.js';
2 | import {getSelectors,mergeSelector,selector2id} from './module/selector.js';
3 | import {reverseId,getItemsById,getChainById,getPairsById} from './module/id.js';
4 | import {setModeData,getModeData,modeData} from './module/mode.js';
5 |
6 | // 对外方法
7 | let relationship = function (parameter) {
8 | if(typeof parameter =='string'){
9 | parameter = getOptions(parameter);
10 | }
11 | let options = Object.assign({
12 | text: '', // 目标对象:目标对象的称谓汉字表达,称谓间用‘的’字分隔
13 | target: '', // 相对对象:相对对象的称谓汉字表达,称谓间用‘的’字分隔,空表示自己
14 | sex: -1, // 本人性别:0表示女性,1表示男性
15 | type: 'default', // 转换类型:'default'计算称谓,'chain'计算关系链,'pair'计算关系合称
16 | reverse: false, // 称呼方式:true对方称呼我,false我称呼对方
17 | mode: 'default', // 模式选择:使用setMode方法定制不同地区模式,在此选择自定义模式
18 | optimal: false // 最短关系:计算两者之间的最短关系
19 | }, parameter);
20 | // 切换模式
21 | getModeData(options.mode);
22 | let fromSelectors = getSelectors(options.text);
23 | let toSelectors = getSelectors(options.target);
24 | if (!toSelectors.length) {
25 | toSelectors = [''];
26 | }
27 | const result = fromSelectors.flatMap(fromSelector => {
28 | return toSelectors.flatMap(toSelector => {
29 | return mergeSelector({
30 | from: fromSelector,
31 | to: toSelector,
32 | sex: options.sex,
33 | optimal: options.optimal
34 | }).flatMap(data => {
35 | const ids = data ? selector2id(data['selector'], data['sex']) : [];
36 | return ids.flatMap(id => {
37 | let temps = [id];
38 | let sex = data['sex'];
39 | if (options.reverse) {
40 | temps = reverseId(id,sex);
41 | if(id.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)){
42 | sex = 1;
43 | }else{
44 | sex = 0;
45 | }
46 | }
47 | if (options.type === 'chain') {
48 | return temps.map(id => getChainById(id, sex)).filter(item => item);
49 | } else if (options.type === 'pair') {
50 | const reversedTemps = reverseId(id, data['sex']);
51 | return reversedTemps.flatMap(rId => getPairsById(id, rId));
52 | } else {
53 | return temps.flatMap(id => {
54 | let items = getItemsById(id);
55 | if (!items.length) {
56 | items = getItemsById(sex + ',' + id);
57 | }
58 | return items;
59 | });
60 | }
61 | });
62 | });
63 | });
64 | });
65 |
66 | return [...new Set(result)];
67 | };
68 |
69 | // 获取数据表
70 | relationship.data = modeData;
71 | // 获取数据量
72 | relationship.dataCount = Object.keys(modeData).length;
73 | // 设置语言模式
74 | relationship.setMode = setModeData;
75 |
76 | export default relationship;
--------------------------------------------------------------------------------
/src/module/map.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 完整关系链数据 - 合并各类关系链数据
3 | */
4 | import _prefix from './data/prefix.js';
5 | import _branch from './data/branch.js';
6 | import _main from './data/main.js';
7 | import _multipie from './data/multiple.js';
8 |
9 | import {expandSelector} from './selector.js';
10 |
11 | let _map = { ..._multipie };
12 |
13 | // 分支 - 前缀处理
14 | const prefixMap = {};
15 | for(const key in _prefix){
16 | prefixMap[key] = {};
17 | for(const selector in _prefix[key]){
18 | expandSelector(selector).forEach(function(s){
19 | prefixMap[key][s] = _prefix[key][selector];
20 | });
21 | }
22 | }
23 | // 分支 - 节点处理
24 | const branchMap = {};
25 | for(const selector in _branch){
26 | expandSelector(selector).forEach(function(s){
27 | branchMap[s] = _branch[selector];
28 | });
29 | }
30 | // 分支 - 合并
31 | const getMap = function(prefixMap,branchMap){
32 | const map = {};
33 | for(const key in branchMap){
34 | const tag = key.match(/\{.+?\}/)[0];
35 | const nameList = branchMap[key];
36 | for(const k in prefixMap[tag]){
37 | const prefixList = prefixMap[tag][k];
38 | const newKey = key.replace(tag,k);
39 | const isFilter = ['h,h','w,w','w,h','h,w'].some(pair=>(newKey.includes(pair)));
40 | if(!isFilter){
41 | const newList = prefixList.flatMap((prefix) =>
42 | nameList.map((name) => (name.includes('?') ? name.replace('?', prefix) : prefix + name))
43 | );
44 | if(!map[newKey]){
45 | map[newKey] = _map[newKey]||[];
46 | }
47 | map[newKey] = newList.concat(map[newKey]);
48 | }
49 | }
50 | }
51 | return map;
52 | };
53 | _map = {..._map,...getMap(prefixMap,branchMap)};
54 |
55 | // 主要关系
56 | for(let key in _main){
57 | _map[key] = [..._main[key], ...(_map[key] || [])];
58 | }
59 |
60 | // 版权彩蛋
61 | _map['o']=['passer-by.com','\u4f5c\u8005'];
62 |
63 | // 配偶关系
64 | const mateMap = {
65 | 'w':['妻','内','岳','岳家','丈人'],
66 | 'h':['夫','外','公','婆家','婆婆'],
67 | };
68 | const nameSet = new Set(Object.values(_map).flat());
69 | for(const key in _map){
70 | if(key.match(/^[fm]/)||key.match(/^[olx][bs]$|^[olx][bs],[^mf]/)){ // 只对长辈或者兄弟辈匹配
71 | for(const k in mateMap){
72 | let newKey = k+','+key;
73 | if(key.match(/[fm]/)){
74 | let newKey_x = newKey.replace(/,[ol]([sb])(,[wh])?$/,',x$1$2').replace(/(,[sd])&[ol](,[wh])?$/,'$1$2');
75 | if(newKey_x!=newKey&&_map[newKey_x]){ // 不扩大解释年龄
76 | continue;
77 | }
78 | }
79 | if(!_map[newKey]){
80 | _map[newKey] = [];
81 | }
82 | const prefixList = mateMap[k];
83 | const nameList = _map[key];
84 | prefixList.forEach(function(prefix){
85 | nameList.forEach(function(name){
86 | const newName = prefix+name;
87 | if(!nameSet.has(newName)){ // 配偶组合的称呼不得与原有称呼冲突(如:妻舅!=妻子的舅舅;外舅公!=老公的舅公)
88 | _map[newKey].push(newName);
89 | }
90 | });
91 | });
92 | }
93 | }
94 | }
95 |
96 | export default _map;
97 |
--------------------------------------------------------------------------------
/static/image/public/bg.svg:
--------------------------------------------------------------------------------
1 |
2 |
54 |
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var test = require('tape');
3 | var relationship = require('..');
4 |
5 | test('[call]', function (t) {
6 | // console.log('[test]',relationship({text:'爸爸的妈妈的姐姐的儿子'}));
7 |
8 | t.deepEqual(relationship({text:'爸爸的哥哥的弟弟的儿子'}),['堂哥','堂弟','哥哥','弟弟','自己']);
9 | t.deepEqual(relationship({text:'爸爸的妹妹的女儿的老公'}),['姑表姐夫','姑表妹夫']);
10 | t.deepEqual(relationship({text:'表姐的哥哥',sex:1}),['姑表哥','舅表哥']);
11 | t.deepEqual(relationship({text:'表姐的妹妹',sex:1}),['姑表姐','姑表妹','舅表姐','舅表妹']);
12 | t.deepEqual(relationship({text:'弟弟的表哥',sex:1}),['姑表哥','姑表弟','舅表哥','舅表弟']);
13 | t.deepEqual(relationship({text:'姐姐的老公的姐姐的老公'}),['姊妹姻姊妹壻']);
14 | t.deepEqual(relationship({text:'哥哥的弟弟的爸爸的儿子',sex:1}),['哥哥','弟弟','自己']);
15 | t.deepEqual(relationship({text:'爱人',sex:1}),['老婆']);
16 | t.deepEqual(relationship({text:'爱人的爱人',sex:1}),['自己']);
17 | t.deepEqual(relationship({text:'老婆的爱人',sex:1}),['自己']);
18 | t.deepEqual(relationship({text:'老婆的老公',sex:1}),['自己']);
19 | t.deepEqual(relationship({text:'老婆的外孙的姥爷',sex:1}),['自己']);
20 | t.deepEqual(relationship({text:'老公的老婆的儿子的爸爸',sex:0}),['老公']);
21 | t.deepEqual(relationship({text:'堂兄弟的孩子',sex:1}),['堂侄','堂侄女']);
22 | t.deepEqual(relationship({text:'儿子的爸爸的妈妈',sex:1}),['妈妈']);
23 | t.deepEqual(relationship({text:'岳母的配偶的孩子的爸爸'}),['岳父']);
24 | t.deepEqual(relationship({text:'爸爸的妈妈的姐姐的儿子'}),['姨伯父','姨叔父']);
25 | t.end();
26 | });
27 | test('[target]', function (t) {
28 | t.deepEqual(relationship({text:'我',target:'爸爸'}),['儿子','女儿']);
29 | t.deepEqual(relationship({text:'老公的父母',target:'孩子'}),['爷爷','奶奶']);
30 | t.deepEqual(relationship({text:'爱人',target:'娘家侄子'}),['姑丈']);
31 | t.end();
32 | });
33 | test('[reverse]', function (t) {
34 | t.deepEqual(relationship({text:'爸爸的舅舅',sex:0,reverse:true}),['甥孙女']);
35 | t.deepEqual(relationship({text:'岳母',target:'女儿',reverse:true}),['外孙女']);
36 | t.deepEqual(relationship({text:'姑妈',target:'舅妈',reverse:true}),['兄弟眷兄弟妇']);
37 | t.deepEqual(relationship({text:'舅妈',target:'女儿',reverse:true}),['姑甥孙女','姑甥外孙女']);
38 | t.deepEqual(relationship({text:'外婆',target:'女婿',reverse:true}),['外曾孙女婿','外曾外孙女婿']);
39 | t.end();
40 | });
41 | test('[filter]', function (t) {
42 | t.deepEqual(relationship({text:'内侄'}),['舅侄','舅侄女']);
43 | t.end();
44 | });
45 | test('[type:chain]', function (t) {
46 | t.deepEqual(relationship({text:'舅爷爷',type:'chain'}),['爸爸的妈妈的兄弟']);
47 | t.deepEqual(relationship({text:'妻儿',type:'chain'}),['老婆','儿子','女儿']);
48 | t.deepEqual(relationship({text:'父母',target:'老公',type:'chain'}),['老婆的爸爸','老婆的妈妈']);
49 | t.end();
50 | });
51 | test('[type:pair]', function (t) {
52 | t.deepEqual(relationship({text:'舅妈',target:'哥哥',type:'pair'}),['舅甥']);
53 | t.deepEqual(relationship({text:'舅妈',target:'外婆',type:'pair'}),['婆媳']);
54 | t.deepEqual(relationship({text:'舅妈',target:'二舅',type:'pair'}),['伯媳','叔嫂','夫妻']);
55 | t.deepEqual(relationship({text:'堂哥',target:'叔叔',type:'pair'}),['伯侄', '叔侄', '父子']);
56 | t.end();
57 | });
58 | test('[age]', function (t) {
59 | t.deepEqual(relationship({text:'妈妈的二哥'}),['二舅']);
60 | t.deepEqual(relationship({text:'爸爸的二哥'}),['二伯']);
61 | t.deepEqual(relationship({text:'二舅妈',target:'三舅'}),['二嫂']);
62 | t.deepEqual(relationship({text:'爸爸的二爸'}),['二爷爷']);
63 | t.deepEqual(relationship({text:'姑姑',target:'叔叔',optimal:true}),['姐姐','妹妹']);
64 | t.deepEqual(relationship({text:'大舅',target:'二舅的儿子'}),['伯父']);
65 | t.deepEqual(relationship({text:'二舅妈',target:'二舅',type:'pair'}),['夫妻']);
66 | t.deepEqual(relationship({text:'二舅妈',target:'大舅',type:'pair'}),['伯媳']);
67 | t.end();
68 | });
69 | test('[expression]', function (t) {
70 | t.deepEqual(relationship('外婆和奶奶之间是什么关系?'),['儿女亲家']);
71 | t.deepEqual(relationship('妈妈应该如何称呼姑姑'),['姑子']);
72 | t.deepEqual(relationship('姑奶奶是什么关系'),['爸爸的爸爸的姐妹']);
73 | t.deepEqual(relationship('姑奶奶和爸爸是什么关系'),['姑侄']);
74 | t.deepEqual(relationship('我应该叫外婆的哥哥什么?'),['舅外公']);
75 | t.deepEqual(relationship('七舅姥爷应该叫我什么?'),['甥外孙','甥外孙女']);
76 | t.deepEqual(relationship('舅公是什么关系?'),['爸爸的妈妈的兄弟', '妈妈的妈妈的兄弟', '老公的妈妈的兄弟']);
77 | t.deepEqual(relationship('舅妈如何称呼外婆?'),['婆婆']);
78 | t.deepEqual(relationship('外婆和奶奶之间是什么关系?'),['儿女亲家']);
79 | t.end();
80 | });
81 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | 由于工作生活节奏不同,如今很多关系稍疏远的亲戚之间来往并不多。因此放假回家过年时,往往会搞不清楚哪位亲戚应该喊什么称呼,很是尴尬。然而搞不清亲戚关系和亲戚称谓的不仅是小孩,就连年轻一代的大人也都常常模糊混乱。
4 |
5 | “中国家庭称谓计算器”为你避免了这种尴尬,只需简单的输入即可算出称谓。输入框兼容了不同的叫法,你可以称呼父亲为:“老爸”、“爹地”、“老爷子”等等,方便不同地域的习惯叫法。快捷输入按键,只需简单的点击即可完成关系输入,算法还支持逆向查找称呼哦~!
6 |
7 | 项目演示地址:[https://passer-by.com/relationship/](https://passer-by.com/relationship/)
8 |
9 | 移动版演示地址: [https://passer-by.com/relationship/vue/](https://passer-by.com/relationship/vue/)
10 |
11 | ## 一、下载 & 安装
12 |
13 | 脚本库可以用于浏览器,也可以用于 Nodejs 环境中。
14 |
15 | 1. 在网页中引入 `