Package com.yahoo.prelude.semantics
Class RuleImporter
java.lang.Object
com.yahoo.prelude.semantics.RuleImporter
Imports rule bases from various sources.
- Author:
- bratseth
-
Constructor Summary
ConstructorDescriptionRuleImporter
(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
Modifier and TypeMethodDescriptionimportConfig
(SemanticRulesConfig.Rulebase ruleBaseConfig) Imports all the rule files (files ending by "sr") in the given directoryimportFile
(String fileName) Imports semantic rules from a fileimportFile
(String fileName, String automataFile) Imports semantic rules from a fileimportFromReader
(Reader reader, String sourceInfo, String automataFile) importFromReader
(Reader reader, String sourceName, String automataFile, RuleBase ruleBase) Imports rules from a readerimportString
(String string, String automataFile) importString
(String string, String automataFile, RuleBase ruleBase) importString
(String string, String automataFile, String sourceName) importString
(String string, String automataFile, String sourceName, RuleBase ruleBase) void
Read and include a rule base in anotherprivateImportConfig
(SemanticRulesConfig.Rulebase ruleBaseConfig) Imports an unitialized rule baseprivateImportFile
(String fileName, String automataFile) privateImportFromReader
(Reader reader, String sourceName, String automataFile, RuleBase ruleBase) Returns an unitialized rule basevoid
setAutomata
(RuleBase base, String automata)
-
Constructor Details
-
RuleImporter
public RuleImporter(com.yahoo.language.Linguistics linguistics) Create a rule importer which will read from file -
RuleImporter
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 Details
-
importFile
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
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
Imports all the rule files (files ending by "sr") in the given directory- Throws:
IOException
ParseException
-
include
Read and include a rule base in another- Throws:
IOException
ParseException
-
setAutomata
-
importString
- 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
-