/** * Creates an extractor using the specified environment, and reading the rules from the given string * @param env * @param str * @throws IOException, ParseException */ public static CoreMapExpressionExtractor createExtractorFromString(Env env, String str) throws IOException, ParseException, TokenSequenceParseException { TokenSequenceParser parser = new TokenSequenceParser(); CoreMapExpressionExtractor extractor = parser.getExpressionExtractor(env, new StringReader(str)); return extractor; }
/** * Creates an extractor using the specified environment, and reading the rules from the given string * @param env * @param str * @throws IOException, ParseException */ public static CoreMapExpressionExtractor createExtractorFromString(Env env, String str) throws IOException, ParseException { TokenSequenceParser parser = new TokenSequenceParser(); CoreMapExpressionExtractor extractor = parser.getExpressionExtractor(env, new StringReader(str)); return extractor; }
/** * Creates an extractor using the specified environment, and reading the rules from the given string * @param env * @param str * @throws IOException, ParseException */ public static CoreMapExpressionExtractor createExtractorFromString(Env env, String str) throws IOException, ParseException, TokenSequenceParseException { TokenSequenceParser parser = new TokenSequenceParser(); CoreMapExpressionExtractor extractor = parser.getExpressionExtractor(env, new StringReader(str)); return extractor; }
/** * Creates an extractor using the specified environment, and reading the rules from the given string * @param env * @param str * @throws IOException, ParseException */ public static CoreMapExpressionExtractor createExtractorFromString(Env env, String str) throws IOException, ParseException, TokenSequenceParseException { TokenSequenceParser parser = new TokenSequenceParser(); CoreMapExpressionExtractor extractor = parser.getExpressionExtractor(env, new StringReader(str)); return extractor; }
/** * 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 { try { System.err.println("Reading TokensRegex rules from " + filename); BufferedReader br = IOUtils.getBufferedReaderFromClasspathOrFileSystem(filename); TokenSequenceParser parser = new TokenSequenceParser(); CoreMapExpressionExtractor extractor = parser.getExpressionExtractor(env, br); IOUtils.closeIgnoringExceptions(br); return extractor; } catch (Exception ex) { throw new RuntimeException("Error parsing file: " + filename, ex); } }