public Lexicon1Lang(String filename) throws IOException { captionToRawQuery = new LinkedHashMap<String, String>(); captionToExpandedQuery = new LinkedHashMap<String, String>(); List<String> lines = Util.getLinesFromInputStream( new FileInputStream(filename), false /* ignore comment lines = false, we'll strip comments here */); for (String line : lines) { int idx = line.indexOf('#'); // strip everything after the comment char if (idx >= 0) line = line.substring(0, idx); line = line.trim(); if (line.length() == 0) continue; // ignore blank lines StringTokenizer st = new StringTokenizer(line, ":"); if (st.countTokens() != 2) { log.warn("line ignored: " + line); continue; } String caption = st.nextToken().trim(); String query = st.nextToken().trim(); String existingQuery = captionToRawQuery.get(caption); if (!Util.nullOrEmpty(existingQuery)) query = existingQuery + "|" + query; captionToRawQuery.put(caption, query); } expandQueries(); }