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