Skip to content

Commit

Permalink
Corrected spelling of the word 'romanji'
Browse files Browse the repository at this point in the history
Turns out, I've been spelling 'romanji' completely wrong this entire time. It's actually spelled 'romaji', with no 'n'. So I went through the entire project, correcting every single use of the word, except the historical database schema records used for migration testing, and the current database field names. Because as I explained before (30c55cc), I don't want to have to write a migration script just for this. Besides, if I was going to change the field names, I'd change 'incorrect_romanji' to 'incorrect_answer', not 'incorrect_romaji'. By the way, the only reason I noticed this was thanks to a YouTube comment (https://www.youtube.com/watch?v=zOwP0KUlnZg&lc=UghRSQOAfU0soXgCoAEC.8VK7CYSCRT88VKGox2Uuob). It's amazing I didn't notice this sooner. Android Studio's spell check would've caught it, but it's a Japanese word, and I didn't install a Japanese dictionary, so I was just adding Japanese words to the custom dictionary instead, not realizing they may be misspelled. I really need to double-check all of this.
  • Loading branch information
theblackwidower committed Oct 25, 2018
1 parent 6a156b0 commit 215e925
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 200 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Currently available on [Google Play™](https://play.google.com/store/apps/detai
* Built-in kana reference sheet
* Supports both digraphs (ひゃ, みゅ, リュ) and diacritics (が, ぴ)
* User can select app behaviour on an incorrect answer from three different options: retry until the correct answer is given, show the correct answer and move on, or hide the correct answer and move on
* Support for the three major romanji systems: Revised Hepburn, Nihon-shiki, and Kunrei-shiki
* Support for the three major romaji systems: Revised Hepburn, Nihon-shiki, and Kunrei-shiki
* A daily log will show your progress over time
* Dynamic AI chooses the kana you have the most trouble with

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public void parsingTest()
assertKanaQuestion(kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][0], "は", "ha");
assertKanaQuestion(kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][1], "ひ", "hi");
assertKanaQuestion(kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][2], "ふ", "fu");
assertThat(((KanaQuestion) kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][2]).fetchRomanji(NIHON), is("hu"));
assertThat(((KanaQuestion) kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][2]).fetchRomanji(KUNREI), is("hu"));
assertThat(((KanaQuestion) kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][2]).fetchRomaji(NIHON), is("hu"));
assertThat(((KanaQuestion) kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][2]).fetchRomaji(KUNREI), is("hu"));
assertKanaQuestion(kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][3], "へ", "he");
assertKanaQuestion(kanaSetList.get(2)[NO_DIACRITIC.ordinal()][0][4], "ほ", "ho");

Expand Down Expand Up @@ -102,9 +102,9 @@ public void parsingTest()
assertKanaQuestion(kanaSetList.get(2)[CONSONANT.ordinal()][0][0], "ん", "n");
}

private void assertKanaQuestion(Question question, String expectedKana, String expectedRomanji)
private void assertKanaQuestion(Question question, String expectedKana, String expectedRomaji)
{
assertThat(question.getQuestionText(), is(expectedKana));
assertThat(((KanaQuestion) question).fetchRomanji(null), is(expectedRomanji));
assertThat(((KanaQuestion) question).fetchRomaji(null), is(expectedRomaji));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,98 +7,98 @@

public class GojuonOrder implements Comparator<String>
{
static class NotRomanjiException extends Exception {}
static class NotRomajiException extends Exception {}

static void sort(String[] romanji)
static void sort(String[] romaji)
{
Arrays.sort(romanji, new GojuonOrder());
Arrays.sort(romaji, new GojuonOrder());
}

private static int getSortId(CharacterIterator romanji)
private static int getSortId(CharacterIterator romaji)
{
int startIndex = romanji.getIndex();
int startIndex = romaji.getIndex();
try
{
return getRomanjiKey(romanji);
return getRomajiKey(romaji);
}
catch (NotRomanjiException ex)
catch (NotRomajiException ex)
{
if (romanji.setIndex(startIndex) == 'n')
if (romaji.setIndex(startIndex) == 'n')
return 108; //N Consonant
else
return 109 + romanji.current();
return 109 + romaji.current();
}
finally
{
romanji.next();
romaji.next();
}
}

private static final char[] VOWELS = {'a', 'i', 'u', 'e', 'o'};
private static final char[] MAIN_SETS = {'k', 'g', '\u0000', 'z', '\u0000', 'd', 'n', 'h', 'b', 'p', 'm'};
private static final char[] Y_VOWELS = {'a', 'u', 'o'};

private static int getRomanjiKey(CharacterIterator romanji) throws NotRomanjiException
private static int getRomajiKey(CharacterIterator romaji) throws NotRomajiException
{
for (int i = 0; i < VOWELS.length; i++)
if (romanji.current() == VOWELS[i])
if (romaji.current() == VOWELS[i])
return i;

for (int i = 0; i < MAIN_SETS.length; i++)
if (romanji.current() == MAIN_SETS[i])
return 5 + (i * 8) + getSubKey(romanji);
if (romaji.current() == MAIN_SETS[i])
return 5 + (i * 8) + getSubKey(romaji);

switch (romanji.current())
switch (romaji.current())
{
case ' ':
case CharacterIterator.DONE:
return -1;

case 's':
if (romanji.next() == 'h')
return 21 + getAltIKey(romanji);
if (romaji.next() == 'h')
return 21 + getAltIKey(romaji);
else
{
romanji.previous();
return 21 + getSubKey(romanji);
romaji.previous();
return 21 + getSubKey(romaji);
}
case 'j':
return 29 + getAltIKey(romanji);
return 29 + getAltIKey(romaji);

case 't':
if (romanji.next() == 's')
if (romaji.next() == 's')
{
if (romanji.next() == 'u')
if (romaji.next() == 'u')
return 37 + 2;
else
break;
}
else
{
romanji.previous();
return 37 + getSubKey(romanji);
romaji.previous();
return 37 + getSubKey(romaji);
}
case 'c':
if (romanji.next() == 'h')
return 37 + getAltIKey(romanji);
if (romaji.next() == 'h')
return 37 + getAltIKey(romaji);
else
break;

case 'f':
if (romanji.next() == 'u')
if (romaji.next() == 'u')
return 61 + 2;
else
break;

case 'y':
romanji.next();
return 93 + getYVowelKey(romanji);
romaji.next();
return 93 + getYVowelKey(romaji);

case 'r':
return 96 + getSubKey(romanji);
return 96 + getSubKey(romaji);

case 'w':
switch (romanji.next())
switch (romaji.next())
{
case 'a':
return 104;
Expand All @@ -111,39 +111,39 @@ private static int getRomanjiKey(CharacterIterator romanji) throws NotRomanjiExc
}
break;
}
throw new NotRomanjiException();
throw new NotRomajiException();
}

private static int getSubKey(CharacterIterator romanji) throws NotRomanjiException
private static int getSubKey(CharacterIterator romaji) throws NotRomajiException
{
romanji.next();
romaji.next();
for (int i = 0; i < VOWELS.length; i++)
if (romanji.current() == VOWELS[i])
if (romaji.current() == VOWELS[i])
return i;

if (romanji.current() == 'y')
if (romaji.current() == 'y')
{
romanji.next();
return 5 + getYVowelKey(romanji);
romaji.next();
return 5 + getYVowelKey(romaji);
}
throw new NotRomanjiException();
throw new NotRomajiException();
}

private static int getAltIKey(CharacterIterator romanji) throws NotRomanjiException
private static int getAltIKey(CharacterIterator romaji) throws NotRomajiException
{
if (romanji.next() == 'i')
if (romaji.next() == 'i')
return 1;

return 5 + getYVowelKey(romanji);
return 5 + getYVowelKey(romaji);
}

private static int getYVowelKey(CharacterIterator romanji) throws NotRomanjiException
private static int getYVowelKey(CharacterIterator romaji) throws NotRomajiException
{
for (int i = 0; i < Y_VOWELS.length; i++)
if (romanji.current() == Y_VOWELS[i])
if (romaji.current() == Y_VOWELS[i])
return i;

throw new NotRomanjiException();
throw new NotRomajiException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
public class KanaQuestion extends Question
{
private final String kana;
private final String defaultRomanji;
private final Map<RomanizationSystem, String> altRomanji;
private final String defaultRomaji;
private final Map<RomanizationSystem, String> altRomaji;

KanaQuestion(String kana, String romanji)
KanaQuestion(String kana, String romaji)
{
this(kana, romanji, null);
this(kana, romaji, null);
}

KanaQuestion(String kana, String romanji, Map<RomanizationSystem, String> altRomanji)
KanaQuestion(String kana, String romaji, Map<RomanizationSystem, String> altRomaji)
{
this.kana = kana.trim();
defaultRomanji = romanji.trim();
this.altRomanji = altRomanji;
defaultRomaji = romaji.trim();
this.altRomaji = altRomaji;
}

String getQuestionText()
Expand All @@ -34,10 +34,10 @@ String getQuestionText()

boolean checkAnswer(String response)
{
if (defaultRomanji.trim().equalsIgnoreCase(response.trim()))
if (defaultRomaji.trim().equalsIgnoreCase(response.trim()))
return true;
if (altRomanji != null)
for (String correctAnswer : altRomanji.values())
if (altRomaji != null)
for (String correctAnswer : altRomaji.values())
if (correctAnswer.trim().equalsIgnoreCase(response.trim()))
return true;

Expand All @@ -46,28 +46,28 @@ boolean checkAnswer(String response)

String fetchCorrectAnswer()
{
return fetchRomanji();
return fetchRomaji();
}

String fetchRomanji()
String fetchRomaji()
{
if (OptionsControl.compareStrings(R.string.prefid_romanize_system, R.string.prefid_romanize_system_default))
return defaultRomanji;
return defaultRomaji;
else if (OptionsControl
.compareStrings(R.string.prefid_romanize_system, R.string.prefid_romanize_system_hepburn))
return fetchRomanji(RomanizationSystem.HEPBURN);
return fetchRomaji(RomanizationSystem.HEPBURN);
else if (OptionsControl.compareStrings(R.string.prefid_romanize_system, R.string.prefid_romanize_system_nihon))
return fetchRomanji(RomanizationSystem.NIHON);
return fetchRomaji(RomanizationSystem.NIHON);
else if (OptionsControl.compareStrings(R.string.prefid_romanize_system, R.string.prefid_romanize_system_kunrei))
return fetchRomanji(RomanizationSystem.KUNREI);
return fetchRomaji(RomanizationSystem.KUNREI);
else
return defaultRomanji;
return defaultRomaji;
}

String fetchRomanji(RomanizationSystem system)
String fetchRomaji(RomanizationSystem system)
{
String romanji = (((system == null) || (altRomanji == null)) ? null : altRomanji.get(system));
return (romanji == null) ? defaultRomanji : romanji;
String romaji = (((system == null) || (altRomaji == null)) ? null : altRomaji.get(system));
return (romaji == null) ? defaultRomaji : romaji;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@

public class WordQuestion extends Question
{
private final String romanji;
private final String romaji;
private final String kana;
private final String kanji;
private final String answer;

public WordQuestion(String romanji, String answer, String kana, String kanji)
public WordQuestion(String romaji, String answer, String kana, String kanji)
{
this.romanji = romanji.trim();
this.romaji = romaji.trim();
this.answer = answer.trim();
this.kana = (kana != null) ? kana.trim() : null;
this.kanji = (kanji != null) ? kanji.trim() : null;
}

enum QuestionTextType
{
ROMANJI,
ROMAJI,
KANA,
KANJI
}

@Override
String getQuestionText()
{
if (OptionsControl.compareStrings(R.string.prefid_vocab_display, R.string.prefid_vocab_display_romanji))
return fetchText(QuestionTextType.ROMANJI);
if (OptionsControl.compareStrings(R.string.prefid_vocab_display, R.string.prefid_vocab_display_romaji))
return fetchText(QuestionTextType.ROMAJI);
else if (OptionsControl.compareStrings(R.string.prefid_vocab_display, R.string.prefid_vocab_display_kana))
return fetchText(QuestionTextType.KANA);
else if (OptionsControl.compareStrings(R.string.prefid_vocab_display, R.string.prefid_vocab_display_kanji))
return fetchText(QuestionTextType.KANJI);
else
return romanji;
return romaji;
}

@SuppressWarnings("fallthrough")
Expand All @@ -53,9 +53,9 @@ private String fetchText(QuestionTextType type)
case KANA:
if (kana != null)
return kana;
case ROMANJI:
case ROMAJI:
default:
return romanji;
return romaji;
}
}

Expand All @@ -74,7 +74,7 @@ String fetchCorrectAnswer()
@Override
String getDatabaseKey()
{
return romanji;
return romaji;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,16 @@ private static KanaQuestion parseXmlKanaQuestion(XmlResourceParser parser, Resou
private static WordQuestion parseXmlWordQuestion(XmlResourceParser parser, Resources resources)
throws ParseException
{
String thisRomanji = null;
String thisRomaji = null;
String thisKana = null;
String thisKanji = null;
String thisAnswer = null;
for (int i = 0; i < parser.getAttributeCount(); i++)
{
switch (parser.getAttributeName(i))
{
case "romanji":
thisRomanji = parseXmlValue(parser, i, resources);
case "romaji":
thisRomaji = parseXmlValue(parser, i, resources);
break;
case "kana":
thisKana = parseXmlValue(parser, i, resources);
Expand All @@ -203,10 +203,10 @@ private static WordQuestion parseXmlWordQuestion(XmlResourceParser parser, Resou
thisAnswer = parseXmlValue(parser, i, resources);
}
}
if ((thisRomanji == null) || (thisAnswer == null))
if ((thisRomaji == null) || (thisAnswer == null))
throw new ParseException("Missing attribute in WordQuestion", 0);

return new WordQuestion(thisRomanji, thisAnswer, thisKana, thisKanji);
return new WordQuestion(thisRomaji, thisAnswer, thisKana, thisKanji);
}

private static TreeMap<RomanizationSystem, String> parseXmlAltAnswers(XmlPullParser parser)
Expand Down
Loading

0 comments on commit 215e925

Please sign in to comment.