diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 19:11:36 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 19:14:46 -0400 |
| commit | ee87cdff7dfbe3782f75db3dc17be23f6edb54ec (patch) | |
| tree | e3ac1393525d37e79d0ae6afef986d2d515162f2 /BJC-Utils2/src/examples | |
| parent | 6e4d80b6fc50abd8692652cda03a1d21e44da261 (diff) | |
Add abbreviation map.
An abbreviation map allows you to figure out which of the possible strings
in a given set could be abbreviated by a particular string.
Diffstat (limited to 'BJC-Utils2/src/examples')
| -rw-r--r-- | BJC-Utils2/src/examples/java/bjc/utils/examples/AbbrevMapTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/BJC-Utils2/src/examples/java/bjc/utils/examples/AbbrevMapTest.java b/BJC-Utils2/src/examples/java/bjc/utils/examples/AbbrevMapTest.java new file mode 100644 index 0000000..ddf8e0c --- /dev/null +++ b/BJC-Utils2/src/examples/java/bjc/utils/examples/AbbrevMapTest.java @@ -0,0 +1,59 @@ +package bjc.utils.examples; + +import bjc.utils.esodata.AbbrevMap; +import bjc.utils.funcutils.StringUtils; + +import java.util.Scanner; + +/** + * Test for abbreviation map. + * + * @author EVE + * + */ +public class AbbrevMapTest { + /** + * Main method. + * + * @param args + * Unused CLI args. + */ + public static void main(String[] args) { + Scanner scn = new Scanner(System.in); + + AbbrevMap map = new AbbrevMap(); + + System.out.print("Enter a command (blank line to quit): "); + String ln = scn.nextLine(); + + while(!ln.equals("")) { + String[] commParts = ln.split(" "); + + switch(commParts[0]) { + case "add": + map.addWords(commParts[1]); + break; + case "remove": + map.removeWords(commParts[1]); + break; + case "recalc": + map.recalculate(); + break; + case "check": + String list = StringUtils.toEnglishList(map.deabbrev(commParts[1]), false); + System.out.println(list); + break; + case "debug": + System.out.println(map.toString()); + break; + default: + System.out.println("Unknown command: " + ln); + } + + System.out.print("Enter a command (blank line to quit): "); + ln = scn.nextLine(); + } + + scn.close(); + } +} |
