/** * Creates an extractor using the specified environment, and reading the rules from the given filename. * @param env * @param filename * @throws RuntimeException */ public static CoreMapExpressionExtractor createExtractorFromFile(Env env, String filename) throws RuntimeException { return createExtractorFromFiles(env, Collections.singletonList(filename)); }
/** * Creates an extractor using the specified environment, and reading the rules from the given filenames. * @param env * @param filenames * @throws RuntimeException */ public static <M extends MatchedExpression> CoreMapExpressionExtractor<M> createExtractorFromFiles(Env env, String... filenames) throws RuntimeException { return createExtractorFromFiles(env, Arrays.asList(filenames)); }
public TokensRegexAnnotator(String... files) { env = TokenSequencePattern.getNewEnv(); extractor = CoreMapExpressionExtractor.createExtractorFromFiles(env, files); verbose = false; }
public CoreMapExpressionExtractor createExtractor() { List<String> filenames = StringUtils.split(options.grammarFilename, "\\s*[,;]\\s*"); return CoreMapExpressionExtractor.createExtractorFromFiles(env, filenames); }
private CoreMapExpressionExtractor<MatchedExpression> createExtractor() { List<String> filenames = StringUtils.split(options.grammarFilename, "\\s*[,;]\\s*"); return CoreMapExpressionExtractor.createExtractorFromFiles(env, filenames); }
public KBPTokensregexExtractor(String tokensregexDir, boolean verbose) { if (verbose) logger.log("Creating TokensRegexExtractor"); // Create extractors for (RelationType rel : RelationType.values()) { String relFileNameComponent = rel.canonicalName.replaceAll(":", "_"); String path = tokensregexDir + File.separator + relFileNameComponent.replaceAll("/", "SLASH") + ".rules"; if (IOUtils.existsInClasspathOrFileSystem(path)) { List<String> listFiles = new ArrayList<>(); listFiles.add(tokensregexDir + File.separator + "defs.rules"); listFiles.add(path); if (verbose) logger.log("Rule files for relation " + rel + " is " + path); Env env = TokenSequencePattern.getNewEnv(); env.bind("collapseExtractionRules", true); env.bind("verbose", verbose); CoreMapExpressionExtractor extr = CoreMapExpressionExtractor.createExtractorFromFiles(env, listFiles).keepTemporaryTags(); rules.put(rel, extr); } } }
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); } } }
.createExtractorFromFiles(TokenSequencePattern.getNewEnv(), rules);
/** * Creates an extractor using the specified environment, and reading the rules from the given filenames. * @param env * @param filenames * @throws RuntimeException */ public static <M extends MatchedExpression> CoreMapExpressionExtractor<M> createExtractorFromFiles(Env env, String... filenames) throws RuntimeException { return createExtractorFromFiles(env, Arrays.asList(filenames)); }
/** * Creates an extractor using the specified environment, and reading the rules from the given filename. * @param env * @param filename * @throws RuntimeException */ public static CoreMapExpressionExtractor createExtractorFromFile(Env env, String filename) throws RuntimeException { return createExtractorFromFiles(env, Collections.singletonList(filename)); }
/** * Creates an extractor using the specified environment, and reading the rules from the given filenames. * @param env * @param filenames * @throws RuntimeException */ public static <M extends MatchedExpression> CoreMapExpressionExtractor<M> createExtractorFromFiles(Env env, String... filenames) throws RuntimeException { return createExtractorFromFiles(env, Arrays.asList(filenames)); }
/** * Creates an extractor using the specified environment, and reading the rules from the given filenames * @param env * @param filenames * @throws RuntimeException */ public static CoreMapExpressionExtractor createExtractorFromFiles(Env env, String... filenames) throws RuntimeException { return createExtractorFromFiles(env, Arrays.asList(filenames)); }
/** * Creates an extractor using the specified environment, and reading the rules from the given filename. * @param env * @param filename * @throws RuntimeException */ public static CoreMapExpressionExtractor createExtractorFromFile(Env env, String filename) throws RuntimeException { return createExtractorFromFiles(env, Collections.singletonList(filename)); }
public TokensRegexAnnotator(String... files) { env = TokenSequencePattern.getNewEnv(); extractor = CoreMapExpressionExtractor.createExtractorFromFiles(env, files); verbose = false; }
private CoreMapExpressionExtractor<MatchedExpression> createExtractor() { List<String> filenames = StringUtils.split(options.grammarFilename, "\\s*[,;]\\s*"); return CoreMapExpressionExtractor.createExtractorFromFiles(env, filenames); }
public TokensRegexAnnotator(String... files) { env = TokenSequencePattern.getNewEnv(); extractor = CoreMapExpressionExtractor.createExtractorFromFiles(env, files); }
public CoreMapExpressionExtractor createExtractor() { List<String> filenames = StringUtils.split(options.grammarFilename, "\\s*[,;]\\s*"); return CoreMapExpressionExtractor.createExtractorFromFiles(env, filenames); }
public CoreMapExpressionExtractor createExtractor() { List<String> filenames = StringUtils.split(options.grammarFilename, "\\s*[,;]\\s*"); return CoreMapExpressionExtractor.createExtractorFromFiles(env, filenames); }
public KBPTokensregexExtractor(String tokensregexDir, boolean verbose) { if (verbose) logger.log("Creating TokensRegexExtractor"); // Create extractors for (RelationType rel : RelationType.values()) { String relFileNameComponent = rel.canonicalName.replaceAll(":", "_"); String path = tokensregexDir + File.separator + relFileNameComponent.replaceAll("/", "SLASH") + ".rules"; if (IOUtils.existsInClasspathOrFileSystem(path)) { List<String> listFiles = new ArrayList<>(); listFiles.add(tokensregexDir + File.separator + "defs.rules"); listFiles.add(path); if (verbose) logger.log("Rule files for relation " + rel + " is " + path); Env env = TokenSequencePattern.getNewEnv(); env.bind("collapseExtractionRules", true); env.bind("verbose", verbose); CoreMapExpressionExtractor extr = CoreMapExpressionExtractor.createExtractorFromFiles(env, listFiles).keepTemporaryTags(); rules.put(rel, extr); } } }
public TokensRegexAnnotator(String name, Properties props) { String prefix = (name == null)? "":name + "."; String[] files = PropertiesUtils.getStringArray(props, prefix + "rules"); if (files == null || files.length == 0) { throw new RuntimeException("No rules specified for TokensRegexAnnotator " + name + ", check " + prefix + "rules property"); } env = TokenSequencePattern.getNewEnv(); env.bind("options", options); extractor = CoreMapExpressionExtractor.createExtractorFromFiles(env, files); verbose = PropertiesUtils.getBool(props, prefix + "verbose", verbose); 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.lookupAnnotationKey(env, matchedExpressionsAnnotationKeyName); if (options.matchedExpressionsAnnotationKey == null) { String propName = prefix + "matchedExpressionsAnnotationKey"; throw new RuntimeException("Cannot determine annotation key for " + propName + "=" + matchedExpressionsAnnotationKeyName); } } }