EdictEntry extends DictEntry { public List<List<String>> getSenses() { final List<List<String>> result = new ArrayList<List<String>>(); int currentSense = 1; final String e = english.substring(findMarkings(english, new ArrayList<String>())); for (final StringTokenizer senses = new StringTokenizer(e, ";/"); senses.hasMoreTokens();) { final String sense = senses.nextToken(); if (MiscUtils.isBlank(sense)) { continue; } int[] newCurrentSense = findSenseNumber(sense); if (newCurrentSense != null) { currentSense = newCurrentSense[0]; } while (result.size() < currentSense) { result.add(new ArrayList<String>()); } if ("(P)".equalsIgnoreCase(sense)) { continue; } result.get(currentSense - 1).add(newCurrentSense != null ? sense.substring(newCurrentSense[1]).trim() : sense.trim()); } return result; } EdictEntry(final String kanji, final String reading, final String english, final boolean isCommon);  EdictEntry(final String kanji, final String reading, final String english); static EdictEntry fromEntry(final DictEntry entry); boolean isIchidan(); boolean isGodan(); boolean isVerb(); boolean isSuru(); boolean isKuru(); List<String> getMarkings(); List<String> getMarkings(final String str); List<List<String>> getSenses();  }
@Test public void getSenses() { EdictEntry e = new EdictEntry( "翫ぶ", "もてあそぶ", "(v5b,vt) (1) (uk) to play with (a toy, one's hair, etc.); to fiddle with; (2) to toy with (one's emotions, etc.); to trifle with; (3) to do with something as one pleases; (4) to appreciate;", false); final List<List<String>> senses = e.getSenses(); assertEquals("(uk) to play with (a toy, one's hair, etc.)", senses.get(0).get(0)); assertEquals("to fiddle with", senses.get(0).get(1)); assertEquals(2, senses.get(0).size()); assertEquals("to toy with (one's emotions, etc.)", senses.get(1).get(0)); assertEquals("to trifle with", senses.get(1).get(1)); assertEquals(2, senses.get(1).size()); assertEquals("to do with something as one pleases", senses.get(2).get(0)); assertEquals(1, senses.get(2).size()); assertEquals("to appreciate", senses.get(3).get(0)); assertEquals(1, senses.get(3).size()); assertEquals(4, senses.size()); }
@Test public void getSenses2() { EdictEntry e = new EdictEntry("翫ぶ", "もてあそぶ", "(n) father and mother;parents", false); List<List<String>> senses = e.getSenses(); assertEquals("father and mother", senses.get(0).get(0)); assertEquals("parents", senses.get(0).get(1)); assertEquals(1, senses.size()); e = new EdictEntry("母", "はは", "(n) (hum) mother/(P)/", true); senses = e.getSenses(); assertEquals("mother", senses.get(0).get(0)); assertEquals(1, senses.get(0).size()); assertEquals(1, senses.size()); e = new EdictEntry("波々迦", "ははか", "(n) (arch) Japanese bird cherry (Prunus grayana)/", false); senses = e.getSenses(); assertEquals("Japanese bird cherry (Prunus grayana)", senses.get(0).get(0)); assertEquals(1, senses.get(0).size()); assertEquals(1, senses.size()); }
@Test public void getSenses3() { EdictEntry e = new EdictEntry("方", "かた", "(n) (1) direction/way/(2) (hon) person/lady/gentleman/(n,n-suf) (3) method of/manner of/way of/(n-suf) (4) care of ../(n-suf) (5) person in charge of ../(n-suf) (6) side (e.g. \"on my mother's side\")/(P)/", true); final List<List<String>> senses = e.getSenses(); assertEquals("direction", senses.get(0).get(0)); assertEquals("way", senses.get(0).get(1)); assertEquals(2, senses.get(0).size()); assertEquals("(hon) person", senses.get(1).get(0)); assertEquals("lady", senses.get(1).get(1)); assertEquals("gentleman", senses.get(1).get(2)); assertEquals(3, senses.get(1).size()); assertEquals("method of", senses.get(2).get(0)); assertEquals("manner of", senses.get(2).get(1)); assertEquals("way of", senses.get(2).get(2)); assertEquals(3, senses.get(2).size()); assertEquals("care of ..", senses.get(3).get(0)); assertEquals(1, senses.get(3).size()); assertEquals("person in charge of ..", senses.get(4).get(0)); assertEquals(1, senses.get(4).size()); assertEquals("side (e.g. \"on my mother's side\")", senses.get(5).get(0)); assertEquals(1, senses.get(5).size()); assertEquals(6, senses.size()); }