initial commit
This commit is contained in:
parent
8c48ef3f72
commit
0cf40fa6e5
3 changed files with 484 additions and 0 deletions
263
conj.ts
Normal file
263
conj.ts
Normal file
|
@ -0,0 +1,263 @@
|
|||
var conjNoList = (<HTMLInputElement> document.getElementById('conj-no'));
|
||||
var conjOptDiv = document.getElementById('conj1-opt-div');
|
||||
var startConj = document.getElementById('start-conjugate');
|
||||
var original = (<HTMLInputElement> document.getElementById('original'));
|
||||
var conjStem = (<HTMLInputElement> document.getElementById('conj-stem'));
|
||||
|
||||
var conj_no = parseInt(conjNoList.value);
|
||||
var type_of_conj1 = null;
|
||||
|
||||
var typesOfConj1Rads = document.getElementsByName("types-of-conj1");
|
||||
|
||||
for(var i = 0; i < typesOfConj1Rads.length; i++) {
|
||||
let radValue = (<HTMLInputElement> typesOfConj1Rads[i]).value;
|
||||
typesOfConj1Rads[i].addEventListener('change', () => {
|
||||
type_of_conj1 = radValue;
|
||||
})
|
||||
}
|
||||
|
||||
conjNoList.addEventListener('change', (event) => {
|
||||
conj_no = parseInt(conjNoList.value);
|
||||
if (conj_no == 2) {
|
||||
conjOptDiv.style.display = "none";
|
||||
} else {
|
||||
conjOptDiv.style.display = "block";
|
||||
}
|
||||
})
|
||||
|
||||
function emptyString(str : string){
|
||||
var isContainedSpace = str.match(/^[ \t\n\r]+$/);
|
||||
var isReallyEmpty = (str == "");
|
||||
return isReallyEmpty || isContainedSpace;
|
||||
}
|
||||
|
||||
startConj.addEventListener('click', (event) => {
|
||||
var original_text = original.value;
|
||||
var conjstem_text = conjStem.value;
|
||||
if (emptyString(original_text) && emptyString(conjstem_text)){
|
||||
alert("您輸入的是空字串,請重新輸入。")
|
||||
}
|
||||
else{
|
||||
if (emptyString(conjstem_text)){
|
||||
conjstem_text = original_text;
|
||||
};
|
||||
generateConj(original_text, conjstem_text, conj_no);
|
||||
}});
|
||||
|
||||
function checkedIfBroadEnd(str_array : string[]){
|
||||
for (var i = str_array.length - 1; i >=0; i--){
|
||||
|
||||
if (str_array[i].match(/[aouáóúAOUÁÓÚ]/)){
|
||||
return true;
|
||||
}
|
||||
else if (str_array[i].match(/[eiéíEIÉÍ]/)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
let first_conj =
|
||||
{ "broad" :
|
||||
{
|
||||
"pres" : ["aim", "air", "ann", "aimíd", "ann sibh", "aid", null, "tar"],
|
||||
"past" : ["as", "ais", null, "amair", "abhair", "adar", null, "adh"],
|
||||
"pa_ha" : ["ainn", "tá", "adh", "aimís", "adh sibh", "aidís", "taí"],
|
||||
"futu" : ["fad", "fair", "faidh", "faimíd", "faidh sibh", "faid", "far"],
|
||||
"cond" : ["fainn", "fá", "fadh", "faimís", "fadh sibh", "faidís", "faí"],
|
||||
"pr_su" : ["ad", "air", "aidh", "aimíd", "aidh sibh", "aid", null],
|
||||
"impe" : ["aim", null, "adh", "aimís", "aidh", "aidís", null],
|
||||
},
|
||||
"slender" :
|
||||
{
|
||||
"pres" : ["im", "ir", "eann", "imíd", "eann sibh", "id", null, "tear"],
|
||||
"past" : ["eas", "is", null, "eamair", "eabhair", "eadar", null, "eadh"],
|
||||
"pa_ha" : ["inn", "teá", "eadh", "imís", "eadh sibh", "idís", "tí"],
|
||||
"futu" : ["fead", "fir", "fidh", "fimíd", "fidh sibh", "fid", "fear"],
|
||||
"cond" : ["finn", "feá", "feadh", "fimís", "feadh sibh", "fidís", "fí"],
|
||||
"pr_su" : ["ead", "ir", "idh", "imíd", "idh sibh", "id", null],
|
||||
"impe" : ["im", null, "eadh", "imís", "idh", "idís", null],
|
||||
}
|
||||
}
|
||||
|
||||
let second_conj =
|
||||
{ "broad" :
|
||||
{
|
||||
"pres" : ["ím", "ír", "íonn", "aimíd", "ann sibh", "aid", null, "tar"],
|
||||
"past" : ["as", "ais", null, "amair", "abhair", "adar", null, "adh"],
|
||||
"pa_ha" : ["ainn", "tá", "adh", "aimís", "adh sibh", "aidís", "taí"],
|
||||
"futu" : ["fad", "fair", "faidh", "faimíd", "faidh sibh", "faid", "far"],
|
||||
"cond" : ["fainn", "fá", "fadh", "faimís", "fadh sibh", "faidís", "faí"],
|
||||
"pr_su" : ["ad", "air", "aidh", "aimíd", "aidh sibh", "aid", null],
|
||||
"impe" : ["aim", null, "adh", "aimís", "aidh", "aidís", null],
|
||||
},
|
||||
"slender" :
|
||||
{
|
||||
"pres" : ["ím", "ír", "íonn", "ímíd", "íonn sibh", "íd", null, "ítear"],
|
||||
"pa_ha" : ["ínn", "íteá", "íodh", "ímís", "íodh sibh", "ídís", "ití"],
|
||||
"futu" : ["eod", "eoir", "eoidh", "eoimíd", "eoidh sibh", "eoid", "eofar"],
|
||||
"cond" : ["eoinn", "eofá", "eodh", "eoimís", "eodh sibh", "eoidís", "eofaí"],
|
||||
"pr_su" : ["íod", "ír", "ídh", "ímíd", "ídh sibh", "íd", null],
|
||||
"impe" : ["ím", null, "íodh", "ímís", "ídh", "ídís", null],
|
||||
}
|
||||
}
|
||||
|
||||
var ighType;
|
||||
|
||||
// values for ighType
|
||||
let shortVowelEnd = 0;
|
||||
let longBroadEnd = 1;
|
||||
let longSlenderEnd = 2;
|
||||
|
||||
let firstConjIgh =
|
||||
{ 0 : // shortVowelEnd
|
||||
{
|
||||
"pres" : ["ím", "ír", "íonn", "ímíd", "íonn sibh", "íd", null, "itear"],
|
||||
"past" : ["íos", "ís", null, "íomair", "íobhair", "íodar", null, "íodh"],
|
||||
"pa_ha" : ["ínn", "iteá", "íodh", "ímís", "íodh sibh", "ídís", "ití"],
|
||||
"futu" : ["ífead", "ífir", "ífidh", "ífimíd", "ífidh sibh", "ífid", "ífear"],
|
||||
"cond" : ["ífinn", "ífeá", "ífeadh", "ífimís", "ífeadh sibh", "ífidís", "ífí"],
|
||||
"pr_su" : ["íod", "ír", "ídh", "ímíd", "ídh sibh", "íd", null],
|
||||
"impe" : ["ím", null, "íodh", "ímís", "ídh", "ídís", null],
|
||||
},
|
||||
1 : // longBroadEnd
|
||||
{
|
||||
"pres" : ["im", "ir", "nn", "imíd", "nn sibh", "id", null, "tar"],
|
||||
"past" : ["s", "is", null, "mair", "bhair", "dar", null, "dh"],
|
||||
"pa_ha" : ["inn", "iteá", "dh", "imís", "dh sibh", "idís", "ití"],
|
||||
"futu" : ["fad", "fair", "faidh", "faimíd", "faidh sibh", "faid", "far"],
|
||||
"cond" : ["fainn", "fá", "fadh", "faimís", "fadh sibh", "faidís", "faí"],
|
||||
"pr_su" : ["d", "ir", "idh", "imíd", "idh sibh", "id", null],
|
||||
"impe" : ["im", null, "dh", "imís", "idh", "idís", null],
|
||||
},
|
||||
2 : // longSlenderEnd
|
||||
{
|
||||
"pres" : ["im", "ir", "ann", "imíd", "ann sibh", "id", null, "tear"],
|
||||
"past" : ["as", "is", null, "amair", "abhair", "adar", null, "adh"],
|
||||
"pa_ha" : ["inn", "iteá", "adh", "imís", "adh sibh", "idís", "tí"],
|
||||
"futu" : ["ifead", "ifir", "ifidh", "ifimíd", "ifidh sibh", "ifid", "ifear"],
|
||||
"cond" : ["ifinn", "ifeá", "ifeadh", "ifimís", "ifeadh sibh", "ifidís", "ifí"],
|
||||
"pr_su" : ["ad", "ir", "idh", "imíd", "idh sibh", "id", null],
|
||||
"impe" : ["im", null, "adh", "imís", "idh", "idís", null],
|
||||
}
|
||||
}
|
||||
|
||||
function generateConj(orig_txt : string, stem_txt : string, conj_no : Number){
|
||||
var impe_ls = document.getElementById("impe");
|
||||
var past_ls = document.getElementById("past");
|
||||
var _2sgimpe = impe_ls.getElementsByTagName("td")[2];
|
||||
var _3sgpast = past_ls.getElementsByTagName("td")[3];
|
||||
_2sgimpe.innerHTML = orig_txt;
|
||||
_3sgpast.innerHTML = orig_txt;
|
||||
|
||||
|
||||
// Gael => ['G', 'ae', 'l']; ithim => [i, th]
|
||||
var stem_txt_splitted = stem_txt.split(/([aA][eE]|[bcdfgmpstBCDFGMPST][hH]|[A-Za-z])/).filter(text => text);
|
||||
var isBroadEnd = checkedIfBroadEnd(stem_txt_splitted);
|
||||
if (conj_no == 1){
|
||||
|
||||
if (type_of_conj1 == "igh"){
|
||||
if (!orig_txt.match('[iI][gG][hH]$')){
|
||||
alert("原來的詞不以 -igh 結尾。");
|
||||
}
|
||||
|
||||
if (stem_txt.match('([áóúÁÓÚ]|[eE][oO]|[uU][aA])$')){
|
||||
ighType = longBroadEnd;
|
||||
}
|
||||
else if (stem_txt.match('[éÉ]$')){
|
||||
ighType = longSlenderEnd;
|
||||
}else{
|
||||
ighType = shortVowelEnd;
|
||||
}
|
||||
|
||||
|
||||
var suffixTable = firstConjIgh[ighType];
|
||||
|
||||
fillTablesInner(suffixTable);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (type_of_conj1 == "ail"){
|
||||
|
||||
if (!orig_txt.match('[áÁ][iI][lL]$')){
|
||||
alert("原來的詞不以 -áil 結尾。");
|
||||
}
|
||||
|
||||
firstConjFillTheArray();
|
||||
|
||||
|
||||
// convert stem -ál to -áil
|
||||
var stemAilLeft = stem_txt.substring(0, stem_txt.length-1);
|
||||
var stemAil;
|
||||
if (stemAilLeft.substring(stemAilLeft.length-1) == 'á'){
|
||||
stemAil = stemAilLeft + 'i' + stem_txt.substring(stem_txt.length-1);
|
||||
}
|
||||
else{
|
||||
stemAil = stemAilLeft + 'I' + stem_txt.substring(stem_txt.length-1);
|
||||
}
|
||||
|
||||
var autoPres = document.getElementById("pres").getElementsByTagName("td")[8];
|
||||
var _2SgPaHa = document.getElementById("pa_ha").getElementsByTagName("td")[2];
|
||||
var autoPaHa = document.getElementById("pa_ha").getElementsByTagName("td")[7];
|
||||
|
||||
var suffixTable = first_conj["slender"];
|
||||
var autoPresSuffix = suffixTable["pres"][7];
|
||||
var _2sgPaHaSuffix = suffixTable["pa_ha"][1];
|
||||
var autoPaHaSuffix = suffixTable["pa_ha"][6];
|
||||
|
||||
autoPres.innerHTML = stemAil + autoPresSuffix;
|
||||
_2SgPaHa.innerHTML = stemAil + _2sgPaHaSuffix;
|
||||
autoPaHa.innerHTML = stemAil + autoPaHaSuffix;
|
||||
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
// general 1st vonj verbs
|
||||
firstConjFillTheArray();
|
||||
|
||||
// irreagularity of the pres. auto. form of lean
|
||||
if (stem_txt == "lean"){
|
||||
var relPres = document.getElementById("pres").getElementsByTagName("td")[7];
|
||||
relPres.innerHTML = "leanas";
|
||||
}
|
||||
}
|
||||
|
||||
// general 1st vonj verbs
|
||||
function firstConjFillTheArray() {
|
||||
var suffixTable;
|
||||
if (isBroadEnd) {
|
||||
suffixTable = first_conj["broad"];
|
||||
} else {
|
||||
suffixTable = first_conj["slender"];
|
||||
}
|
||||
|
||||
fillTablesInner(suffixTable);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function fillTablesInner(suffixTable : any) {
|
||||
var suffixTableKeys = Object.keys(suffixTable);
|
||||
|
||||
for (var i = 0; i < suffixTableKeys.length; i++) {
|
||||
var currentSuffixTableKey = suffixTableKeys[i];
|
||||
var personalArray = document.getElementById(currentSuffixTableKey);
|
||||
|
||||
for (var j = 0; j < suffixTable[currentSuffixTableKey].length; j++) {
|
||||
var item = personalArray.getElementsByTagName("td")[1 + j];
|
||||
var currentSuffix = suffixTable[currentSuffixTableKey][j];
|
||||
|
||||
if (currentSuffix != null) {
|
||||
item.innerHTML = stem_txt + currentSuffix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
214
index.html
Normal file
214
index.html
Normal file
|
@ -0,0 +1,214 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Irish Conjugator</title>
|
||||
</head>
|
||||
<body><br>
|
||||
<div>
|
||||
<h1>愛爾蘭語動詞變化產生器</h1>
|
||||
<p><i>Gineadóir Réimniú na Gaeilge</i></p>
|
||||
</div>
|
||||
<div><br>
|
||||
</div>
|
||||
<div>詞彙原形:<input id="original" type="text"></div>
|
||||
<div><br>
|
||||
</div>
|
||||
<div>拿來變化的詞根:<input id="conj-stem" type="text"></div>
|
||||
<div><br>
|
||||
</div>
|
||||
<div>(註:如 imir 拿來變化的詞根是 imr,留空白代表同原形。第一類變化的 -igh 型去掉詞尾 igh,比如:nigh 寫成 n;dóigh 寫成 dó;-áil 型詞尾的 áil 改成 ál)</div>
|
||||
<div><br>
|
||||
</div>
|
||||
<div>詞彙變化編號:
|
||||
<select id="conj-no">
|
||||
<option value="1" selected="true">第一類變化</option>
|
||||
<option value="2">第二類變化</option>
|
||||
</select>
|
||||
</div>
|
||||
<div><br>
|
||||
</div>
|
||||
<div id="conj1-opt-div">第一類變化選項:<br>
|
||||
<form>
|
||||
<p> <input name="types-of-conj1" value="general" checked="checked"
|
||||
type="radio">一般型態</p>
|
||||
<p><input name="types-of-conj1" value="igh" type="radio">-igh型態</p>
|
||||
<p><input name="types-of-conj1" value="ail" type="radio">-áil型態</p>
|
||||
</form>
|
||||
</div>
|
||||
<input id="start-conjugate" value="產生變化" type="button">
|
||||
<h2>動詞變化表</h2>
|
||||
<tb rowspan="6"></tb>
|
||||
<table id="conj-table" width="100%" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>式(態) \ 主詞 </td>
|
||||
<td style="background-color: #ccffff;">1 單 </td>
|
||||
<td>2 單 </td>
|
||||
<td style="background-color: #ffffcc;">3 單<br>
|
||||
(分析式)<sub>5</sub></td>
|
||||
<td style="background-color: #ccffff;">1 複 </td>
|
||||
<td>2 複 </td>
|
||||
<td>3 複 </td>
|
||||
<td>肯定直接關係式<sub>6</sub><br>
|
||||
</td>
|
||||
<td>無人稱<sub>7</sub></td>
|
||||
</tr>
|
||||
<tr id="pres">
|
||||
<td>現在式<br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td style="background-color: #ffffcc;"><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td>同分析式<br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="past">
|
||||
<td>過去式<sub>2</sub><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td style="background-color: #ffffcc;"><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td rowspan="4" colspan="1">
|
||||
<div style="text-align: left;">同分析式</div>
|
||||
<br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="pa_ha">
|
||||
<td>過去習慣式<sub>2</sub> </td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td style="background-color: #ffffcc;"><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="futu">
|
||||
<td>未來式<br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td style="background-color: #ffffcc;"><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="cond">
|
||||
<td>條件態<sub>2,3</sub><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td style="background-color: #ffffcc;"><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="pr_su">
|
||||
<td>現在假設態<sub>4</sub><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td style="background-color: #ffffcc;"><br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td rowspan="3">N/A<br>
|
||||
</td>
|
||||
<td>同現在式 (但子音交替法不同) </td>
|
||||
</tr>
|
||||
<tr id="pa_su">
|
||||
<td>過去假設態<sub>3</sub> </td>
|
||||
<td colspan="6" style="background-color: white;">同過去習慣式(但子音交替法不同)<br>
|
||||
</td>
|
||||
<td>同過去習慣式<br>
|
||||
(但子音交替法不同) </td>
|
||||
</tr>
|
||||
<tr id="impe">
|
||||
<td>命令態<br>
|
||||
</td>
|
||||
<td style="background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td style="background-color: #ffffcc;"><br>
|
||||
</td>
|
||||
<td style="height: 21px; background-color: #ccffff;"><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td><br>
|
||||
</td>
|
||||
<td>同現在式 </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>過去分詞</td>
|
||||
<td colspan="7"><br>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>註:</h3>
|
||||
<ol>
|
||||
<li> 以上動詞變化以凱里 (Ciarraí) 和科克 (Corcaigh) 的芒斯特方言 (Gaelainn na Mumhan, Munster Irish) 為準。參考資料:Cork Irish、reimnigh.net。</li>
|
||||
<li>前面接 do/d',接 do/d' 時動詞要軟音化 (seimhiıú, lenition)(無人稱除外)。d' 接在母音和 fh(軟音化後)前面;do 接在子音前面。</li>
|
||||
<li>前接連接詞 dá 時,動詞要暗音化 (urú, eclipsis)。</li>
|
||||
<li>前接連接詞 go 時,動詞要暗音化。</li>
|
||||
<li>分析式後面接主詞或代名詞比如說第三人稱單數代詞 sé/sí,以表達文意。</li>
|
||||
<li>用於肯定式直接關係子句內。</li>
|
||||
<li>「無人稱」(automous/impersonal),指不特定對象當主詞的情況,可以翻譯為「某某+動詞」。接 do/d' 這個詞不可以讓動詞軟音化。</li>
|
||||
</ol>
|
||||
<p></p>
|
||||
<script content="text/javascript" src="./conj.js"></script>
|
||||
</body>
|
||||
</html>
|
7
tsconfig.json
Normal file
7
tsconfig.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue