Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global.hiragana =
- [
- [["あ", "a"], ["い", "i"], ["う", "u"], ["え", "e"], ["お", "o"]],
- [["か", "ka"], ["き", "ki"], ["く", "ku"], ["け", "ke"], ["こ", "ko"]],
- [["さ", "sa"], ["し", "shi"], ["す", "su"], ["せ", "se"], ["そ", "so"]],
- [["た", "ta"], ["ち", "chi"], ["つ", "tsu"], ["て", "te"], ["と", "to"]],
- [["な", "na"], ["に", "ni"], ["ぬ", "nu"], ["ね", "ne"], ["の", "no"]],
- [["は", "ha"], ["ひ", "hi"], ["ふ", "fu"], ["へ", "he"], ["ほ", "ho"]],
- [["ま", "ma"], ["み", "mi"], ["む", "mu"], ["め", "me"], ["も", "mo"]],
- [["ら", "ra"], ["り", "ri"], ["る", "ru"], ["れ", "re"], ["ろ", "ro"]],
- [["わ", "wa"], ["を", "wo"], ["ん", "n"]],
- [["や", "ya"], ["ゆ", "yu"], ["よ", "yo"]],
- [["が", "ga"], ["ぎ", "gi"], ["ぐ", "gu"], ["げ", "ge"], ["ご", "go"]],
- [["ざ", "za"], ["じ", "ji"], ["ず", "zu"], ["ぜ", "ze"], ["ぞ", "zo"]],
- [["だ", "da"], ["ぢ", "ji"], ["づ", "zu"], ["で", "de"], ["ど", "do"]],
- [["ば", "ba"], ["び", "bi"], ["ぶ", "bu"], ["べ", "be"], ["ぼ", "bo"]],
- [["ぱ", "pa"], ["ぴ", "pi"], ["ぷ", "pu"], ["ぺ", "pe"], ["ぽ", "po"]]
- ];
- global.exeption = [
- "嘲る", "焦る", "脂ぎ", "熱る", "弄る", "いび", "煎る", "入る", "要る", "うね", "彫る", "選る", "陥る", "阿る", "還る", "帰る", "孵る", "返る",
- "反る", "限る", "翔る", "陰る", "呪る", "齧る", "噛る", "軋る", "轢る", "切る", "剪る", "斬る", "霧る", "抉る", "愚痴る", "散る", "抓る", "照る",
- "覆る", "くねる", "縊る", "蹴る", "抉る", "遮る", "雑じる", "見縊る", "漲る", "毟る", "滅入る", "減る", "捩る", "よぎる", "捩る", "蘇る・甦る",
- "湿気る", "茂る", "湿る", "喋る", "知る", "捩る", "滑る", "せびる", "競る", "謗る", "譏る", "誹る", "そべる", "滾る", "猛る", "駄弁る", "魂消る", "契る",
- "どじる", "とちる", "迸る", "詰る", "滑る", "握る", "躙る", "滑る", "捩じる", "捻じる", "練る", "錬る", "煉る", "粘る", "罵る", "野次る", "弥次る",
- "のめる", "入る", "走る", "侍る", "捻る", "びびる", "翻る", "耽る", "臥せる", "減る", "謙る", "穿る", "火照る・熱る", "迸る", "参る", "交じる", "混じる",
- ];
- Array.prototype.searchDepth = function(searchElement, equality, getter) {
- const O = Object(this);
- var index = this.indexOf(searchElement);
- if(~index) {
- return (getter) ? [index] : index;
- }
- else {
- if(equality) {
- if(Array.isArray(O[i])) {
- index = O[i].searchDepth(searchElement, equality, getter);
- if(index) {
- return getter ? O[i] : [i].concat(index);
- }
- }
- }
- for(var i = 0; i < O.length; i++) {
- if(Array.isArray(O[i])) {
- index = O[i].searchDepth(searchElement, equality, getter);
- if(index != null) {
- return getter ? O[i] : [i].concat(index);
- }
- }
- }
- return null;
- }
- };
- Array.prototype.path = function(path) {
- let arr = this;
- for(let i = 0; i < path.length; i++) {
- arr = arr[parseInt(path[i])];
- }
- return arr;
- };
- class Verb {
- constructor(verb, type) {
- this.verb = verb;
- this.type = type ? type : this.findType();
- this.rentaikei = this.verb;
- this.shuushikei = this.verb;
- const base = this.verb.substring(0, this.verb.length-1);
- console.log(this.__search(this.verb.substr(-1)));
- this.renyoukei = base+(this.type == "godan" ? this.__search(this.verb.substr(-1))[1][0] : "");
- this.mizenkei = base+(this.type == "godan" ? this.__search(this.verb.substr(-1))[0][0] : "");
- this.kateikei = base+this.__search(this.verb.substr(-1))[3][0];
- this.meireikei = base+(this.type == "ichidan" ? this.__search(this.verb.substr(-1))[4][0] : this.kateikei.substr(-1));
- const last = this.verb.substring(this.verb.length-1);
- console.log(last);
- const __conjExeptObj = {
- "す": ["した", "して"],
- "く": ["いた", "いて"], "ぐ": ["いた", "いて"],
- "む": ["んだ", "んで"], "ぶ": ["んだ", "んで"], "ぬ": ["んだ", "んで"],
- "る": ["った", "って"], "う": ["った", "って"], "つ": ["った", "って"]
- }
- const past = (this.type == "ichidan") ? this.renyoukei+"た" : base+__conjExeptObj[last][0];
- const teform = (this.type == "ichidan") ? this.renyoukei+"た" : base+__conjExeptObj[last][1];
- this.conj = {
- "type": this.type,
- "rentaikei": this.rentaikei,
- "shuushikei": this.shuushikei,
- "renyoukei": this.renyoukei,
- "mizenkei": this.mizenkei,
- "meireikei": this.meireikei,
- "kateikei": this.kateikei,
- "renyoukei": this.renyoukei,
- "non-past": { pos: this.rentaikei, neg: this.mizenkei+"ない" },
- "non-past-polite": { pos: this.renyoukei+"ます", neg: this.renyoukei+"ません" },
- "past": { pos: past, neg: this.mizenkei+"なかった" },
- "past-polite": { pos: this.renyoukei+"ました", neg: this.renyoukei+"ませんでした" },
- "te-form": { pos: teform, neg: this.mizenkei+"なくて" },
- "imperative": { pos: this.meireikei, neg: this.verb+"な" },
- "potential": {
- pos: (this.type == "ichidan" ? this.renyoukei+"られる" : this.kateikei+"る"),
- neg: (this.type == "ichidan" ? this.renyoukei+"られない" : this.kateikei+"ない")
- },
- "passive": {
- pos: this.mizenkei+(this.type == "ichidan" ? "られる" : "れる"),
- neg: this.mizenkei+(this.type == "ichidan" ? "られない" : "れない")
- },
- "causative": {
- pos: this.mizenkei+(this.type == "ichidan" ? "させる" : "せる"),
- neg: this.mizenkei+(this.type == "ichidan" ? "させない" : "せない")
- },
- "naide-form": { pos: "-", neg: this.mizenkei+"ない"+"で" }
- };
- }
- __search(v) {
- return hiragana.searchDepth(v, false, true);
- }
- findType() {
- const lastChar = this.verb.substr(-1);
- if(lastChar != "る") return "godan";
- else if(~exeption.indexOf(this.verb)) return "godan";
- else {
- const lastlastChar = this.verb.substr(-2, 1);console.log(lastlastChar);
- const hiraganaPath = hiragana.searchDepth(lastlastChar, false, false);
- hiraganaPath.pop();
- const syll = hiragana.path(hiraganaPath);
- if(~syll[1].indexOf("e") || ~syll[1].indexOf("i")) return "ichidan";
- else return "godan";
- }
- }
- getRentaikei() {
- return this.rentaikei;
- }
- getRenyoukei() {
- return this.renyoukei;
- }
- getMizenkei() {
- return this.mizenkei;
- }
- getKateikei() {
- return this.kateikei;
- }
- getMeireikei() {
- return this.meireikei;
- }
- get(tense, positive) {
- this.conj["causative-passive"] = {
- pos: new Verb(this.conj["causative"]["pos"], "godan").getMizenkei()+"れる",
- neg: new Verb(this.conj["causative"]["pos"], "godan").getMizenkei()+"れない"
- };
- console.log(tense);
- let constr = tense.split(" ");
- if(constr.length > 1) {
- let first = constr[0]; console.log(first);
- constr.shift();
- return new Verb(this.conj[first]["pos"], "ichidan").get(constr.join(" "), positive);
- }
- return this.conj[tense][(positive) ? "pos" : "neg"];
- }
- getAll() {
- return this.conj;
- }
- }
- module.exports = Verb;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement