initial commit

This commit is contained in:
2026-02-09 19:04:19 -08:00
commit f92b57c7b6
531 changed files with 196294 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
/*
* Copyright (C) 2025 Yomitan Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {basicTextProcessorOptions, removeAlphabeticDiacritics} from '../text-processors.js';
/** @type {import('language').TextProcessor<boolean>} */
export const convertLatinToGreek = {
name: 'Convert latin characters to greek',
description: 'a → α, A → Α, b → β, B → Β, etc.',
options: basicTextProcessorOptions,
process: (str, setting) => {
return setting ? latinToGreek(str) : str;
},
};
/**
* @param {string} latin
* @returns {string}
*/
export function latinToGreek(latin) {
latin = removeAlphabeticDiacritics.process(latin, true);
const singleMap = {
a: 'α',
b: 'β',
g: 'γ',
d: 'δ',
e: 'ε',
z: 'ζ',
ē: 'η',
i: 'ι',
k: 'κ',
l: 'λ',
m: 'μ',
n: 'ν',
x: 'ξ',
o: 'ο',
p: 'π',
r: 'ρ',
s: 'σ',
t: 'τ',
u: 'υ',
ō: 'ω',
A: 'Α',
B: 'Β',
G: 'Γ',
D: 'Δ',
E: 'Ε',
Z: 'Ζ',
Ē: 'Η',
I: 'Ι',
K: 'Κ',
L: 'Λ',
M: 'Μ',
N: 'Ν',
X: 'Ξ',
O: 'Ο',
P: 'Π',
R: 'Ρ',
S: 'Σ',
T: 'Τ',
U: 'Υ',
Ō: 'Ω',
};
const doubleMap = {
th: 'θ',
ph: 'φ',
ch: 'χ',
ps: 'ψ',
Th: 'Θ',
Ph: 'Φ',
Ch: 'Χ',
Ps: 'Ψ',
};
let result = latin;
for (const [double, greek] of Object.entries(doubleMap)) {
result = result.replace(new RegExp(double, 'g'), greek);
}
// Handle basic character replacements
for (const [single, greek] of Object.entries(singleMap)) {
result = result.replace(new RegExp(single, 'g'), greek);
}
// Handle final sigma
result = result.replace(/σ$/, 'ς');
return result;
}

View File

@@ -0,0 +1,207 @@
/*
* Copyright (C) 2025 Yomitan Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {suffixInflection} from '../language-transforms.js';
const conditions = {
v: {
name: 'Verb',
isDictionaryForm: true,
},
n: {
name: 'Noun',
isDictionaryForm: true,
},
adj: {
name: 'Adjective',
isDictionaryForm: true,
},
};
/** @type {import('language-transformer').LanguageTransformDescriptor<keyof typeof conditions>} */
export const ancientGreekTransforms = {
language: 'grc',
conditions,
transforms: {
// inflections
// verbs - active voice
'2nd person singular present active indicative': {
name: '2nd person singular present active indicative',
rules: [
suffixInflection('εις', 'ω', [], ['v']),
suffixInflection('εις', 'εω', [], ['v']),
],
},
'3rd person singular present active indicative': {
name: '3rd person singular present active indicative',
rules: [
suffixInflection('ει', 'ω', [], ['v']),
suffixInflection('ει', 'εω', [], ['v']),
],
},
'1st person plural present active indicative': {
name: '1st person plural present active indicative',
rules: [
suffixInflection('ομεν', 'ω', [], ['v']),
],
},
'2nd person plural present active indicative': {
name: '2nd person plural present active indicative',
rules: [
suffixInflection('ετε', 'ω', [], ['v']),
],
},
'3rd person plural present active indicative': {
name: '3rd person plural present active indicative',
rules: [
suffixInflection('ουσι', 'ω', [], ['v']),
suffixInflection('ουσιν', 'ω', [], ['v']),
],
},
// verbs - middle voice
'2nd person singular present middle indicative': {
name: '2nd person singular present middle indicative',
rules: [
suffixInflection('ῃ', 'ομαι', [], ['v']),
suffixInflection('ει', 'ομαι', [], ['v']),
],
},
'3rd person singular present middle indicative': {
name: '3rd person singular present middle indicative',
rules: [
suffixInflection('εται', 'ομαι', [], ['v']),
],
},
'1st person plural present middle indicative': {
name: '1st person plural present middle indicative',
rules: [
suffixInflection('ομεθα', 'ομαι', [], ['v']),
],
},
'2nd person plural present middle indicative': {
name: '2nd person plural present middle indicative',
rules: [
suffixInflection('εσθε', 'ομαι', [], ['v']),
],
},
'3rd person plural present middle indicative': {
name: '3rd person plural present middle indicative',
rules: [
suffixInflection('ονται', 'ομαι', [], ['v']),
],
},
// nouns
'genitive singular': {
name: 'genitive singular',
rules: [
suffixInflection('ου', 'ος', [], ['n']),
suffixInflection('ας', 'α', [], ['n']),
suffixInflection('ου', 'ας', [], ['n']),
suffixInflection('ου', 'ον', [], ['n']),
suffixInflection('ης', 'η', [], ['n']),
],
},
'dative singular': {
name: 'dative singular',
rules: [
suffixInflection('ω', 'ος', [], ['n']),
suffixInflection('α', 'ας', [], ['n']),
suffixInflection('ω', 'ον', [], ['n']),
],
},
'accusative singular': {
name: 'accusative singular',
rules: [
suffixInflection('ον', 'ος', [], ['n']),
suffixInflection('αν', 'α', [], ['n']),
suffixInflection('αν', 'ας', [], ['n']),
suffixInflection('ην', 'η', [], ['n']),
],
},
'vocative singular': {
name: 'vocative singular',
rules: [
suffixInflection('ε', 'ος', [], ['n']),
suffixInflection('α', 'ας', [], ['n']),
suffixInflection('η', 'η', [], ['n']),
],
},
'nominative plural': {
name: 'nominative plural',
rules: [
suffixInflection('οι', 'ος', [], ['n']),
suffixInflection('αι', 'α', [], ['n']),
suffixInflection('αι', 'ας', [], ['n']),
suffixInflection('α', 'ον', [], ['n']),
suffixInflection('αι', 'η', [], ['n']),
],
},
'genitive plural': {
name: 'genitive plural',
rules: [
suffixInflection('ων', 'ος', [], ['n']),
suffixInflection('ων', 'α', [], ['n']),
suffixInflection('ων', 'ας', [], ['n']),
suffixInflection('ων', 'ον', [], ['n']),
suffixInflection('ων', 'η', [], ['n']),
],
},
'dative plural': {
name: 'dative plural',
rules: [
suffixInflection('οις', 'ος', [], ['n']),
suffixInflection('αις', 'α', [], ['n']),
suffixInflection('αις', 'ας', [], ['n']),
suffixInflection('οις', 'ον', [], ['n']),
suffixInflection('αις', 'η', [], ['n']),
],
},
'accusative plural': {
name: 'accusative plural',
rules: [
suffixInflection('ους', 'ος', [], ['n']),
suffixInflection('ας', 'α', [], ['n']),
suffixInflection('α', 'ον', [], ['n']),
suffixInflection('ας', 'η', [], ['n']),
],
},
'vocative plural': {
name: 'vocative plural',
rules: [
suffixInflection('οι', 'ος', [], ['n']),
suffixInflection('αι', 'α', [], ['n']),
suffixInflection('αι', 'ας', [], ['n']),
suffixInflection('α', 'ον', [], ['n']),
suffixInflection('αι', 'η', [], ['n']),
],
},
// adjectives
'accusative singular masculine': {
name: 'accusative singular masculine',
rules: [
suffixInflection('ον', 'ος', [], ['adj']),
],
},
// word formation
'nominalization': {
name: 'nominalization',
rules: [
suffixInflection('ος', 'εω', [], ['v']),
],
},
},
};