Skip to content

Commit f556a85

Browse files
committed
Attempt to implement the match
1 parent ef889a6 commit f556a85

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/edu/stanford/nlp/semgraph/semgrex/NodePattern.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,19 @@ public boolean nodeAttrMatch(IndexedWord node, final SemanticGraph sg, boolean i
236236
for (Pair<String, Attribute> partialAttribute : partialAttributes) {
237237
String annotation = partialAttribute.first();
238238
Attribute attr = partialAttribute.second();
239+
239240
Class clazz = Env.lookupAnnotationKey(env, annotation);
240-
// TODO
241+
Object rawmap = node.get(clazz);
242+
if (!(rawmap instanceof Map))
243+
throw new RuntimeException("Can only use partial attributes with Maps... this should have been checked at creation time!");
244+
Map<String, ?> map = (Map) rawmap;
245+
246+
Object value = map.get(attr.key);
247+
final String nodeValue = (value == null) ? null : value.toString();
248+
boolean matches = checkMatch(attr, ignoreCase, nodeValue);
249+
if (!matches) {
250+
return negDesc;
251+
}
241252
}
242253

243254
// System.out.println("matches");

0 commit comments

Comments
 (0)