@treeviz/gedcom-parser 2.1.7 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/index.js +463 -4
- package/dist/classes/indi.d.ts +11 -1
- package/dist/classes/indi.d.ts.map +1 -1
- package/dist/cli/index.js +463 -4
- package/dist/constants/index.js +462 -3
- package/dist/factories/index.js +462 -3
- package/dist/index.js +464 -5
- package/dist/kinship-translator/index.d.ts +2 -0
- package/dist/kinship-translator/index.d.ts.map +1 -1
- package/dist/kinship-translator/index.js +463 -4
- package/dist/kinship-translator/kinship-translator.ja.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.ja.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.zh.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.zh.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.ja.d.ts +2 -0
- package/dist/kinship-translator/patterns.ja.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.zh.d.ts +2 -0
- package/dist/kinship-translator/patterns.zh.d.ts.map +1 -0
- package/dist/kinship-translator/translators.d.ts +2 -0
- package/dist/kinship-translator/translators.d.ts.map +1 -1
- package/dist/kinship-translator/types.d.ts +1 -1
- package/dist/kinship-translator/types.d.ts.map +1 -1
- package/dist/utils/index.js +463 -4
- package/package.json +1 -1
package/dist/constants/index.js
CHANGED
|
@@ -98,7 +98,9 @@ __export(translators_exports, {
|
|
|
98
98
|
es: () => KinshipTranslatorEs,
|
|
99
99
|
fr: () => KinshipTranslatorFr,
|
|
100
100
|
hu: () => KinshipTranslatorHU,
|
|
101
|
-
|
|
101
|
+
ja: () => KinshipTranslatorJa,
|
|
102
|
+
ru: () => KinshipTranslatorRu,
|
|
103
|
+
zh: () => KinshipTranslatorZh
|
|
102
104
|
});
|
|
103
105
|
var getGedcomId = (gedcom) => {
|
|
104
106
|
if (!gedcom) {
|
|
@@ -4306,14 +4308,29 @@ var Indi = class extends Common {
|
|
|
4306
4308
|
getAkas(limit) {
|
|
4307
4309
|
return this.getFacts(limit, "AKA");
|
|
4308
4310
|
}
|
|
4311
|
+
/**
|
|
4312
|
+
* Collect event/attribute facts.
|
|
4313
|
+
* @param limit Max records per tag
|
|
4314
|
+
* @param filter Whitelist tags, or `{ include?, exclude? }`.
|
|
4315
|
+
* - string/array: include only these tags (and custom EVEN/FACT TYPE values)
|
|
4316
|
+
* - `{ exclude: ["BIRT","DEAT"] }`: all facts except those tags
|
|
4317
|
+
*/
|
|
4309
4318
|
getFacts(limit, filter) {
|
|
4310
|
-
const
|
|
4311
|
-
|
|
4319
|
+
const asList = (value) => (Array.isArray(value) ? value : [value]).filter(Boolean);
|
|
4320
|
+
const isFilterObject = !!filter && typeof filter === "object" && !Array.isArray(filter) && ("include" in filter || "exclude" in filter);
|
|
4321
|
+
const filters = asList(
|
|
4322
|
+
isFilterObject ? filter.include : filter
|
|
4323
|
+
);
|
|
4324
|
+
const excludes = asList(
|
|
4325
|
+
isFilterObject ? filter.exclude : void 0
|
|
4312
4326
|
);
|
|
4313
4327
|
const facts = new List();
|
|
4314
4328
|
let id = 0;
|
|
4315
4329
|
ALLOWED_FACTS.forEach((fact) => {
|
|
4316
4330
|
const isCustom = ["EVEN", "FACT"].includes(fact);
|
|
4331
|
+
if (excludes.length && excludes.includes(fact) && !isCustom) {
|
|
4332
|
+
return;
|
|
4333
|
+
}
|
|
4317
4334
|
if (filters.length && !filters.includes(fact) && !isCustom) {
|
|
4318
4335
|
return;
|
|
4319
4336
|
}
|
|
@@ -4336,6 +4353,9 @@ var Indi = class extends Common {
|
|
|
4336
4353
|
if (!type || DISALLOWED_CUSTOM_FACTS.includes(type)) {
|
|
4337
4354
|
return;
|
|
4338
4355
|
}
|
|
4356
|
+
if (excludes.length && excludes.includes(type)) {
|
|
4357
|
+
return;
|
|
4358
|
+
}
|
|
4339
4359
|
if (filters.length && !filters.includes(type) && isCustom) {
|
|
4340
4360
|
return;
|
|
4341
4361
|
}
|
|
@@ -6985,6 +7005,445 @@ var KinshipTranslatorRu = class extends KinshipTranslatorBasic {
|
|
|
6985
7005
|
}
|
|
6986
7006
|
};
|
|
6987
7007
|
|
|
7008
|
+
// src/kinship-translator/patterns.ja.ts
|
|
7009
|
+
var InLawsJa = {
|
|
7010
|
+
"(\u5B50|\u5A18|\u606F\u5B50)\u306E\u914D\u5076\u8005": "\u7FA9\u7406\u306E\u5B50",
|
|
7011
|
+
"(\u5B50|\u5A18|\u606F\u5B50)\u306E\u59BB": "\u5AC1",
|
|
7012
|
+
"(\u5B50|\u5A18|\u606F\u5B50)\u306E\u592B": "\u5A7F",
|
|
7013
|
+
"(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u6BCD": "\u7FA9\u6BCD",
|
|
7014
|
+
"(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u7236": "\u7FA9\u7236",
|
|
7015
|
+
"(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u89AA": "\u7FA9\u7406\u306E\u89AA",
|
|
7016
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u5144\u5F1F|\u59C9\u59B9|\u5144\u5F1F\u59C9\u59B9)\u306E\u59BB": "\u7FA9\u7406\u306E\u59C9\u59B9",
|
|
7017
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u5144\u5F1F|\u59C9\u59B9|\u5144\u5F1F\u59C9\u59B9)\u306E\u592B": "\u7FA9\u7406\u306E\u5144\u5F1F",
|
|
7018
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u5144\u5F1F|\u59C9\u59B9|\u5144\u5F1F\u59C9\u59B9)\u306E\u914D\u5076\u8005": "\u7FA9\u7406\u306E\u5144\u5F1F\u59C9\u59B9",
|
|
7019
|
+
"(\u7570\u7236\u6BCD\u306E)?\u59C9\u59B9\u306E(\u914D\u5076\u8005|\u59BB|\u592B)": "\u7FA9\u7406\u306E\u59C9\u59B9",
|
|
7020
|
+
"(\u7570\u7236\u6BCD\u306E)?\u5144\u5F1F\u306E(\u914D\u5076\u8005|\u59BB|\u592B)": "\u7FA9\u7406\u306E\u5144\u5F1F",
|
|
7021
|
+
"(\u7570\u7236\u6BCD\u306E)?\u5144\u5F1F\u59C9\u59B9\u306E(\u914D\u5076\u8005|\u59BB|\u592B)": "\u7FA9\u7406\u306E\u5144\u5F1F\u59C9\u59B9",
|
|
7022
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u59C9\u59B9": "\u7FA9\u7406\u306E\u59C9\u59B9",
|
|
7023
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u5144\u5F1F": "\u7FA9\u7406\u306E\u5144\u5F1F",
|
|
7024
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u5144\u5F1F\u59C9\u59B9": "\u7FA9\u7406\u306E\u5144\u5F1F\u59C9\u59B9"
|
|
7025
|
+
};
|
|
7026
|
+
|
|
7027
|
+
// src/kinship-translator/kinship-translator.ja.ts
|
|
7028
|
+
var sexOf2 = (person) => {
|
|
7029
|
+
if (person?.isMale?.()) {
|
|
7030
|
+
return "m";
|
|
7031
|
+
}
|
|
7032
|
+
if (person?.isFemale?.()) {
|
|
7033
|
+
return "f";
|
|
7034
|
+
}
|
|
7035
|
+
return "n";
|
|
7036
|
+
};
|
|
7037
|
+
var pick = (sex, male, female, neutral) => {
|
|
7038
|
+
if (sex === "m") {
|
|
7039
|
+
return male;
|
|
7040
|
+
}
|
|
7041
|
+
if (sex === "f") {
|
|
7042
|
+
return female;
|
|
7043
|
+
}
|
|
7044
|
+
return neutral;
|
|
7045
|
+
};
|
|
7046
|
+
var lineal = (level, sex, kind) => {
|
|
7047
|
+
const L = Math.max(1, level);
|
|
7048
|
+
if (kind === "asc") {
|
|
7049
|
+
if (L <= 1) {
|
|
7050
|
+
return pick(sex, "\u7236", "\u6BCD", "\u89AA");
|
|
7051
|
+
}
|
|
7052
|
+
if (L === 2) {
|
|
7053
|
+
return pick(sex, "\u7956\u7236", "\u7956\u6BCD", "\u7956\u7236\u6BCD");
|
|
7054
|
+
}
|
|
7055
|
+
if (L === 3) {
|
|
7056
|
+
return pick(sex, "\u66FE\u7956\u7236", "\u66FE\u7956\u6BCD", "\u66FE\u7956\u7236\u6BCD");
|
|
7057
|
+
}
|
|
7058
|
+
if (L === 4) {
|
|
7059
|
+
return pick(sex, "\u9AD8\u7956\u7236", "\u9AD8\u7956\u6BCD", "\u9AD8\u7956\u7236\u6BCD");
|
|
7060
|
+
}
|
|
7061
|
+
return pick(
|
|
7062
|
+
sex,
|
|
7063
|
+
`${L - 1}\u4E16\u306E\u7956\u7236`,
|
|
7064
|
+
`${L - 1}\u4E16\u306E\u7956\u6BCD`,
|
|
7065
|
+
`${L - 1}\u4E16\u306E\u7956\u7236\u6BCD`
|
|
7066
|
+
);
|
|
7067
|
+
}
|
|
7068
|
+
if (L <= 1) {
|
|
7069
|
+
return pick(sex, "\u606F\u5B50", "\u5A18", "\u5B50");
|
|
7070
|
+
}
|
|
7071
|
+
if (L === 2) {
|
|
7072
|
+
return "\u5B6B";
|
|
7073
|
+
}
|
|
7074
|
+
if (L === 3) {
|
|
7075
|
+
return "\u66FE\u5B6B";
|
|
7076
|
+
}
|
|
7077
|
+
if (L === 4) {
|
|
7078
|
+
return "\u7384\u5B6B";
|
|
7079
|
+
}
|
|
7080
|
+
return `${L - 1}\u4E16\u306E\u5B6B`;
|
|
7081
|
+
};
|
|
7082
|
+
var cousinPlain = (degree) => {
|
|
7083
|
+
if (degree <= 1) {
|
|
7084
|
+
return "\u3044\u3068\u3053";
|
|
7085
|
+
}
|
|
7086
|
+
if (degree === 2) {
|
|
7087
|
+
return "\u307E\u305F\u3044\u3068\u3053";
|
|
7088
|
+
}
|
|
7089
|
+
if (degree === 3) {
|
|
7090
|
+
return "\u306F\u3068\u3053";
|
|
7091
|
+
}
|
|
7092
|
+
return `${degree}\u89AA\u7B49\u306E\u3044\u3068\u3053`;
|
|
7093
|
+
};
|
|
7094
|
+
var KinshipTranslatorJa = class extends KinshipTranslatorBasic {
|
|
7095
|
+
indirect() {
|
|
7096
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7097
|
+
if (degree > 0) {
|
|
7098
|
+
degree = degree - 1;
|
|
7099
|
+
}
|
|
7100
|
+
return cousinPlain(degree);
|
|
7101
|
+
}
|
|
7102
|
+
removal() {
|
|
7103
|
+
const level = this.pathN?.level ?? 0;
|
|
7104
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7105
|
+
if (degree > 0) {
|
|
7106
|
+
degree = degree - 1;
|
|
7107
|
+
}
|
|
7108
|
+
if (!degree) {
|
|
7109
|
+
return level < 0 ? this.nibling() : this.auncle();
|
|
7110
|
+
}
|
|
7111
|
+
const removed = Math.abs(level);
|
|
7112
|
+
return `${cousinPlain(degree)}\uFF08${removed}\u4E16\u4EE3\u9055\u3044\uFF09`;
|
|
7113
|
+
}
|
|
7114
|
+
auncle() {
|
|
7115
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7116
|
+
const sex = sexOf2(this.personN);
|
|
7117
|
+
if (level <= 2) {
|
|
7118
|
+
return pick(sex, "\u304A\u3058", "\u304A\u3070", "\u304A\u3058/\u304A\u3070");
|
|
7119
|
+
}
|
|
7120
|
+
if (level === 3) {
|
|
7121
|
+
return pick(sex, "\u5927\u304A\u3058", "\u5927\u304A\u3070", "\u5927\u304A\u3058/\u5927\u304A\u3070");
|
|
7122
|
+
}
|
|
7123
|
+
return pick(
|
|
7124
|
+
sex,
|
|
7125
|
+
`${level - 2}\u4EE3\u524D\u306E\u304A\u3058`,
|
|
7126
|
+
`${level - 2}\u4EE3\u524D\u306E\u304A\u3070`,
|
|
7127
|
+
`${level - 2}\u4EE3\u524D\u306E\u304A\u3058/\u304A\u3070`
|
|
7128
|
+
);
|
|
7129
|
+
}
|
|
7130
|
+
nibling() {
|
|
7131
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7132
|
+
const sex = sexOf2(this.personN);
|
|
7133
|
+
if (level <= 2) {
|
|
7134
|
+
return pick(sex, "\u7525", "\u59EA", "\u7525/\u59EA");
|
|
7135
|
+
}
|
|
7136
|
+
if (level === 3) {
|
|
7137
|
+
return pick(sex, "\u5927\u7525", "\u5927\u59EA", "\u5927\u7525/\u5927\u59EA");
|
|
7138
|
+
}
|
|
7139
|
+
return pick(
|
|
7140
|
+
sex,
|
|
7141
|
+
`${level - 2}\u4EE3\u4E0B\u306E\u7525`,
|
|
7142
|
+
`${level - 2}\u4EE3\u4E0B\u306E\u59EA`,
|
|
7143
|
+
`${level - 2}\u4EE3\u4E0B\u306E\u7525/\u59EA`
|
|
7144
|
+
);
|
|
7145
|
+
}
|
|
7146
|
+
parent() {
|
|
7147
|
+
return lineal(
|
|
7148
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7149
|
+
sexOf2(this.personN),
|
|
7150
|
+
"asc"
|
|
7151
|
+
);
|
|
7152
|
+
}
|
|
7153
|
+
child() {
|
|
7154
|
+
return lineal(
|
|
7155
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7156
|
+
sexOf2(this.personN),
|
|
7157
|
+
"desc"
|
|
7158
|
+
);
|
|
7159
|
+
}
|
|
7160
|
+
sibling() {
|
|
7161
|
+
return pick(sexOf2(this.personN), "\u5144\u5F1F", "\u59C9\u59B9", "\u5144\u5F1F\u59C9\u59B9");
|
|
7162
|
+
}
|
|
7163
|
+
halfBlood(relation) {
|
|
7164
|
+
if (!relation || !this.isHalfBlood) {
|
|
7165
|
+
return relation ?? "";
|
|
7166
|
+
}
|
|
7167
|
+
return `\u7570\u7236\u6BCD\u306E${relation}`;
|
|
7168
|
+
}
|
|
7169
|
+
spouse() {
|
|
7170
|
+
return pick(sexOf2(this.personN), "\u592B", "\u59BB", "\u914D\u5076\u8005");
|
|
7171
|
+
}
|
|
7172
|
+
ofSpouse(relation) {
|
|
7173
|
+
if (!relation) {
|
|
7174
|
+
return "";
|
|
7175
|
+
}
|
|
7176
|
+
const spouseType = pick(
|
|
7177
|
+
sexOf2(this.path?.[1].indi),
|
|
7178
|
+
"\u592B",
|
|
7179
|
+
"\u59BB",
|
|
7180
|
+
"\u914D\u5076\u8005"
|
|
7181
|
+
);
|
|
7182
|
+
return `${spouseType}\u306E${relation}`;
|
|
7183
|
+
}
|
|
7184
|
+
spouseOf(relation) {
|
|
7185
|
+
if (!relation) {
|
|
7186
|
+
return "";
|
|
7187
|
+
}
|
|
7188
|
+
const spouse = this.path?.[this.path.length - 1].indi;
|
|
7189
|
+
const spouseType = pick(sexOf2(spouse), "\u592B", "\u59BB", "\u914D\u5076\u8005");
|
|
7190
|
+
return `${relation}\u306E${spouseType}`;
|
|
7191
|
+
}
|
|
7192
|
+
of(relation) {
|
|
7193
|
+
const formattedName = nameFormatter(this.path?.[0]?.indi, {
|
|
7194
|
+
nameOrder: "last-first"
|
|
7195
|
+
});
|
|
7196
|
+
let name = formattedName.inOrder.filter(Boolean).join(" ");
|
|
7197
|
+
if (this.displayName === "none") {
|
|
7198
|
+
name = "";
|
|
7199
|
+
} else if (this.displayName === "givenname") {
|
|
7200
|
+
name = formattedName.givenname;
|
|
7201
|
+
} else if (this.displayName === "surname") {
|
|
7202
|
+
name = `${formattedName.surname}`;
|
|
7203
|
+
}
|
|
7204
|
+
if (!name || !relation) {
|
|
7205
|
+
return relation ?? "";
|
|
7206
|
+
}
|
|
7207
|
+
return `${name}\u306E${relation}`;
|
|
7208
|
+
}
|
|
7209
|
+
inLaw(relation) {
|
|
7210
|
+
let inLawRelation = relation;
|
|
7211
|
+
Object.keys(InLawsJa).find((pattern) => {
|
|
7212
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
7213
|
+
if (relation?.match(regex)) {
|
|
7214
|
+
inLawRelation = InLawsJa[pattern];
|
|
7215
|
+
return true;
|
|
7216
|
+
}
|
|
7217
|
+
return false;
|
|
7218
|
+
});
|
|
7219
|
+
return inLawRelation ?? "";
|
|
7220
|
+
}
|
|
7221
|
+
relationType(relation) {
|
|
7222
|
+
if (!relation || !this.pathN?.relation) {
|
|
7223
|
+
return relation ?? "";
|
|
7224
|
+
}
|
|
7225
|
+
return `${this.pathN.relation}\u306E${relation}`;
|
|
7226
|
+
}
|
|
7227
|
+
};
|
|
7228
|
+
|
|
7229
|
+
// src/kinship-translator/patterns.zh.ts
|
|
7230
|
+
var InLawsZh = {
|
|
7231
|
+
"(\u5B50\u5973|\u5973\u513F|\u513F\u5B50)\u7684\u914D\u5076": "\u513F\u5AB3/\u5973\u5A7F",
|
|
7232
|
+
"(\u5B50\u5973|\u5973\u513F|\u513F\u5B50)\u7684\u59BB\u5B50": "\u513F\u5AB3",
|
|
7233
|
+
"(\u5B50\u5973|\u5973\u513F|\u513F\u5B50)\u7684\u4E08\u592B": "\u5973\u5A7F",
|
|
7234
|
+
"(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u6BCD\u4EB2": "\u5CB3\u6BCD/\u5A46\u5A46",
|
|
7235
|
+
"(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u7236\u4EB2": "\u5CB3\u7236/\u516C\u516C",
|
|
7236
|
+
"(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u7236\u6BCD": "\u5CB3\u7236\u5CB3\u6BCD/\u516C\u516C\u5A46\u5A46",
|
|
7237
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u5144\u5F1F\u59D0\u59B9|\u59D0\u59B9|\u5144\u5F1F)\u7684\u59BB\u5B50": "\u5AC2\u5B50/\u5F1F\u59B9",
|
|
7238
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u5144\u5F1F\u59D0\u59B9|\u59D0\u59B9|\u5144\u5F1F)\u7684\u4E08\u592B": "\u59D0\u592B/\u59B9\u592B",
|
|
7239
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u5144\u5F1F\u59D0\u59B9|\u59D0\u59B9|\u5144\u5F1F)\u7684\u914D\u5076": "\u59FB\u4EB2\u5144\u5F1F\u59D0\u59B9",
|
|
7240
|
+
"(\u5F02\u7236\u6BCD\u7684)?\u59D0\u59B9\u7684(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)": "\u59D0\u592B/\u59B9\u592B",
|
|
7241
|
+
"(\u5F02\u7236\u6BCD\u7684)?\u5144\u5F1F\u7684(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)": "\u5AC2\u5B50/\u5F1F\u59B9",
|
|
7242
|
+
"(\u5F02\u7236\u6BCD\u7684)?\u5144\u5F1F\u59D0\u59B9\u7684(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)": "\u59FB\u4EB2\u5144\u5F1F\u59D0\u59B9",
|
|
7243
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u59D0\u59B9": "\u59D1\u5B50/\u59E8\u5B50",
|
|
7244
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u5144\u5F1F": "\u5927\u4F2F/\u5C0F\u53D4/\u5185\u5144/\u5185\u5F1F",
|
|
7245
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u5144\u5F1F\u59D0\u59B9": "\u59FB\u4EB2\u5144\u5F1F\u59D0\u59B9"
|
|
7246
|
+
};
|
|
7247
|
+
|
|
7248
|
+
// src/kinship-translator/kinship-translator.zh.ts
|
|
7249
|
+
var sexOf3 = (person) => {
|
|
7250
|
+
if (person?.isMale?.()) {
|
|
7251
|
+
return "m";
|
|
7252
|
+
}
|
|
7253
|
+
if (person?.isFemale?.()) {
|
|
7254
|
+
return "f";
|
|
7255
|
+
}
|
|
7256
|
+
return "n";
|
|
7257
|
+
};
|
|
7258
|
+
var pick2 = (sex, male, female, neutral) => {
|
|
7259
|
+
if (sex === "m") {
|
|
7260
|
+
return male;
|
|
7261
|
+
}
|
|
7262
|
+
if (sex === "f") {
|
|
7263
|
+
return female;
|
|
7264
|
+
}
|
|
7265
|
+
return neutral;
|
|
7266
|
+
};
|
|
7267
|
+
var lineal2 = (level, sex, kind) => {
|
|
7268
|
+
const L = Math.max(1, level);
|
|
7269
|
+
if (kind === "asc") {
|
|
7270
|
+
if (L <= 1) {
|
|
7271
|
+
return pick2(sex, "\u7236\u4EB2", "\u6BCD\u4EB2", "\u7236\u6BCD");
|
|
7272
|
+
}
|
|
7273
|
+
if (L === 2) {
|
|
7274
|
+
return pick2(sex, "\u7956\u7236", "\u7956\u6BCD", "\u7956\u7236\u6BCD");
|
|
7275
|
+
}
|
|
7276
|
+
if (L === 3) {
|
|
7277
|
+
return pick2(sex, "\u66FE\u7956\u7236", "\u66FE\u7956\u6BCD", "\u66FE\u7956\u7236\u6BCD");
|
|
7278
|
+
}
|
|
7279
|
+
if (L === 4) {
|
|
7280
|
+
return pick2(sex, "\u9AD8\u7956\u7236", "\u9AD8\u7956\u6BCD", "\u9AD8\u7956\u7236\u6BCD");
|
|
7281
|
+
}
|
|
7282
|
+
return pick2(sex, `${L}\u4E16\u7956`, `${L}\u4E16\u7956\u6BCD`, `${L}\u4E16\u7956\u7236\u6BCD`);
|
|
7283
|
+
}
|
|
7284
|
+
if (L <= 1) {
|
|
7285
|
+
return pick2(sex, "\u513F\u5B50", "\u5973\u513F", "\u5B50\u5973");
|
|
7286
|
+
}
|
|
7287
|
+
if (L === 2) {
|
|
7288
|
+
return pick2(sex, "\u5B59\u5B50", "\u5B59\u5973", "\u5B59\u5B50\u5973");
|
|
7289
|
+
}
|
|
7290
|
+
if (L === 3) {
|
|
7291
|
+
return pick2(sex, "\u66FE\u5B59", "\u66FE\u5B59\u5973", "\u66FE\u5B59\u5B50\u5973");
|
|
7292
|
+
}
|
|
7293
|
+
if (L === 4) {
|
|
7294
|
+
return pick2(sex, "\u7384\u5B59", "\u7384\u5B59\u5973", "\u7384\u5B59\u5B50\u5973");
|
|
7295
|
+
}
|
|
7296
|
+
return pick2(sex, `${L}\u4E16\u5B59`, `${L}\u4E16\u5B59\u5973`, `${L}\u4E16\u5B59\u5B50\u5973`);
|
|
7297
|
+
};
|
|
7298
|
+
var cousinPlain2 = (degree, sex) => {
|
|
7299
|
+
if (degree <= 1) {
|
|
7300
|
+
return pick2(sex, "\u5802\u8868\u5144\u5F1F", "\u5802\u8868\u59D0\u59B9", "\u5802\u8868\u4EB2");
|
|
7301
|
+
}
|
|
7302
|
+
if (degree === 2) {
|
|
7303
|
+
return pick2(sex, "\u4ECE\u5802\u8868\u5144\u5F1F", "\u4ECE\u5802\u8868\u59D0\u59B9", "\u4ECE\u5802\u8868\u4EB2");
|
|
7304
|
+
}
|
|
7305
|
+
return pick2(
|
|
7306
|
+
sex,
|
|
7307
|
+
`${degree}\u4EE3\u5802\u8868\u5144\u5F1F`,
|
|
7308
|
+
`${degree}\u4EE3\u5802\u8868\u59D0\u59B9`,
|
|
7309
|
+
`${degree}\u4EE3\u5802\u8868\u4EB2`
|
|
7310
|
+
);
|
|
7311
|
+
};
|
|
7312
|
+
var KinshipTranslatorZh = class extends KinshipTranslatorBasic {
|
|
7313
|
+
indirect() {
|
|
7314
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7315
|
+
if (degree > 0) {
|
|
7316
|
+
degree = degree - 1;
|
|
7317
|
+
}
|
|
7318
|
+
return cousinPlain2(degree, sexOf3(this.personN));
|
|
7319
|
+
}
|
|
7320
|
+
removal() {
|
|
7321
|
+
const level = this.pathN?.level ?? 0;
|
|
7322
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7323
|
+
if (degree > 0) {
|
|
7324
|
+
degree = degree - 1;
|
|
7325
|
+
}
|
|
7326
|
+
if (!degree) {
|
|
7327
|
+
return level < 0 ? this.nibling() : this.auncle();
|
|
7328
|
+
}
|
|
7329
|
+
const removed = Math.abs(level);
|
|
7330
|
+
return `${cousinPlain2(degree, sexOf3(this.personN))}\uFF08\u9694${removed}\u4EE3\uFF09`;
|
|
7331
|
+
}
|
|
7332
|
+
auncle() {
|
|
7333
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7334
|
+
const sex = sexOf3(this.personN);
|
|
7335
|
+
if (level <= 2) {
|
|
7336
|
+
return pick2(sex, "\u53D4\u53D4", "\u963F\u59E8", "\u53D4\u4F2F/\u59D1\u59E8");
|
|
7337
|
+
}
|
|
7338
|
+
if (level === 3) {
|
|
7339
|
+
return pick2(sex, "\u4F2F\u53D4\u7956\u7236", "\u59D1\u7956\u6BCD", "\u4F2F\u53D4\u7956\u7236\u6BCD");
|
|
7340
|
+
}
|
|
7341
|
+
return pick2(
|
|
7342
|
+
sex,
|
|
7343
|
+
`${level - 2}\u4EE3\u524D\u7684\u53D4\u53D4`,
|
|
7344
|
+
`${level - 2}\u4EE3\u524D\u7684\u963F\u59E8`,
|
|
7345
|
+
`${level - 2}\u4EE3\u524D\u7684\u53D4\u4F2F/\u59D1\u59E8`
|
|
7346
|
+
);
|
|
7347
|
+
}
|
|
7348
|
+
nibling() {
|
|
7349
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7350
|
+
const sex = sexOf3(this.personN);
|
|
7351
|
+
if (level <= 2) {
|
|
7352
|
+
return pick2(sex, "\u4F84\u5B50", "\u4F84\u5973", "\u4F84\u5B50\u5973");
|
|
7353
|
+
}
|
|
7354
|
+
if (level === 3) {
|
|
7355
|
+
return pick2(sex, "\u4F84\u5B59", "\u4F84\u5B59\u5973", "\u4F84\u5B59\u5B50\u5973");
|
|
7356
|
+
}
|
|
7357
|
+
return pick2(
|
|
7358
|
+
sex,
|
|
7359
|
+
`${level - 2}\u4EE3\u4E0B\u7684\u4F84\u5B50`,
|
|
7360
|
+
`${level - 2}\u4EE3\u4E0B\u7684\u4F84\u5973`,
|
|
7361
|
+
`${level - 2}\u4EE3\u4E0B\u7684\u4F84\u5B50\u5973`
|
|
7362
|
+
);
|
|
7363
|
+
}
|
|
7364
|
+
parent() {
|
|
7365
|
+
return lineal2(
|
|
7366
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7367
|
+
sexOf3(this.personN),
|
|
7368
|
+
"asc"
|
|
7369
|
+
);
|
|
7370
|
+
}
|
|
7371
|
+
child() {
|
|
7372
|
+
return lineal2(
|
|
7373
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7374
|
+
sexOf3(this.personN),
|
|
7375
|
+
"desc"
|
|
7376
|
+
);
|
|
7377
|
+
}
|
|
7378
|
+
sibling() {
|
|
7379
|
+
return pick2(sexOf3(this.personN), "\u5144\u5F1F", "\u59D0\u59B9", "\u5144\u5F1F\u59D0\u59B9");
|
|
7380
|
+
}
|
|
7381
|
+
halfBlood(relation) {
|
|
7382
|
+
if (!relation || !this.isHalfBlood) {
|
|
7383
|
+
return relation ?? "";
|
|
7384
|
+
}
|
|
7385
|
+
return `\u5F02\u7236\u6BCD\u7684${relation}`;
|
|
7386
|
+
}
|
|
7387
|
+
spouse() {
|
|
7388
|
+
return pick2(sexOf3(this.personN), "\u4E08\u592B", "\u59BB\u5B50", "\u914D\u5076");
|
|
7389
|
+
}
|
|
7390
|
+
ofSpouse(relation) {
|
|
7391
|
+
if (!relation) {
|
|
7392
|
+
return "";
|
|
7393
|
+
}
|
|
7394
|
+
const spouseType = pick2(
|
|
7395
|
+
sexOf3(this.path?.[1].indi),
|
|
7396
|
+
"\u4E08\u592B",
|
|
7397
|
+
"\u59BB\u5B50",
|
|
7398
|
+
"\u914D\u5076"
|
|
7399
|
+
);
|
|
7400
|
+
return `${spouseType}\u7684${relation}`;
|
|
7401
|
+
}
|
|
7402
|
+
spouseOf(relation) {
|
|
7403
|
+
if (!relation) {
|
|
7404
|
+
return "";
|
|
7405
|
+
}
|
|
7406
|
+
const spouse = this.path?.[this.path.length - 1].indi;
|
|
7407
|
+
const spouseType = pick2(sexOf3(spouse), "\u4E08\u592B", "\u59BB\u5B50", "\u914D\u5076");
|
|
7408
|
+
return `${relation}\u7684${spouseType}`;
|
|
7409
|
+
}
|
|
7410
|
+
of(relation) {
|
|
7411
|
+
const formattedName = nameFormatter(this.path?.[0]?.indi, {
|
|
7412
|
+
nameOrder: "last-first"
|
|
7413
|
+
});
|
|
7414
|
+
let name = formattedName.inOrder.filter(Boolean).join(" ");
|
|
7415
|
+
if (this.displayName === "none") {
|
|
7416
|
+
name = "";
|
|
7417
|
+
} else if (this.displayName === "givenname") {
|
|
7418
|
+
name = formattedName.givenname;
|
|
7419
|
+
} else if (this.displayName === "surname") {
|
|
7420
|
+
name = `${formattedName.surname}`;
|
|
7421
|
+
}
|
|
7422
|
+
if (!name || !relation) {
|
|
7423
|
+
return relation ?? "";
|
|
7424
|
+
}
|
|
7425
|
+
return `${name}\u7684${relation}`;
|
|
7426
|
+
}
|
|
7427
|
+
inLaw(relation) {
|
|
7428
|
+
let inLawRelation = relation;
|
|
7429
|
+
Object.keys(InLawsZh).find((pattern) => {
|
|
7430
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
7431
|
+
if (relation?.match(regex)) {
|
|
7432
|
+
inLawRelation = InLawsZh[pattern];
|
|
7433
|
+
return true;
|
|
7434
|
+
}
|
|
7435
|
+
return false;
|
|
7436
|
+
});
|
|
7437
|
+
return inLawRelation ?? "";
|
|
7438
|
+
}
|
|
7439
|
+
relationType(relation) {
|
|
7440
|
+
if (!relation || !this.pathN?.relation) {
|
|
7441
|
+
return relation ?? "";
|
|
7442
|
+
}
|
|
7443
|
+
return `${this.pathN.relation}${relation}`;
|
|
7444
|
+
}
|
|
7445
|
+
};
|
|
7446
|
+
|
|
6988
7447
|
// src/kinship-translator/kinship-translator.ts
|
|
6989
7448
|
var KinshipTranslator = class {
|
|
6990
7449
|
constructor(person1, person2, lang = "en", entirePath, displayName = "givenname") {
|