aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/japanese-util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/language/japanese-util.js')
-rw-r--r--ext/js/language/japanese-util.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/js/language/japanese-util.js b/ext/js/language/japanese-util.js
index e47cdf55..4d317396 100644
--- a/ext/js/language/japanese-util.js
+++ b/ext/js/language/japanese-util.js
@@ -232,6 +232,22 @@ const JapaneseUtil = (() => {
}
}
+ getPitchCategory(text, pitchAccentPosition, isVerbOrAdjective) {
+ if (pitchAccentPosition === 0) {
+ return 'heiban';
+ }
+ if (isVerbOrAdjective) {
+ return pitchAccentPosition > 0 ? 'kifuku' : null;
+ }
+ if (pitchAccentPosition === 1) {
+ return 'atamadaka';
+ }
+ if (pitchAccentPosition > 1) {
+ return pitchAccentPosition >= this.getKanaMoraCount(text) ? 'odaka' : 'nakadaka';
+ }
+ return null;
+ }
+
getKanaMorae(text) {
const morae = [];
let i;
@@ -245,6 +261,16 @@ const JapaneseUtil = (() => {
return morae;
}
+ getKanaMoraCount(text) {
+ let moraCount = 0;
+ for (const c of text) {
+ if (!(SMALL_KANA_SET.has(c) && moraCount > 0)) {
+ ++moraCount;
+ }
+ }
+ return moraCount;
+ }
+
// Conversion functions
convertToKana(text) {