/** @param args */ public static void main(String[] args) { try { DependencyGraph graph = new CreateDependencyGraph().run(); System.out.println(graph); } catch (MaltChainedException e) { System.err.println("MaltParser exception : " + e.getMessage()); } }
public DependencyParser() { ConfigService cs = new ConfigService(); try { this.maltService = new MaltParserService(); maltService.initializeParserModel(cs.getMaltParams()); } catch (MaltChainedException e) { e.printStackTrace(); } }
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; }
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; }