private static void execFindConcordancesDoeCorpus(String[] args) { int limit = 1000000; if (args.length > 2) limit = 100; String searchString = args[1]; execParseDoeCorpus(false /* doSave */); ArrayList<DOECorpusLine> allLines = new ArrayList<DOECorpusLine>(); HashMap<String, ArrayList<DOECorpusLine>> matches = corpus.getConcordances(searchString); for (ArrayList<DOECorpusLine> list : matches.values()) allLines.addAll(list); if (allLines.size() > limit) allLines = getRandomSelectionFromList(allLines, limit); System.out.println("Concordances for search term " + searchString + " with limit " + limit); for (DOECorpusLine line : allLines) { System.out.println( "Doc ID: " + line.getShortTitle() + "; Line ID: " + line.getLineID() + "; " + line.getLine()); } }
/** * @param searchString * @param matches */ private static void printSearchResults( String searchString, HashMap<String, ArrayList<DOECorpusLine>> matches) { // Print results System.out.println( "Found the search string " + searchString + " in the following " + matches.size() + " docs and lines: "); for (String key : matches.keySet()) { System.out.println("Doc ID: " + key); int i = 0; for (DOECorpusLine line : matches.get(key)) { System.out.println( "\t" + i + ") " + line.getLineID() + " - " + line.getLine().replace(searchString, "@@" + searchString + "@@")); i++; } } }