public class RuleImporter extends Object
Modifier and Type | Field and Description |
---|---|
private SemanticRulesConfig |
config
If this is set, imported rule bases are looked up in this config
otherwise, they are looked up as files
|
private boolean |
ignoreAutomatas
Ignore requests to read automata files.
|
private boolean |
ignoreIncludes
Ignore requests to include files.
|
Constructor and Description |
---|
RuleImporter()
Create a rule importer which will read from file
|
RuleImporter(boolean ignoreAutomatas) |
RuleImporter(boolean ignoreAutomatas,
boolean ignoreIncludes) |
RuleImporter(SemanticRulesConfig config)
Create a rule importer which will read from a config object
|
RuleImporter(SemanticRulesConfig config,
boolean ignoreAutomatas) |
RuleImporter(SemanticRulesConfig config,
boolean ignoreAutomatas,
boolean ignoreIncludes) |
Modifier and Type | Method and Description |
---|---|
private SemanticRulesConfig.Rulebase |
findRuleBaseConfig(SemanticRulesConfig config,
String ruleBaseName) |
RuleBase |
importConfig(SemanticRulesConfig.Rulebase ruleBaseConfig) |
List<RuleBase> |
importDir(String ruleBaseDir)
Imports all the rule files (files ending by "sr") in the given directory
|
RuleBase |
importFile(String fileName)
Imports semantic rules from a file
|
RuleBase |
importFile(String fileName,
String automataFile)
Imports semantic rules from a file
|
RuleBase |
importFile(String fileName,
String automataFile,
RuleBase ruleBase)
Imports semantic rules from a file
|
RuleBase |
importFromReader(Reader reader,
String sourceInfo,
String automataFile) |
RuleBase |
importFromReader(Reader reader,
String sourceName,
String automataFile,
RuleBase ruleBase)
Imports rules from a reader
|
RuleBase |
importString(String string,
String automataFile) |
RuleBase |
importString(String string,
String automataFile,
RuleBase ruleBase) |
RuleBase |
importString(String string,
String automataFile,
String sourceName) |
RuleBase |
importString(String string,
String automataFile,
String sourceName,
RuleBase ruleBase) |
void |
include(String ruleBaseName,
RuleBase ruleBase)
Read and include a rule base in another
|
RuleBase |
privateImportConfig(SemanticRulesConfig.Rulebase ruleBaseConfig)
Imports an unitialized rule base
|
RuleBase |
privateImportFile(String fileName,
String automataFile,
RuleBase ruleBase) |
private RuleBase |
privateImportFromConfig(String ruleBaseName)
Returns an unitialized rule base
|
private RuleBase |
privateImportFromDirectory(String ruleBaseName,
RuleBase ruleBase)
Returns an unitialized rule base
|
RuleBase |
privateImportFromReader(Reader reader,
String sourceName,
String automataFile,
RuleBase ruleBase)
Returns an unitialized rule base
|
void |
setAutomata(RuleBase base,
String automata) |
private static String |
shortenPath(String path)
Snips what's in from of rules/ if "rules/" is present in the string
to avoid displaying details about where application content is copied
(if rules/ is present, these rules are read from an applicatino package)
|
(package private) static String |
stripLastName(String fileName) |
private SemanticRulesConfig config
private boolean ignoreAutomatas
private boolean ignoreIncludes
public RuleImporter()
public RuleImporter(SemanticRulesConfig config)
public RuleImporter(boolean ignoreAutomatas)
public RuleImporter(boolean ignoreAutomatas, boolean ignoreIncludes)
public RuleImporter(SemanticRulesConfig config, boolean ignoreAutomatas)
public RuleImporter(SemanticRulesConfig config, boolean ignoreAutomatas, boolean ignoreIncludes)
public RuleBase importFile(String fileName) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
fileName
- the rule file to useIOException
- if the file can not be read for some reasoncom.yahoo.prelude.semantics.parser.ParseException
- if the file does not contain a valid semantic rule setpublic RuleBase importFile(String fileName, String automataFile) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
fileName
- the rule file to useautomataFile
- the automata file to use, or null to not use anyIOException
- if the file can not be read for some reasoncom.yahoo.prelude.semantics.parser.ParseException
- if the file does not contain a valid semantic rule setpublic RuleBase importFile(String fileName, String automataFile, RuleBase ruleBase) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
fileName
- the rule file to useautomataFile
- the automata file to use, or null to not use anyruleBase
- an existing rule base to import these rules into, or null
to create a newIOException
- if the file can not be read for some reasoncom.yahoo.prelude.semantics.parser.ParseException
- if the file does not contain a valid semantic rule setpublic RuleBase privateImportFile(String fileName, String automataFile, RuleBase ruleBase) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public List<RuleBase> importDir(String ruleBaseDir) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public void include(String ruleBaseName, RuleBase ruleBase) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
private RuleBase privateImportFromDirectory(String ruleBaseName, RuleBase ruleBase) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
private RuleBase privateImportFromConfig(String ruleBaseName) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
private SemanticRulesConfig.Rulebase findRuleBaseConfig(SemanticRulesConfig config, String ruleBaseName)
public RuleBase importString(String string, String automataFile) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public RuleBase importString(String string, String automataFile, String sourceName) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public RuleBase importString(String string, String automataFile, RuleBase ruleBase) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public RuleBase importString(String string, String automataFile, String sourceName, RuleBase ruleBase) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public RuleBase importConfig(SemanticRulesConfig.Rulebase ruleBaseConfig) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public RuleBase privateImportConfig(SemanticRulesConfig.Rulebase ruleBaseConfig) throws IOException, com.yahoo.prelude.semantics.parser.ParseException
IOException
com.yahoo.prelude.semantics.parser.ParseException
public RuleBase importFromReader(Reader reader, String sourceInfo, String automataFile) throws com.yahoo.prelude.semantics.parser.ParseException
com.yahoo.prelude.semantics.parser.ParseException
public RuleBase importFromReader(Reader reader, String sourceName, String automataFile, RuleBase ruleBase) throws com.yahoo.prelude.semantics.parser.ParseException
reader
- the reader containing rules on the proper syntaxsourceName
- a string describing the source of the rules used for error messagesruleBase
- an existing rule base to import the rules into, or null to create a new onecom.yahoo.prelude.semantics.parser.ParseException
- if the reader contains illegal rule syntaxpublic RuleBase privateImportFromReader(Reader reader, String sourceName, String automataFile, RuleBase ruleBase) throws com.yahoo.prelude.semantics.parser.ParseException
com.yahoo.prelude.semantics.parser.ParseException
Copyright © 2018. All rights reserved.