Beispiel #1
0
  public static void getSentPOSExamples(String resourceName, String sentencePOS) {
    InputStream is = chatbot.class.getResourceAsStream(resourceName);

    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(is));
      String sentence;
      while ((sentence = in.readLine()) != null) {
        // sentence = Global.tokenize(sentence, Global.tokenizer);

        // Parse the sentence
        Parse[] topParse = ParserTool.parseLine(sentence, Global.parser, 1);
        Parse p = topParse[0].getChildren()[0];

        if (p.getType().equals(sentencePOS)) {
          System.out.println(p.getType() + " - " + sentence);
        }
      }

    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.exit(1);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.exit(1);
    }
  }
Beispiel #2
0
  public void parseSentence(String sent) {
    // Parse the sentence
    Parse[] topParse = ParserTool.parseLine(sent, Global.parser, 3);

    // Crawl children
    for (Parse child : topParse) {
      crawl(child);
    }
  }
Beispiel #3
0
  /**
   * Luo lauseen jäsennyspuun.
   *
   * @param sentence
   * @return Viittaus jäsennyspuun juureen Parse-oliona
   */
  public Parse parse(String sentence) {
    // the parser prints to stderr when it can't parse the sentence, UGH
    PrintStream err = System.err;
    System.setErr(new Interceptor(err));
    Parse topParses[] = ParserTool.parseLine(sentence, parser, 1);
    System.setErr(err);

    return getRoot(topParses[0]);
  }
Beispiel #4
0
  public DataBean parse(Parser parser, String sentence[])
      throws InvalidFormatException, IOException {

    DataBean result = new DataBean();

    for (String s : sentence) {
      Parse topParses[] = ParserTool.parseLine(s, parser, 1);

      for (Parse p : topParses) {
        readParse(p, result);
      }
    }

    return (result);
  }