@Test public void testStringTagger() throws Exception { if (tagger == null) { return; } List<ListMatrix<MapMatrix<String, Object>>> list = tagger.tag(s1); System.out.println(list.get(0).get(0)); assertEquals(2, list.size()); assertEquals(1, list.get(0).getColumnCount()); assertEquals(11, list.get(0).getRowCount()); assertEquals(1, list.get(1).getColumnCount()); assertEquals(11, list.get(1).getRowCount()); }
public ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(String text) throws Exception { ListMatrix<ListMatrix<MapMatrix<String, Object>>> sentenceList = new DefaultListMatrix<ListMatrix<MapMatrix<String, Object>>>(); Annotation document = new Annotation(text); stanfordCoreNLP.annotate(document); List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class); for (CoreMap sentence : sentences) { ListMatrix<MapMatrix<String, Object>> tokenList = new DefaultListMatrix<MapMatrix<String, Object>>(); sentenceList.add(tokenList); for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) { MapMatrix<String, Object> tokenMap = new DefaultMapMatrix<String, Object>(); tokenList.add(tokenMap); String word = token.get(CoreAnnotations.TextAnnotation.class); tokenMap.put("Token", word); String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); tokenMap.put("POS", pos); String ne = token.get(CoreAnnotations.NamedEntityTagAnnotation.class); tokenMap.put("NE", ne); } Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class); SemanticGraph dependencies = sentence.get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class); } Map<Integer, CorefChain> graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class); return sentenceList; }
StanfordTagger extends AbstractTagger { public ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(String text) throws Exception { ListMatrix<ListMatrix<MapMatrix<String, Object>>> sentenceList = new DefaultListMatrix<ListMatrix<MapMatrix<String, Object>>>(); Annotation document = new Annotation(text); stanfordCoreNLP.annotate(document); List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class); for (CoreMap sentence : sentences) { ListMatrix<MapMatrix<String, Object>> tokenList = new DefaultListMatrix<MapMatrix<String, Object>>(); sentenceList.add(tokenList); for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) { MapMatrix<String, Object> tokenMap = new DefaultMapMatrix<String, Object>(); tokenList.add(tokenMap); String word = token.get(CoreAnnotations.TextAnnotation.class); tokenMap.put("Token", word); String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); tokenMap.put("POS", pos); String ne = token.get(CoreAnnotations.NamedEntityTagAnnotation.class); tokenMap.put("NE", ne); } Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class); SemanticGraph dependencies = sentence.get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class); } Map<Integer, CorefChain> graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class); return sentenceList; } }
StanfordTagger extends AbstractTagger { public ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(String text) throws Exception { ListMatrix<ListMatrix<MapMatrix<String, Object>>> sentenceList = new DefaultListMatrix<ListMatrix<MapMatrix<String, Object>>>(); Annotation document = new Annotation(text); stanfordCoreNLP.annotate(document); List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class); for (CoreMap sentence : sentences) { ListMatrix<MapMatrix<String, Object>> tokenList = new DefaultListMatrix<MapMatrix<String, Object>>(); sentenceList.add(tokenList); for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) { MapMatrix<String, Object> tokenMap = new DefaultMapMatrix<String, Object>(); tokenList.add(tokenMap); String word = token.get(CoreAnnotations.TextAnnotation.class); tokenMap.put("Token", word); String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); tokenMap.put("POS", pos); String ne = token.get(CoreAnnotations.NamedEntityTagAnnotation.class); tokenMap.put("NE", ne); } Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class); SemanticGraph dependencies = sentence.get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class); } Map<Integer, CorefChain> graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class); return sentenceList; } StanfordTagger();  StanfordTagger(File file);  StanfordTagger(String filename); }
StanfordTagger extends AbstractTagger { public ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(String text) throws Exception { ListMatrix<ListMatrix<MapMatrix<String, Object>>> sentenceList = new DefaultListMatrix<ListMatrix<MapMatrix<String, Object>>>(); Annotation document = new Annotation(text); stanfordCoreNLP.annotate(document); List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class); for (CoreMap sentence : sentences) { ListMatrix<MapMatrix<String, Object>> tokenList = new DefaultListMatrix<MapMatrix<String, Object>>(); sentenceList.add(tokenList); for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) { MapMatrix<String, Object> tokenMap = new DefaultMapMatrix<String, Object>(); tokenList.add(tokenMap); String word = token.get(CoreAnnotations.TextAnnotation.class); tokenMap.put("Token", word); String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); tokenMap.put("POS", pos); String ne = token.get(CoreAnnotations.NamedEntityTagAnnotation.class); tokenMap.put("NE", ne); } Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class); SemanticGraph dependencies = sentence.get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class); } Map<Integer, CorefChain> graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class); return sentenceList; } StanfordTagger();  StanfordTagger(File file);  StanfordTagger(String filename); ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(String text); ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(Matrix input); void train(ListMatrix<ListMatrix<MapMatrix<String, String>>> listMatrix); CoreLabelListMatrix tagCRF(ListMatrix<MapMatrix<String, String>> text); CoreLabelListListMatrix tagCRF(String text); static void main(String[] args); }
StanfordTagger extends AbstractTagger { public ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(String text) throws Exception { ListMatrix<ListMatrix<MapMatrix<String, Object>>> sentenceList = new DefaultListMatrix<ListMatrix<MapMatrix<String, Object>>>(); Annotation document = new Annotation(text); stanfordCoreNLP.annotate(document); List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class); for (CoreMap sentence : sentences) { ListMatrix<MapMatrix<String, Object>> tokenList = new DefaultListMatrix<MapMatrix<String, Object>>(); sentenceList.add(tokenList); for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) { MapMatrix<String, Object> tokenMap = new DefaultMapMatrix<String, Object>(); tokenList.add(tokenMap); String word = token.get(CoreAnnotations.TextAnnotation.class); tokenMap.put("Token", word); String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); tokenMap.put("POS", pos); String ne = token.get(CoreAnnotations.NamedEntityTagAnnotation.class); tokenMap.put("NE", ne); } Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class); SemanticGraph dependencies = sentence.get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class); } Map<Integer, CorefChain> graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class); return sentenceList; } StanfordTagger();  StanfordTagger(File file);  StanfordTagger(String filename); ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(String text); ListMatrix<ListMatrix<MapMatrix<String, Object>>> tag(Matrix input); void train(ListMatrix<ListMatrix<MapMatrix<String, String>>> listMatrix); CoreLabelListMatrix tagCRF(ListMatrix<MapMatrix<String, String>> text); CoreLabelListListMatrix tagCRF(String text); static void main(String[] args);  }