Exemple #1
0
  private static void execSearchDoeCorpus(String[] args) {
    String searchString = args[1];
    boolean interactive = false;

    // Load corpus first
    execParseDoeCorpus(false /* doSave */);

    // Check mode
    if (args.length > 2) if (args[2].equals("i")) interactive = true;

    // Search for string
    HashMap<String, ArrayList<DOECorpusLine>> matches = corpus.getConcordances(searchString);
    printSearchResults(searchString, matches);

    if (interactive) {
      do {
        System.out.println("Enter the sear term here (or QUIT to exit):");
        Scanner scanIn = new Scanner(System.in);
        searchString = scanIn.nextLine();
        scanIn.close();

        if (!("QUIT".equals(searchString))) {
          matches = corpus.getConcordances(searchString);
          printSearchResults(searchString, matches);
        }
      } while (!("QUIT".equals(searchString)));
    }
  }
Exemple #2
0
  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());
    }
  }