This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/src/data.js

81 lines
2.5 KiB
JavaScript
Raw Normal View History

2020-08-05 11:24:05 -07:00
import {Source, Example, NounTemplate} from './classes'
import { buildDict, buildList } from './helpers';
import { parseTemplates, getTemplate } from './buildTemplate';
import templatesRaw from '../data/templates.tsv';
export const templates = parseTemplates(templatesRaw);
import examplesRaw from '../data/examples.tsv';
export const examples = buildList(function* () {
for (let e of examplesRaw) {
yield new Example(
Example.parse(e.singular),
Example.parse(e.plural || e.singular),
e.isHonorific,
);
}
});
import sourcesRaw from '../data/sources.tsv';
export const sources = buildDict(function* () {
for (let s of sourcesRaw) {
yield [
s.key,
new Source(
s.type,
s.author,
s.title,
s.extra,
s.year,
s.fragments ? s.fragments.replace(/\|/g, '\n').split('@') : [],
s.comment,
s.link,
)
];
}
});
export const sourcesForMultipleForms = {
2020-08-20 01:15:42 -07:00
'on&ona': ['genderneutralizacja', 'niebTlum', 'jurewicz', 'krolowaZimy', 'mlotThora', 'statekUmarlych', 'starWarsKoPo'],
2020-09-01 02:47:41 -07:00
'ona&onu': ['liniaOporuMix'],
2020-09-05 05:17:33 -07:00
'ono/jego&ono/jej': ['kazmierczak'],
}
2020-07-26 06:15:56 -07:00
export const getSources = (selectedTemplate) => {
if (!selectedTemplate) {
return {};
}
let sources = {};
for (let multiple in sourcesForMultipleForms) {
if (sourcesForMultipleForms.hasOwnProperty(multiple)) {
if (multiple === selectedTemplate.canonicalName) {
sources[multiple] = sourcesForMultipleForms[multiple];
}
}
}
for (let option of selectedTemplate.nameOptions()) {
const template = getTemplate(templates, option);
if (template && template.sources.length) {
sources[option] = template.sources;
}
}
return sources;
}
2020-08-05 11:24:05 -07:00
2020-09-04 08:07:32 -07:00
import nounTemplatesRaw from '../data/nounTemplates.tsv';
export const nounTemplates = buildList(function* () {
for (let t of nounTemplatesRaw) {
yield new NounTemplate(
t.masc.replace(/-/g, '').split('/'),
t.fem.replace(/-/g, '').split('/'),
t.neutr.replace(/-/g, '').split('/'),
t.mascPl.replace(/-/g, '').split('/'),
t.femPl.replace(/-/g, '').split('/'),
t.neutrPl.replace(/-/g, '').split('/'),
);
}
});
2020-08-05 11:24:05 -07:00
export const separators = ['ono/jego', 'onu/jenu', 'oni/ich', 'onæ/jæ', 'vono/vego', 'on&ona'];