Package com.yahoo.prelude.semantics
Class RuleImporter
- java.lang.Object
-
- com.yahoo.prelude.semantics.RuleImporter
-
public class RuleImporter extends java.lang.Object
Imports rule bases from various sources.- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description RuleImporter()
Create a rule importer which will read from fileRuleImporter(boolean ignoreAutomatas)
RuleImporter(boolean ignoreAutomatas, boolean ignoreIncludes)
RuleImporter(SemanticRulesConfig config)
Create a rule importer which will read from a config objectRuleImporter(SemanticRulesConfig config, boolean ignoreAutomatas)
RuleImporter(SemanticRulesConfig config, boolean ignoreAutomatas, boolean ignoreIncludes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RuleBase
importConfig(SemanticRulesConfig.Rulebase ruleBaseConfig)
java.util.List<RuleBase>
importDir(java.lang.String ruleBaseDir)
Imports all the rule files (files ending by "sr") in the given directoryRuleBase
importFile(java.lang.String fileName)
Imports semantic rules from a fileRuleBase
importFile(java.lang.String fileName, java.lang.String automataFile)
Imports semantic rules from a fileRuleBase
importFile(java.lang.String fileName, java.lang.String automataFile, RuleBase ruleBase)
Imports semantic rules from a fileRuleBase
importFromReader(java.io.Reader reader, java.lang.String sourceInfo, java.lang.String automataFile)
RuleBase
importFromReader(java.io.Reader reader, java.lang.String sourceName, java.lang.String automataFile, RuleBase ruleBase)
Imports rules from a readerRuleBase
importString(java.lang.String string, java.lang.String automataFile)
RuleBase
importString(java.lang.String string, java.lang.String automataFile, RuleBase ruleBase)
RuleBase
importString(java.lang.String string, java.lang.String automataFile, java.lang.String sourceName)
RuleBase
importString(java.lang.String string, java.lang.String automataFile, java.lang.String sourceName, RuleBase ruleBase)
void
include(java.lang.String ruleBaseName, RuleBase ruleBase)
Read and include a rule base in anotherRuleBase
privateImportConfig(SemanticRulesConfig.Rulebase ruleBaseConfig)
Imports an unitialized rule baseRuleBase
privateImportFile(java.lang.String fileName, java.lang.String automataFile, RuleBase ruleBase)
RuleBase
privateImportFromReader(java.io.Reader reader, java.lang.String sourceName, java.lang.String automataFile, RuleBase ruleBase)
Returns an unitialized rule basevoid
setAutomata(RuleBase base, java.lang.String automata)
-
-
-
Constructor Detail
-
RuleImporter
public RuleImporter()
Create a rule importer which will read from file
-
RuleImporter
public RuleImporter(SemanticRulesConfig config)
Create a rule importer which will read from a config object
-
RuleImporter
public RuleImporter(boolean ignoreAutomatas)
-
RuleImporter
public RuleImporter(boolean ignoreAutomatas, boolean ignoreIncludes)
-
RuleImporter
public RuleImporter(SemanticRulesConfig config, boolean ignoreAutomatas)
-
RuleImporter
public RuleImporter(SemanticRulesConfig config, boolean ignoreAutomatas, boolean ignoreIncludes)
-
-
Method Detail
-
importFile
public RuleBase importFile(java.lang.String fileName) throws java.io.IOException, ParseException
Imports semantic rules from a file- Parameters:
fileName
- the rule file to use- Throws:
java.io.IOException
- if the file can not be read for some reasonParseException
- if the file does not contain a valid semantic rule set
-
importFile
public RuleBase importFile(java.lang.String fileName, java.lang.String automataFile) throws java.io.IOException, ParseException
Imports semantic rules from a file- Parameters:
fileName
- the rule file to useautomataFile
- the automata file to use, or null to not use any- Throws:
java.io.IOException
- if the file can not be read for some reasonParseException
- if the file does not contain a valid semantic rule set
-
importFile
public RuleBase importFile(java.lang.String fileName, java.lang.String automataFile, RuleBase ruleBase) throws java.io.IOException, ParseException
Imports semantic rules from a file- Parameters:
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 new- Throws:
java.io.IOException
- if the file can not be read for some reasonParseException
- if the file does not contain a valid semantic rule set
-
privateImportFile
public RuleBase privateImportFile(java.lang.String fileName, java.lang.String automataFile, RuleBase ruleBase) throws java.io.IOException, ParseException
- Throws:
java.io.IOException
ParseException
-
importDir
public java.util.List<RuleBase> importDir(java.lang.String ruleBaseDir) throws java.io.IOException, ParseException
Imports all the rule files (files ending by "sr") in the given directory- Throws:
java.io.IOException
ParseException
-
include
public void include(java.lang.String ruleBaseName, RuleBase ruleBase) throws java.io.IOException, ParseException
Read and include a rule base in another- Throws:
java.io.IOException
ParseException
-
setAutomata
public void setAutomata(RuleBase base, java.lang.String automata)
-
importString
public RuleBase importString(java.lang.String string, java.lang.String automataFile) throws java.io.IOException, ParseException
- Throws:
java.io.IOException
ParseException
-
importString
public RuleBase importString(java.lang.String string, java.lang.String automataFile, java.lang.String sourceName) throws java.io.IOException, ParseException
- Throws:
java.io.IOException
ParseException
-
importString
public RuleBase importString(java.lang.String string, java.lang.String automataFile, RuleBase ruleBase) throws java.io.IOException, ParseException
- Throws:
java.io.IOException
ParseException
-
importString
public RuleBase importString(java.lang.String string, java.lang.String automataFile, java.lang.String sourceName, RuleBase ruleBase) throws java.io.IOException, ParseException
- Throws:
java.io.IOException
ParseException
-
importConfig
public RuleBase importConfig(SemanticRulesConfig.Rulebase ruleBaseConfig) throws java.io.IOException, ParseException
- Throws:
java.io.IOException
ParseException
-
privateImportConfig
public RuleBase privateImportConfig(SemanticRulesConfig.Rulebase ruleBaseConfig) throws java.io.IOException, ParseException
Imports an unitialized rule base- Throws:
java.io.IOException
ParseException
-
importFromReader
public RuleBase importFromReader(java.io.Reader reader, java.lang.String sourceInfo, java.lang.String automataFile) throws ParseException
- Throws:
ParseException
-
importFromReader
public RuleBase importFromReader(java.io.Reader reader, java.lang.String sourceName, java.lang.String automataFile, RuleBase ruleBase) throws ParseException
Imports rules from a reader- Parameters:
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 one- Returns:
- the rule base containing the rules added from the reader
- Throws:
ParseException
- if the reader contains illegal rule syntax
-
privateImportFromReader
public RuleBase privateImportFromReader(java.io.Reader reader, java.lang.String sourceName, java.lang.String automataFile, RuleBase ruleBase) throws ParseException
Returns an unitialized rule base- Throws:
ParseException
-
-