本文整理汇总了Java中net.didion.jwnl.JWNL.isInitialized方法的典型用法代码示例。如果您正苦于以下问题:Java JWNL.isInitialized方法的具体用法?Java JWNL.isInitialized怎么用?Java JWNL.isInitialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.didion.jwnl.JWNL
的用法示例。
在下文中一共展示了JWNL.isInitialized方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import net.didion.jwnl.JWNL; //导入方法依赖的package包/类
/**
* Initializes static resources. The input properties that must be defined are:
* <ul>
* <li>jwnl.configuration : </p> the location of the configuration file for JWNL
* <li>edu.cmu.lti.javelin.qa.english.WordNetAnswerTypeMapping.mapFile :
* <p> the location of the file specifying a mapping from WordNet synsets
* to answer subtypes. The one-to-many mapping must be specified
* one element per line, with the domain and range values separated by a comma.
* Blank lines and lines beginning with "#" are ignored. WordNet synsets must be
* represented by concatenating the list of lemmas in the synset, separating them
* with a dash ("-"), followed by another "-" and the database file offset of the synset.
* (Note: this offset value will vary with the version of WordNet used.)</p>
* Thus, an example of an element of the mapping is:</p>
* <code>body_of_water-water-8651117,ocean</code>
* </ul>
* @throws Exception if one of the required properties is not defined.
*/
public static void initialize() throws Exception {
if (isInitialized()) return;
if (!JWNL.isInitialized()) {
String file_properties = System.getProperty("jwnl.configuration");
if (file_properties == null)
throw new Exception("Required property 'jwnl.configuration' is undefined");
JWNL.initialize(new FileInputStream(file_properties));
}
pUtils = PointerUtils.getInstance();
Properties properties = Properties.loadFromClassName(WordNetAnswerTypeMapping.class.getName());
String wnAtypeMapFile = properties.getProperty("mapFile");
if (wnAtypeMapFile == null)
throw new RuntimeException("Required parameter mapFile is undefined");
BufferedReader in = new BufferedReader(new FileReader(wnAtypeMapFile));
String line;
wnAtypeMap = new HashMap<String, String>();
wnAtypeMapKeys = new ArrayList<String>();
while ((line = in.readLine()) != null) {
if (line.matches("#.*") || line.matches("\\s*")) continue;
String[] strs = line.split(",");
wnAtypeMap.put(strs[0],strs[1]);
wnAtypeMapKeys.add(strs[0]);
}
in.close();
setInitialized(true);
}
示例2: initialize
import net.didion.jwnl.JWNL; //导入方法依赖的package包/类
/**
* Initializes static resources. The input properties which must be defined are:
* <ul>
* <li> edu.cmu.lti.javelin.qa.english.FocusFinder.treeTemplatesFile :
* the location of a file containing tree templates to use. Each tree template
* must be specified on one line. Blank lines and lines beginning with "#"
* are ignored. A tree template is a parenthesized syntactic parse tree which
* can be used as an underspecified template tree to unify with a real syntactic
* parse tree. See {@link edu.cmu.lti.chineseNLP.util.TreeHelper#extractNode
* TreeHelper.extractNode} for more details.
* </ul>
* @throws Exception if the required input property is not defined
*/
public static void initialize() throws Exception {
// return if already initialized
if (isInitialized()) return;
Properties properties = Properties.loadFromClassName(FocusFinder.class.getName());
// initialize JWNL
if (!JWNL.isInitialized()) {
String file_properties = System.getProperty("jwnl.configuration");
if (file_properties == null)
throw new Exception("Required property 'jwnl.configuration' is undefined");
JWNL.initialize(new FileInputStream(file_properties));
}
// load tree templates file
treeTemplatesFile = properties.getProperty("treeTemplatesFile");
if (treeTemplatesFile == null)
throw new Exception("Required property treeTemplatesFile is undefined");
BufferedReader in = new BufferedReader(new FileReader(treeTemplatesFile));
String line;
treeTemplates = new ArrayList<Tree>();
while ((line = in.readLine()) != null) {
if (line.matches("#.*") || line.matches("\\s*")) continue;
treeTemplates.add(TreeHelper.buildTree(line, Tree.ENGLISH));
}
in.close();
setInitialized(true);
}
示例3: load
import net.didion.jwnl.JWNL; //导入方法依赖的package包/类
@Override
public void load() throws Exception {
if(this.isEnabled()){
super.load();
}
mInit = !JWNL.isInitialized();
if (mInit) {
try(InputStream inputStream = new FileInputStream("resources/wndictionary/prop.xml");) {
JWNL.initialize(inputStream);
}
}
mDictionary = Dictionary.getInstance();
}
示例4: load
import net.didion.jwnl.JWNL; //导入方法依赖的package包/类
@Override
public void load() throws IOException, JWNLException {
mInit = !JWNL.isInitialized();
if (mInit) {
try(InputStream inputStream = new FileInputStream(this.getDefaultModel())) {
JWNL.initialize(inputStream);
}
}
mDictionary = Dictionary.getInstance();
}