|
11 | 11 |
|
12 | 12 | import edu.stanford.nlp.io.IOUtils; |
13 | 13 | import edu.stanford.nlp.ling.*; |
14 | | -import edu.stanford.nlp.patterns.PatternsAnnotations; |
15 | 14 | import edu.stanford.nlp.semgraph.SemanticGraph; |
16 | 15 | import edu.stanford.nlp.semgraph.SemanticGraphFactory; |
17 | 16 | import edu.stanford.nlp.trees.*; |
@@ -138,14 +137,21 @@ public void testMacro() throws IOException { |
138 | 137 | throw new RuntimeException("failed!"); |
139 | 138 | } |
140 | 139 |
|
| 140 | + private static class PatternLabelAnnotation implements CoreAnnotation<String> { |
| 141 | + @Override |
| 142 | + public Class<String> getType() { |
| 143 | + return String.class; |
| 144 | + } |
| 145 | + } |
| 146 | + |
141 | 147 | public void testEnv() throws IOException { |
142 | 148 | SemanticGraph h = SemanticGraph.valueOf("[married/VBN nsubjpass>Hughes/NNP auxpass>was/VBD nmod:to>Gracia/NNP]"); |
143 | | - h.getFirstRoot().set(PatternsAnnotations.PatternLabel1.class,"YES"); |
| 149 | + h.getFirstRoot().set(PatternLabelAnnotation.class,"YES"); |
144 | 150 | //SemanticGraph t = SemanticGraph |
145 | 151 | // .valueOf("[loved/VBD\nnsubj:Hughes/NNP\ndobj:[wife/NN poss:his/PRP$ appos:Gracia/NNP]\nconj_and:[obsessed/JJ\ncop:was/VBD\nadvmod:absolutely/RB\nprep_with:[Elicia/NN poss:his/PRP$ amod:little/JJ nn:daughter/NN]]]"); |
146 | 152 | String macro = "macro WORD = married"; |
147 | 153 | Env env = new Env(); |
148 | | - env.bind("pattern1",PatternsAnnotations.PatternLabel1.class); |
| 154 | + env.bind("pattern1",PatternLabelAnnotation.class); |
149 | 155 | String pattern = "({pattern1:YES}=parent >>nsubjpass {}=node)"; |
150 | 156 | List<SemgrexPattern> pats = SemgrexBatchParser.compileStream(new ByteArrayInputStream((macro + "\n" + pattern).getBytes(StandardCharsets.UTF_8)), env); |
151 | 157 | SemgrexPattern pat3 = pats.get(0); |
|
0 commit comments