Esempio n. 1
0
 public DependencyParser() {
   ConfigService cs = new ConfigService();
   try {
     this.maltService = new MaltParserService();
     maltService.initializeParserModel(cs.getMaltParams());
   } catch (MaltChainedException e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
  public BasicDBObject parseSentence(
      String[] postagString, String filename, int sentenceNumber, int offset, int length) {
    BasicDBObject obj = new BasicDBObject();

    try {
      obj.put("filename", filename);
      obj.put("sentenceNumber", sentenceNumber);
      obj.put("offset", offset);
      obj.put("length", length);
      String[] parsedSentence = maltService.parseTokens(postagString);
      BasicDBList tokenList = new BasicDBList();
      for (String parsedToken : parsedSentence) {
        tokenList.add(getToken(parsedToken));
      }

      obj.put("tokens", tokenList);
    } catch (MaltChainedException e) {
      e.printStackTrace();
    }

    return obj;
  }
Esempio n. 3
0
  public BasicDBObject parseSentence(NLPSentence sentence) {
    BasicDBObject obj = new BasicDBObject();
    try {
      obj.put("id", sentence.getFilename() + "-" + sentence.getNumber());
      obj.put("filename", sentence.getFilename());
      obj.put("sentenceNumber", sentence.getNumber());
      obj.put("offset", sentence.getStart());
      obj.put("length", sentence.getLength());
      String[] parsedSentence = maltService.parseTokens(sentence.getPostags());

      BasicDBList tokenList = new BasicDBList();
      for (String parsedToken : parsedSentence) {
        tokenList.add(getToken(parsedToken));
      }

      obj.put("tokens", tokenList);
    } catch (MaltChainedException e) {
      e.printStackTrace();
    }

    return obj;
  }