@Test public void testTagger() throws Exception { if (tagger == null) { return; } ListDataSet ds = new DefaultListDataSet(); Sample sa1 = new DefaultSample(); sa1.put(Sample.INPUT, s1); Sample sa2 = new DefaultSample(); sa2.put(Sample.INPUT, s2); ds.add(sa1); ds.add(sa2); tokenizer.tokenize(Sample.INPUT, ds); tagger.tag(ds); sa1 = ds.get(0); sa2 = ds.get(1); Matrix m1 = sa1.getAsMatrix(Tagger.TAGGED); Matrix m2 = sa2.getAsMatrix(Tagger.TAGGED); assertEquals(2, m1.getColumnCount()); assertEquals(11, m1.getRowCount()); assertEquals(2, m2.getColumnCount()); assertEquals(5, m2.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);  }