{"id":13559791,"url":"https://github.com/mumuy/relationship","last_synced_at":"2025-05-13T17:14:36.224Z","repository":{"id":42000572,"uuid":"54008251","full_name":"mumuy/relationship","owner":"mumuy","description":"中国亲戚关系计算器 - 家庭称谓/亲戚称呼/称呼计算/辈分计算/亲戚关系算法/親戚稱呼計算機_Chinese kinship system.","archived":false,"fork":false,"pushed_at":"2025-05-13T15:51:06.000Z","size":19218,"stargazers_count":3401,"open_issues_count":0,"forks_count":368,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-05-13T16:48:41.727Z","etag":null,"topics":["chinese","family-tree","kinship","relationship"],"latest_commit_sha":null,"homepage":"https://passer-by.com/relationship/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mumuy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["mumuy"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2016-03-16T06:57:16.000Z","updated_at":"2025-05-13T15:51:09.000Z","dependencies_parsed_at":"2023-09-22T10:45:56.080Z","dependency_job_id":"6f40c69b-293e-4a76-9f40-13ec140c837f","html_url":"https://github.com/mumuy/relationship","commit_stats":{"total_commits":803,"total_committers":8,"mean_commits":100.375,"dds":"0.31133250311332505","last_synced_commit":"ba1838d28c70282662f012d595ace7243db17fa1"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Frelationship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Frelationship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Frelationship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Frelationship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mumuy","download_url":"https://codeload.github.com/mumuy/relationship/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990500,"owners_count":21995776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chinese","family-tree","kinship","relationship"],"created_at":"2024-08-01T13:00:33.445Z","updated_at":"2025-05-13T17:14:31.204Z","avatar_url":"https://github.com/mumuy.png","language":"JavaScript","funding_links":["https://github.com/sponsors/mumuy"],"categories":["JavaScript","JavaScript (485)"],"sub_categories":[],"readme":"![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/mumuy/relationship/test.yml)\n\n由于工作生活节奏不同，如今很多关系稍疏远的亲戚之间来往并不多。因此放假回家过年时，往往会搞不清楚哪位亲戚应该喊什么称呼，很是尴尬。然而搞不清亲戚关系和亲戚称谓的不仅是小孩，就连年轻一代的大人也都常常模糊混乱。\n\n“中国家庭称谓计算器”为你避免了这种尴尬，只需简单的输入即可算出称谓。输入框兼容了不同的叫法，你可以称呼父亲为：“老爸”、“爹地”、“老爷子”等等，方便不同地域的习惯叫法。快捷输入按键，只需简单的点击即可完成关系输入，算法还支持逆向查找称呼哦～！\n\n项目演示地址：[https://passer-by.com/relationship/](https://passer-by.com/relationship/)\n\n移动版演示地址: [https://passer-by.com/relationship/vue/](https://passer-by.com/relationship/vue/)\n\n## 一、下载 \u0026 安装\n\n脚本库可以用于浏览器，也可以用于 Nodejs 环境中。\n\n1. 在网页中引入 `\u003cscript src=\"https://passer-by.com/relationship/dist/relationship.min.js\"\u003e`\n\n   获取全局方法 `relationship`\n   \n2. 使用 npm 安装名为 `relationship.js ` 的包\n\n\t\u003e **npm install relationship.js**\n\n\t在脚本中引入模块\n\n\t```js\n\t// CommonJS 引入\n\tconst relationship = require(\"relationship.js\");\n\t```\n\t```js\n\t// ES Module 引入\n \timport relationship from 'relationship.js';\n\t```\n \t ![npm](https://img.shields.io/npm/v/relationship.js)  ![npm](https://img.shields.io/npm/dw/relationship.js)\n\n## 二、使用\n1. 通用方法: 唯一的计算方法 `relationship`.\n\t\n\t* 选项模式 `relationship(options)`\n\t\n\t参数`options`结构为：\n\t\n\t```js\n\tvar options = {\n\t\ttext:'',\t\t// 目标对象：目标对象的称谓汉字表达，称谓间用‘的’字分隔\n\t\ttarget:'',\t    \t// 相对对象：相对对象的称谓汉字表达，称谓间用‘的’字分隔，空表示自己\n\t\tsex:-1,\t\t\t// 本人性别：0表示女性,1表示男性\n\t\ttype:'default',\t\t// 转换类型：'default'计算称谓,'chain'计算关系链,'pair'计算关系合称\n\t\treverse:false,\t\t// 称呼方式：true对方称呼我,false我称呼对方\n\t\tmode:'default',\t\t// 模式选择：使用setMode方法定制不同地区模式，在此选择自定义模式\n\t\toptimal:false,       \t// 最短关系：计算两者之间的最短关系\n\t};\n\t```\n\t\n\t代码示例：\n\t\n\t```js\n\t// 如：我应该叫外婆的哥哥什么？\n\trelationship({text:'妈妈的妈妈的哥哥'});\n\t// =\u003e ['舅外公']\n\t\n\t// 如：七舅姥爷应该叫我什么？\n\trelationship({text:'七舅姥爷',reverse:true,sex:1});\n\t// =\u003e ['甥外孙']\n\t\n\t// 如：舅公是什么亲戚\n\trelationship({text:'舅公',type:'chain'});\n\t// =\u003e ['爸爸的妈妈的兄弟', '妈妈的妈妈的兄弟', '老公的妈妈的兄弟']\n\t\n\t// 如：舅妈如何称呼外婆？\n\trelationship({text:'外婆',target:'舅妈',sex:1});\n\t// =\u003e ['婆婆']\n\t\n\t// 如：外婆和奶奶之间是什么关系？\n\trelationship({text:'外婆',target:'奶奶',type:'pair'});\n\t// =\u003e ['儿女亲家']\n\t```\n\t\n\t* 语句模式 `relationship(exptession)`\n\t\n\t参数`exptession`句式可以为：`xxx是xxx的什么人`、`xxx叫xxx什么`、`xxx如何称呼xxx`等.\n\t\n\t代码示例：\n\t\n\t```js\n\t// 如：舅妈如何称呼外婆？\n\trelationship('舅妈如何称呼外婆？');\n\t// =\u003e ['婆婆']\n\t\n\t// 如：外婆和奶奶之间是什么关系？\n\trelationship('外婆和奶奶之间是什么关系？');\n\t// =\u003e ['儿女亲家']\n\t```\n\n2. 内部属性：获取当前数据表 `relationship.data`.\n\n3. 内部属性：获取当前数据量 `relationship.dataCount`.\n\n4. 内部方法：用户自定义模式 `relationship.setMode(mode_name,mode_data)`.\n\n\t代码示例(可参考数据表格式对数据进行覆盖)：\n\t\n\t```js\n\t// 关系解析语法\n\t// 【关系链】f:父,m:母,h:夫,w:妻,s:子,d:女,xb:兄弟,ob:兄,lb:弟,xs:姐妹,os:姐,ls:妹\n\t// 【修饰符】 1:男性,0:女性,\u0026o:年长,\u0026l:年幼,#:隔断,[a|b]:并列\n\trelationship.setMode('northern',{\n\t\t'm,f':['姥爷'],\n\t\t'm,m':['姥姥'],\n\t\t'm,xb,s\u0026o':['表哥'],\n\t\t'm,xb,s\u0026l':['表弟'],\n\t});\n\t```\n\n## 三、开发 \u0026 贡献\n\n```sh\n# 安装开发依赖\nnpm install\n\n# build 模块: 将 relationship 打包压缩\nnpm run build\n\n# 执行测试用例（可以在tests/test.js中完善测试用例）\nnpm test\n```\n\n\n## 四、关于分歧\n\n一些称呼存在南北方或地区差异，容易引起歧义，并不保证和你所处地区的称谓习惯一致。\n\n部分称呼有多种关系且跨辈分。例如：\n* 大爷：爷爷的哥哥 / 父亲的哥哥(北方)；\n* 舅公：爸妈的舅舅 / 老公的舅舅；\n* 伯公：爸妈的伯父 / 老公的伯父；\n* 叔公：爸妈的叔叔 / 老公的叔叔；\n* 姨公：爸妈的姨丈 / 老公的姨丈；\n* 姨夫：姨妈的老公 / 姨子的老公；\n* 姑夫：姑妈的老公 / 姑子的老公；\n* 婶子：叔叔的老婆 / 叔子的老婆；\n* 妗子：舅舅的老婆 / 舅子的老婆；\n\n部分称呼以现代生活常见理解为主。例如：\n* 媳妇：在古代或者北方地区指儿子的妻子，这里指自己的妻子(儿媳妇写作“息妇”)；\n* 太太：一些地方指年长的妇人或曾祖父母，这里指自己的妻子；\n\n## 五、教程\n\n* [算法实现原理](https://github.com/mumuy/relationship/wiki/%E7%AE%97%E6%B3%95%E5%AE%9E%E7%8E%B0)\n\n## 六、其他\n\n他们都在用：\n\n查询网\nhttp://www.ip138.com/chengwei/\n\n在线查询网\nhttp://qinshu.supfree.net/\n\n在线工具\nhttp://www.atool.org/relateship.php\n\n有道语文达人\nhttp://dict.youdao.com/k12yuwen/html/relation.html\n\n小米MIUI系统计算器\nhttp://www.miui.com/\n\n小米MIUI网页版本\nhttp://www.miui.com/zt/calculator2016/dist.php\n\n符号库\nhttp://www.fuhaoku.com/tool/qinqiguanxi.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumuy%2Frelationship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmumuy%2Frelationship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumuy%2Frelationship/lists"}