/** * Creates a new instance of {@link PunctDescription} for the given language. * * @param resourceDir path to the folder with the language resources * @param lang the language * @param macrosMap a map of macro names to regular expression strings * @throws IOException if there is an error when reading the configuration */ public PunctDescription(String resourceDir, String lang, Map<String, String> macrosMap) throws IOException { super.setDefinitionsMap(new HashMap<String, RegExp>()); super.setRulesMap(new HashMap<String, RegExp>()); super.setRegExpMap(new HashMap<RegExp, String>()); Path punctDescrPath = Paths.get(resourceDir).resolve(lang + PUNCT_DESCR); BufferedReader in = new BufferedReader( new InputStreamReader(FileTools.openResourceFileAsStream(punctDescrPath), "utf-8")); // read config file to definitions start readToDefinitions(in); // read definitions Map<String, String> defsMap = new HashMap<>(); super.loadDefinitions(in, macrosMap, defsMap); // when loadDefinitions returns the reader has reached the rules section; // read rules super.loadRules(in, defsMap, macrosMap); getRulesMap().put(ALL_RULE, createAllRule(defsMap)); in.close(); }