From 27d6673f231715ccab8105cc34e5fb5dbf4356be Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Thu, 3 Jan 2019 19:17:54 -0400 Subject: Add prelim for guessing group names --- src/AffixLister.java | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/AffixLister.java b/src/AffixLister.java index ef7e3223..d20ca9b7 100644 --- a/src/AffixLister.java +++ b/src/AffixLister.java @@ -596,7 +596,7 @@ public class AffixLister { NAMED; } - private static int readNamesFromFile(Map> fNames, String from, String defGroup) { + private static int readNamesFromFile(Map> fNames, String from, String defGroup, boolean guessGroups) { int numFiles = 0; try (FileReader fr = new FileReader(from)) { Scanner scn = new Scanner(fr); @@ -610,6 +610,15 @@ public class AffixLister { if (ln.startsWith("#")) { curGroup = ln.substring(1); + if (!fNames.containsKey(curGroup)) { + curList = new ArrayList<>(); + fNames.put(curGroup, curList); + } else { + curList = fNames.get(curGroup); + } + } else if (guessGroups && ln.contains("/mods/")) { + curGroup = ln.replaceAll(".*/mods/([^/]+)/*", "$1"); + if (!fNames.containsKey(curGroup)) { curList = new ArrayList<>(); fNames.put(curGroup, curList); @@ -637,8 +646,9 @@ public class AffixLister { public static void main(String[] args) { boolean doingArgs = true; - boolean omitZeros = false; - boolean listZeros = false; + boolean omitZeros = false; + boolean listZeros = false; + boolean guessGroups = false; NameMode nameMode = NameMode.ALL; @@ -727,6 +737,12 @@ public class AffixLister { fGroups.put(curGroup, fNames); } break; + case "--guess-groups": + guessGroups = true; + break; + case "--no-guess-groups": + guessGroups = false; + break; case "--read-names-from-file": case "-r": if (i + 1 >= args.length) { @@ -734,7 +750,7 @@ public class AffixLister { break; } - fCount += readNamesFromFile(fGroups, args[++i], curGroup); + fCount += readNamesFromFile(fGroups, args[++i], curGroup, guessGroups); break; default: isArg = false; -- cgit v1.2.3