public static CoreMapNodePattern valueOf(Env env, Map<String, String> attributes) { CoreMapNodePattern p = new CoreMapNodePattern(new ArrayList<>(attributes.size())); p.populate(env, attributes, envAttrPair -> EnvLookup.lookupAnnotationKeyWithClassname(envAttrPair.first, envAttrPair.second)); return p; }
Class fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, field); if (fieldClass == null) { throw new RuntimeException( "Not recognized annotation class field \"" + field + "\" in header for mapping file " + allOptions[numOptions -1]);
private static void addAnnotationPatterns(CollectionValuedMap<Class, Pair<Pattern,Pattern>> annotationPatterns, String conf, boolean attrOnly) { String[] annoPatternStrings = conf == null ? StringUtils.EMPTY_STRING_ARRAY : conf.trim().split("\\s*,\\s*"); for (String annoPatternString:annoPatternStrings) { String[] annoPattern = annoPatternString.split("\\s*=\\s*", 2); if (annoPattern.length != 2) { throw new IllegalArgumentException("Invalid annotation to tag pattern: " + annoPatternString); } String annoKeyString = annoPattern[0]; String pattern = annoPattern[1]; Class annoKey = EnvLookup.lookupAnnotationKeyWithClassname(null, annoKeyString); if (annoKey == null) { throw new IllegalArgumentException("Cannot resolve annotation key " + annoKeyString); } Matcher m = TAG_ATTR_PATTERN.matcher(pattern); if (m.matches()) { Pattern tagPattern = toCaseInsensitivePattern(m.group(1)); Pattern attrPattern = toCaseInsensitivePattern(m.group(2)); annotationPatterns.add(annoKey, Pair.makePair(tagPattern, attrPattern)); } else { if (attrOnly) { // attribute is require throw new IllegalArgumentException("Invalid tag pattern: " + pattern + " for annotation key " + annoKeyString); } else { Pattern tagPattern = toCaseInsensitivePattern(pattern); annotationPatterns.add(annoKey, Pair.makePair(tagPattern, null)); } } } }
for (String field : headerFields) { if ( ! predefinedHeaderFields.contains(field)) { Class fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, field); if (fieldClass == null) { fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, classname);
annotationField = (Class) annoKey; } else if (annoKey instanceof String) { annotationField = EnvLookup.lookupAnnotationKeyWithClassname(env, (String) annoKey); } else if (annotationField == null) { annotationField = CoreMap.class;
public TokensRegexAnnotator(String name, Properties props) { String prefix = (name == null)? "": name + '.'; String[] files = PropertiesUtils.getStringArray(props, prefix + "rules"); env = TokenSequencePattern.getNewEnv(); env.bind("options", options); if (PropertiesUtils.getBool(props, prefix+"caseInsensitive")) { System.err.println("using case insensitive!"); env.setDefaultStringMatchFlags(NodePattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); env.setDefaultStringPatternFlags(Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); } if (files.length != 0) { extractor = CoreMapExpressionExtractor.createExtractorFromFiles(env, files); } else { extractor = null; } verbose = PropertiesUtils.getBool(props, prefix + "verbose", false); options.setTokenOffsets = PropertiesUtils.getBool(props, prefix + "setTokenOffsets", options.setTokenOffsets); options.extractWithTokens = PropertiesUtils.getBool(props, prefix + "extractWithTokens", options.extractWithTokens); options.flatten = PropertiesUtils.getBool(props, prefix + "flatten", options.flatten); String matchedExpressionsAnnotationKeyName = props.getProperty(prefix + "matchedExpressionsAnnotationKey"); if (matchedExpressionsAnnotationKeyName != null) { options.matchedExpressionsAnnotationKey = EnvLookup.lookupAnnotationKeyWithClassname(env, matchedExpressionsAnnotationKeyName); if (options.matchedExpressionsAnnotationKey == null) { String propName = prefix + "matchedExpressionsAnnotationKey"; throw new RuntimeException("Cannot determine annotation key for " + propName + '=' + matchedExpressionsAnnotationKeyName); } } }
public static CoreMapNodePattern valueOf(Env env, Map<String, String> attributes) { CoreMapNodePattern p = new CoreMapNodePattern(new ArrayList<>(attributes.size())); p.populate(env, attributes, envAttrPair -> EnvLookup.lookupAnnotationKeyWithClassname(envAttrPair.first, envAttrPair.second)); return p; }
public static CoreMapNodePattern valueOf(Env env, Map<String, String> attributes) { CoreMapNodePattern p = new CoreMapNodePattern(new ArrayList<>(attributes.size())); p.populate(env, attributes, envAttrPair -> EnvLookup.lookupAnnotationKeyWithClassname(envAttrPair.first, envAttrPair.second)); return p; }
Class fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, field); if (fieldClass == null) { throw new RuntimeException( "Not recognized annotation class field \"" + field + "\" in header for mapping file " + allOptions[numOptions -1]);
private static void addAnnotationPatterns(CollectionValuedMap<Class, Pair<Pattern,Pattern>> annotationPatterns, String conf, boolean attrOnly) { String[] annoPatternStrings = conf == null ? StringUtils.EMPTY_STRING_ARRAY : conf.trim().split("\\s*,\\s*"); for (String annoPatternString:annoPatternStrings) { String[] annoPattern = annoPatternString.split("\\s*=\\s*", 2); if (annoPattern.length != 2) { throw new IllegalArgumentException("Invalid annotation to tag pattern: " + annoPatternString); } String annoKeyString = annoPattern[0]; String pattern = annoPattern[1]; Class annoKey = EnvLookup.lookupAnnotationKeyWithClassname(null, annoKeyString); if (annoKey == null) { throw new IllegalArgumentException("Cannot resolve annotation key " + annoKeyString); } Matcher m = TAG_ATTR_PATTERN.matcher(pattern); if (m.matches()) { Pattern tagPattern = toCaseInsensitivePattern(m.group(1)); Pattern attrPattern = toCaseInsensitivePattern(m.group(2)); annotationPatterns.add(annoKey, Pair.makePair(tagPattern, attrPattern)); } else { if (attrOnly) { // attribute is require throw new IllegalArgumentException("Invalid tag pattern: " + pattern + " for annotation key " + annoKeyString); } else { Pattern tagPattern = toCaseInsensitivePattern(pattern); annotationPatterns.add(annoKey, Pair.makePair(tagPattern, null)); } } } }
for (String field : headerFields) { if ( ! predefinedHeaderFields.contains(field)) { Class fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, field); if (fieldClass == null) { fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, classname);
annotationField = (Class) annoKey; } else if (annoKey instanceof String) { annotationField = EnvLookup.lookupAnnotationKeyWithClassname(env, (String) annoKey); } else if (annotationField == null) { annotationField = CoreMap.class;
annotationField = (Class) annoKey; } else if (annoKey instanceof String) { annotationField = EnvLookup.lookupAnnotationKeyWithClassname(env, (String) annoKey); } else if (annotationField == null) { annotationField = CoreMap.class;
public TokensRegexAnnotator(String name, Properties props) { String prefix = (name == null)? "": name + '.'; String[] files = PropertiesUtils.getStringArray(props, prefix + "rules"); env = TokenSequencePattern.getNewEnv(); env.bind("options", options); if (PropertiesUtils.getBool(props, prefix+"caseInsensitive")) { System.err.println("using case insensitive!"); env.setDefaultStringMatchFlags(NodePattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); env.setDefaultStringPatternFlags(Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); } if (files.length != 0) { extractor = CoreMapExpressionExtractor.createExtractorFromFiles(env, files); } else { extractor = null; } verbose = PropertiesUtils.getBool(props, prefix + "verbose", false); options.setTokenOffsets = PropertiesUtils.getBool(props, prefix + "setTokenOffsets", options.setTokenOffsets); options.extractWithTokens = PropertiesUtils.getBool(props, prefix + "extractWithTokens", options.extractWithTokens); options.flatten = PropertiesUtils.getBool(props, prefix + "flatten", options.flatten); String matchedExpressionsAnnotationKeyName = props.getProperty(prefix + "matchedExpressionsAnnotationKey"); if (matchedExpressionsAnnotationKeyName != null) { options.matchedExpressionsAnnotationKey = EnvLookup.lookupAnnotationKeyWithClassname(env, matchedExpressionsAnnotationKeyName); if (options.matchedExpressionsAnnotationKey == null) { String propName = prefix + "matchedExpressionsAnnotationKey"; throw new RuntimeException("Cannot determine annotation key for " + propName + '=' + matchedExpressionsAnnotationKeyName); } } }