/** * 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, List<String> filenames) throws RuntimeException { CoreMapExpressionExtractor<M> extractor = new CoreMapExpressionExtractor<>(env); for (String filename:filenames) { try (BufferedReader br = IOUtils.readerFromString(filename)) { if (verbose) log.info("Reading TokensRegex rules from " + filename); TokenSequenceParser parser = new TokenSequenceParser(); parser.updateExpressionExtractor(extractor, br); } catch (Exception ex) { throw new RuntimeException("Error parsing file: " + filename, ex); } } return extractor; }
/** * 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, List<String> filenames) throws RuntimeException { CoreMapExpressionExtractor extractor = new CoreMapExpressionExtractor(env); for (String filename:filenames) { try { System.err.println("Reading TokensRegex rules from " + filename); BufferedReader br = IOUtils.getBufferedReaderFromClasspathOrFileSystem(filename); TokenSequenceParser parser = new TokenSequenceParser(); parser.updateExpressionExtractor(extractor, br); IOUtils.closeIgnoringExceptions(br); } catch (Exception ex) { throw new RuntimeException("Error parsing file: " + filename, ex); } } return extractor; }
/** * 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, List<String> filenames) throws RuntimeException { CoreMapExpressionExtractor<M> extractor = new CoreMapExpressionExtractor<>(env); for (String filename:filenames) { try (BufferedReader br = IOUtils.readerFromString(filename)) { if (verbose) log.info("Reading TokensRegex rules from " + filename); TokenSequenceParser parser = new TokenSequenceParser(); parser.updateExpressionExtractor(extractor, br); } catch (Exception ex) { throw new RuntimeException("Error parsing file: " + filename, ex); } } return extractor; }
/** * 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, List<String> filenames) throws RuntimeException { CoreMapExpressionExtractor<M> extractor = new CoreMapExpressionExtractor<>(env); for (String filename:filenames) { try (BufferedReader br = IOUtils.readerFromString(filename)) { if (verbose) log.info("Reading TokensRegex rules from " + filename); TokenSequenceParser parser = new TokenSequenceParser(); parser.updateExpressionExtractor(extractor, br); } catch (Exception ex) { throw new RuntimeException("Error parsing file: " + filename, ex); } } return extractor; }