mirror of
https://github.com/ZetaKebab/japanese-conjugation-drill.git
synced 2025-01-14 22:08:44 +00:00
Changed to calculate tags automatically.
This commit is contained in:
parent
480b0ce97e
commit
ff1d3fb6b6
236
conjugation/drill.js
Normal file → Executable file
236
conjugation/drill.js
Normal file → Executable file
@ -814,110 +814,110 @@ var words = {
|
|||||||
|
|
||||||
var transformations = [
|
var transformations = [
|
||||||
|
|
||||||
{ from: "negative", to: "dictionary", tags: ["plain", "negative"] },
|
{ from: "negative", to: "dictionary" },
|
||||||
{ from: "past", to: "dictionary", tags: ["plain", "past"] },
|
{ from: "past", to: "dictionary" },
|
||||||
{ from: "polite", to: "dictionary", tags: ["plain", "polite"] },
|
{ from: "polite", to: "dictionary" },
|
||||||
{ from: "te-form", to: "dictionary", tags: ["plain", "te-form"] },
|
{ from: "te-form", to: "dictionary" },
|
||||||
{ from: "potential", to: "dictionary", tags: ["plain", "potential"] },
|
{ from: "potential", to: "dictionary" },
|
||||||
{ from: "imperative", to: "dictionary", tags: ["plain", "imperative"] },
|
{ from: "imperative", to: "dictionary" },
|
||||||
{ from: "causative", to: "dictionary", tags: ["plain", "causative"] },
|
{ from: "causative", to: "dictionary" },
|
||||||
{ from: "passive", to: "dictionary", tags: ["plain", "passive"] },
|
{ from: "passive", to: "dictionary" },
|
||||||
{ from: "progressive" , to: "dictionary", tags: ["plain", "progressive"] },
|
{ from: "progressive", to: "dictionary" },
|
||||||
{ from: "dictionary", to: "negative", tags: ["plain", "negative"] },
|
{ from: "dictionary", to: "negative" },
|
||||||
{ from: "past negative", to: "negative", tags: ["plain", "past", "negative"] },
|
{ from: "past negative", to: "negative" },
|
||||||
{ from: "polite negative", to: "negative", tags: ["plain", "polite", "negative"] },
|
{ from: "polite negative", to: "negative" },
|
||||||
{ from: "te-form negative", to: "negative", tags: ["plain", "te-form", "negative"] },
|
{ from: "te-form negative", to: "negative" },
|
||||||
{ from: "potential negative", to: "negative", tags: ["plain", "potential", "negative"] },
|
{ from: "potential negative", to: "negative" },
|
||||||
{ from: "imperative negative", to: "negative", tags: ["plain", "imperative", "negative"] },
|
{ from: "imperative negative", to: "negative" },
|
||||||
{ from: "causative negative", to: "negative", tags: ["plain", "causative", "negative"] },
|
{ from: "causative negative", to: "negative" },
|
||||||
{ from: "passive negative", to: "negative", tags: ["plain", "passive", "negative"] },
|
{ from: "passive negative", to: "negative" },
|
||||||
{ from: "progressive negative", to: "negative", tags: ["plain", "progressive", "negative"] },
|
{ from: "progressive negative", to: "negative" },
|
||||||
{ from: "dictionary", to: "past", tags: ["plain", "past"] },
|
{ from: "dictionary", to: "past" },
|
||||||
{ from: "past negative" , to: "past", tags: ["plain", "past", "negative"] },
|
{ from: "past negative", to: "past" },
|
||||||
{ from: "polite past", to: "past", tags: ["plain", "polite", "past"] },
|
{ from: "polite past", to: "past" },
|
||||||
{ from: "progressive past", to: "past", tags: ["plain", "progressive", "past"] },
|
{ from: "progressive past", to: "past" },
|
||||||
{ from: "negative", to: "past negative", tags: ["plain", "past", "negative"] },
|
{ from: "negative", to: "past negative" },
|
||||||
{ from: "past", to: "past negative", tags: ["plain", "past", "negative"] },
|
{ from: "past", to: "past negative" },
|
||||||
{ from: "polite past negative", to: "past negative", tags: ["plain", "polite", "past", "negative"] },
|
{ from: "polite past negative", to: "past negative" },
|
||||||
{ from: "progressive past negative", to: "past negative", tags: ["plain", "progressive", "past", "negative"] },
|
{ from: "progressive past negative", to: "past negative" },
|
||||||
{ from: "dictionary", to: "polite", tags: ["plain", "polite"] },
|
{ from: "dictionary", to: "polite" },
|
||||||
{ from: "polite past", to: "polite", tags: ["polite", "past"] },
|
{ from: "polite past", to: "polite" },
|
||||||
{ from: "polite negative", to: "polite", tags: ["polite", "negative"] },
|
{ from: "polite negative", to: "polite" },
|
||||||
{ from: "polite progressive", to: "polite", tags: ["polite", "progressive"] },
|
{ from: "polite progressive", to: "polite" },
|
||||||
{ from: "past", to: "polite past", tags: ["plain", "past", "polite"] },
|
{ from: "past", to: "polite past" },
|
||||||
{ from: "polite", to: "polite past", tags: ["past", "polite"] },
|
{ from: "polite", to: "polite past" },
|
||||||
{ from: "polite past negative", to: "polite past", tags: ["polite", "past", "negative"] },
|
{ from: "polite past negative", to: "polite past" },
|
||||||
{ from: "polite progressive past", to: "polite past", tags: ["polite", "progressive", "past"] },
|
{ from: "polite progressive past", to: "polite past" },
|
||||||
{ from: "negative", to: "polite negative", tags: ["plain", "polite", "negative"] },
|
{ from: "negative", to: "polite negative" },
|
||||||
{ from: "polite", to: "polite negative", tags: ["polite", "negative"] },
|
{ from: "polite", to: "polite negative" },
|
||||||
{ from: "polite past negative", to: "polite negative", tags: ["polite", "past", "negative"] },
|
{ from: "polite past negative", to: "polite negative" },
|
||||||
{ from: "polite progressive negative", to: "polite negative", tags: ["polite", "progressive", "negative"] },
|
{ from: "polite progressive negative", to: "polite negative" },
|
||||||
{ from: "past negative", to: "polite past negative", tags: ["plain", "polite", "past", "negative"] },
|
{ from: "past negative", to: "polite past negative" },
|
||||||
{ from: "polite past", to: "polite past negative", tags: ["polite", "past", "negative"] },
|
{ from: "polite past", to: "polite past negative" },
|
||||||
{ from: "polite negative", to: "polite past negative", tags: ["polite", "past", "negative"] },
|
{ from: "polite negative", to: "polite past negative" },
|
||||||
{ from: "polite progressive past negative", to: "polite past negative", tags: ["polite", "progressive", "past", "negative"] },
|
{ from: "polite progressive past negative", to: "polite past negative" },
|
||||||
{ from: "dictionary" , to: "te-form", tags: ["plain", "te-form"] },
|
{ from: "dictionary", to: "te-form" },
|
||||||
{ from: "te-form negative" , to: "te-form", tags: ["plain", "te-form", "negative"] },
|
{ from: "te-form negative", to: "te-form" },
|
||||||
{ from: "te-form" , to: "te-form negative", tags: ["plain", "te-form", "negative"] },
|
{ from: "te-form", to: "te-form negative" },
|
||||||
{ from: "negative" , to: "te-form negative", tags: ["plain", "te-form", "negative"] },
|
{ from: "negative", to: "te-form negative" },
|
||||||
{ from: "dictionary" , to: "potential", tags: ["plain", "potential"] },
|
{ from: "dictionary", to: "potential" },
|
||||||
{ from: "potential negative" , to: "potential", tags: ["plain", "potential", "negative"] },
|
{ from: "potential negative", to: "potential" },
|
||||||
{ from: "potential" , to: "potential negative", tags: ["plain", "potential", "negative"] },
|
{ from: "potential", to: "potential negative" },
|
||||||
{ from: "negative" , to: "potential negative", tags: ["plain", "potential", "negative"] },
|
{ from: "negative", to: "potential negative" },
|
||||||
{ from: "dictionary" , to: "imperative", tags: ["plain", "imperative"] },
|
{ from: "dictionary", to: "imperative" },
|
||||||
{ from: "imperative negative" , to: "imperative", tags: ["plain", "imperative", "negative"] },
|
{ from: "imperative negative", to: "imperative" },
|
||||||
{ from: "imperative" , to: "imperative negative", tags: ["plain", "imperative", "negative"] },
|
{ from: "imperative", to: "imperative negative" },
|
||||||
{ from: "negative" , to: "imperative negative", tags: ["plain", "imperative", "negative"] },
|
{ from: "negative", to: "imperative negative" },
|
||||||
{ from: "dictionary" , to: "causative", tags: ["plain", "causative"] },
|
{ from: "dictionary", to: "causative" },
|
||||||
{ from: "causative negative" , to: "causative", tags: ["plain", "causative", "negative"] },
|
{ from: "causative negative", to: "causative" },
|
||||||
{ from: "causative passive" , to: "causative", tags: ["plain", "causative", "passive"] },
|
{ from: "causative passive", to: "causative" },
|
||||||
{ from: "causative" , to: "causative negative", tags: ["plain", "causative", "negative"] },
|
{ from: "causative", to: "causative negative" },
|
||||||
{ from: "negative" , to: "causative negative", tags: ["plain", "causative", "negative"] },
|
{ from: "negative", to: "causative negative" },
|
||||||
{ from: "causative passive negative" , to: "causative negative", tags: ["plain", "causative", "passive", "negative"] },
|
{ from: "causative passive negative", to: "causative negative" },
|
||||||
{ from: "dictionary" , to: "passive", tags: ["plain", "passive"] },
|
{ from: "dictionary", to: "passive" },
|
||||||
{ from: "passive negative" , to: "passive", tags: ["plain", "passive", "negative"] },
|
{ from: "passive negative", to: "passive" },
|
||||||
{ from: "causative passive" , to: "passive", tags: ["plain", "causative", "passive"] },
|
{ from: "causative passive", to: "passive" },
|
||||||
{ from: "passive" , to: "passive negative", tags: ["plain", "passive", "negative"] },
|
{ from: "passive", to: "passive negative" },
|
||||||
{ from: "negative" , to: "passive negative", tags: ["plain", "passive", "negative"] },
|
{ from: "negative", to: "passive negative" },
|
||||||
{ from: "causative passive negative" , to: "passive negative", tags: ["plain", "causative", "passive", "negative"] },
|
{ from: "causative passive negative", to: "passive negative" },
|
||||||
{ from: "causative" , to: "causative passive", tags: ["plain", "causative", "passive"] },
|
{ from: "causative", to: "causative passive" },
|
||||||
{ from: "passive" , to: "causative passive", tags: ["plain", "causative", "passive"] },
|
{ from: "passive", to: "causative passive" },
|
||||||
{ from: "causative passive negative" , to: "causative passive", tags: ["plain", "causative", "passive", "negative"] },
|
{ from: "causative passive negative", to: "causative passive" },
|
||||||
{ from: "causative negative" , to: "causative passive negative", tags: ["plain", "causative", "passive", "negative"] },
|
{ from: "causative negative", to: "causative passive negative" },
|
||||||
{ from: "passive negative" , to: "causative passive negative", tags: ["plain", "causative", "passive", "negative"] },
|
{ from: "passive negative", to: "causative passive negative" },
|
||||||
{ from: "causative passive" , to: "causative passive negative", tags: ["plain", "causative", "passive", "negative"] },
|
{ from: "causative passive", to: "causative passive negative" },
|
||||||
{ from: "dictionary", to: "progressive", tags: ["plain", "progressive"] },
|
{ from: "dictionary", to: "progressive" },
|
||||||
{ from: "polite progressive", to: "progressive", tags: ["plain", "polite", "progressive"] },
|
{ from: "polite progressive", to: "progressive" },
|
||||||
{ from: "progressive negative", to: "progressive", tags: ["plain", "progressive", "negative"] },
|
{ from: "progressive negative", to: "progressive" },
|
||||||
{ from: "progressive past", to: "progressive", tags: ["plain", "progressive", "past"] },
|
{ from: "progressive past", to: "progressive" },
|
||||||
{ from: "progressive", to: "progressive negative", tags: ["plain", "progressive", "negative"] },
|
{ from: "progressive", to: "progressive negative" },
|
||||||
{ from: "negative", to: "progressive negative", tags: ["plain", "negative", "progressive"] },
|
{ from: "negative", to: "progressive negative" },
|
||||||
{ from: "progressive past negative", to: "progressive negative", tags: ["plain", "progressive", "past", "negative"] },
|
{ from: "progressive past negative", to: "progressive negative" },
|
||||||
{ from: "polite progressive negative", to: "progressive negative", tags: ["plain", "polite", "progressive", "negative"] },
|
{ from: "polite progressive negative", to: "progressive negative" },
|
||||||
{ from: "progressive", to: "polite progressive", tags: ["plain", "progressive", "polite"] },
|
{ from: "progressive", to: "polite progressive" },
|
||||||
{ from: "polite", to: "polite progressive", tags: ["polite", "progressive"] },
|
{ from: "polite", to: "polite progressive" },
|
||||||
{ from: "polite progressive negative", to: "polite progressive", tags: ["polite", "progressive", "negative"] },
|
{ from: "polite progressive negative", to: "polite progressive" },
|
||||||
{ from: "polite progressive past", to: "polite progressive", tags: ["polite", "progressive", "past"] },
|
{ from: "polite progressive past", to: "polite progressive" },
|
||||||
{ from: "polite progressive", to: "polite progressive negative", tags: ["polite", "progressive", "negative"] },
|
{ from: "polite progressive", to: "polite progressive negative" },
|
||||||
{ from: "polite negative", to: "polite progressive negative", tags: ["polite", "progressive", "negative"] },
|
{ from: "polite negative", to: "polite progressive negative" },
|
||||||
{ from: "progressive negative", to: "polite progressive negative", tags: ["plain", "polite", "progressive", "negative"] },
|
{ from: "progressive negative", to: "polite progressive negative" },
|
||||||
{ from: "polite progressive past negative", to: "polite progressive negative", tags: ["polite", "past", "progressive", "negative"] },
|
{ from: "polite progressive past negative", to: "polite progressive negative" },
|
||||||
{ from: "past", to: "progressive past", tags: ["plain", "past", "progressive"] },
|
{ from: "past", to: "progressive past" },
|
||||||
{ from: "progressive", to: "progressive past", tags: ["plain", "past", "progressive"] },
|
{ from: "progressive", to: "progressive past" },
|
||||||
{ from: "progressive past negative", to: "progressive past", tags: ["plain", "progressive", "past", "negative"] },
|
{ from: "progressive past negative", to: "progressive past" },
|
||||||
{ from: "polite progressive past", to: "progressive past", tags: ["plain", "polite", "progressive", "past"] },
|
{ from: "polite progressive past", to: "progressive past" },
|
||||||
{ from: "past negative", to: "progressive past negative", tags: ["plain", "progressive", "past", "negative"] },
|
{ from: "past negative", to: "progressive past negative" },
|
||||||
{ from: "progressive negative", to: "progressive past negative", tags: ["plain", "progressive", "past", "negative"] },
|
{ from: "progressive negative", to: "progressive past negative" },
|
||||||
{ from: "progressive past", to: "progressive past negative", tags: ["plain", "progressive", "past", "negative"] },
|
{ from: "progressive past", to: "progressive past negative" },
|
||||||
{ from: "polite progressive past negative", to: "progressive past negative", tags: ["plain", "polite", "progressive", "past", "negative"] },
|
{ from: "polite progressive past negative", to: "progressive past negative" },
|
||||||
{ from: "polite past", to: "polite progressive past", tags: ["polite", "progressive", "past"] },
|
{ from: "polite past", to: "polite progressive past" },
|
||||||
{ from: "polite progressive" , to: "polite progressive past", tags: ["polite", "progressive", "past"] },
|
{ from: "polite progressive", to: "polite progressive past" },
|
||||||
{ from: "progressive past", to: "polite progressive past", tags: ["plain", "polite", "progressive", "past"] },
|
{ from: "progressive past", to: "polite progressive past" },
|
||||||
{ from: "polite progressive past negative", to: "polite progressive past", tags: ["polite", "progressive", "past", "negative"] },
|
{ from: "polite progressive past negative", to: "polite progressive past" },
|
||||||
{ from: "polite past negative", to: "polite progressive past negative", tags: ["polite", "progressive", "past", "negative"] },
|
{ from: "polite past negative", to: "polite progressive past negative" },
|
||||||
{ from: "progressive past negative", to: "polite progressive past negative", tags: ["plain", "polite", "progressive", "past", "negative"] },
|
{ from: "progressive past negative", to: "polite progressive past negative" },
|
||||||
{ from: "polite progressive past", to: "polite progressive past negative", tags: ["polite", "progressive", "past", "negative"] },
|
{ from: "polite progressive past", to: "polite progressive past negative" },
|
||||||
{ from: "polite progressive negative", to: "polite progressive past negative", tags: ["polite", "progressive", "past", "negative"] },
|
{ from: "polite progressive negative", to: "polite progressive past negative" },
|
||||||
];
|
];
|
||||||
|
|
||||||
var log;
|
var log;
|
||||||
@ -1312,6 +1312,12 @@ function arrayDifference(a, b) {
|
|||||||
return a.filter(function (x) { return b.indexOf(x) < 0 });
|
return a.filter(function (x) { return b.indexOf(x) < 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arrayUnique(arr) {
|
||||||
|
return arr.filter(function (value, index, self) {
|
||||||
|
return self.indexOf(value) === index;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function calculateTransitions() {
|
function calculateTransitions() {
|
||||||
|
|
||||||
function getTags(str) {
|
function getTags(str) {
|
||||||
@ -1325,6 +1331,21 @@ function calculateTransitions() {
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function calculateTags(tags) {
|
||||||
|
|
||||||
|
tags = tags.split(" ");
|
||||||
|
|
||||||
|
if (tags.indexOf("polite") == -1) {
|
||||||
|
tags.push("plain");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tags.indexOf("dictionary") != -1) {
|
||||||
|
tags.splice(tags.indexOf("dictionary"), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
transformations.forEach(function (transformation) {
|
transformations.forEach(function (transformation) {
|
||||||
|
|
||||||
var from = getTags(transformation.from);
|
var from = getTags(transformation.from);
|
||||||
@ -1359,11 +1380,10 @@ function calculateTransitions() {
|
|||||||
phrase = phrase || from_extra[arrayDifference(from, to)[0]];
|
phrase = phrase || from_extra[arrayDifference(from, to)[0]];
|
||||||
phrase = phrase || to_extra[arrayDifference(to, from)[0]];
|
phrase = phrase || to_extra[arrayDifference(to, from)[0]];
|
||||||
|
|
||||||
if (phrase == undefined) {
|
|
||||||
throw "wobbly";
|
|
||||||
}
|
|
||||||
|
|
||||||
transformation.phrase = phrase;
|
transformation.phrase = phrase;
|
||||||
|
|
||||||
|
transformation.tags = arrayUnique(calculateTags(transformation.from).concat(calculateTags(transformation.to)));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add trick forms
|
// Add trick forms
|
||||||
|
Loading…
Reference in New Issue
Block a user