本文整理汇总了Java中net.didion.jwnl.JWNL类的典型用法代码示例。如果您正苦于以下问题:Java JWNL类的具体用法?Java JWNL怎么用?Java JWNL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JWNL类属于net.didion.jwnl包,在下文中一共展示了JWNL类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length != 1) {
System.out.println(USAGE);
System.exit(-1);
}
String propsFile = args[0];
try {
// initialize JWNL (this must be done before JWNL can be used)
JWNL.initialize(new FileInputStream(propsFile));
new Examples().go();
} catch (Exception ex) {
ex.printStackTrace();
System.exit(-1);
}
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:17,代码来源:Examples.java
示例2: processInput
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public void processInput() {
if( infoPath.length() <= 0 )
System.err.println("No info file given");
else {
// Load WordNet first
try {
JWNL.initialize(new FileInputStream(wordnetPath)); // WordNet
} catch( Exception ex ) { ex.printStackTrace(); }
// Read the Parser
_parser = Ling.createParser(serializedGrammar);
_options = _parser.getOp();
System.out.println("Processing info file " + infoPath);
infoFile.readFromFile(new File(infoPath));
if( onlyEvents ) infoToEventFeatures(infoFile);
else infoToRelationFeatures(infoFile);
// Save the indices, we may have added new words
indices.indexToFile(indices.wordIndex(),"new-wordIndex.txt");
indices.indexToFile(indices.lemmaIndex(),"new-lemmaIndex.txt");
indices.indexToFile(indices.synsetIndex(),"new-synsetIndex.txt");
}
}
开发者ID:nchambers,项目名称:schemas,代码行数:25,代码来源:EventParser.java
示例3: processInput
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public void processInput() {
// Load WordNet first
try {
JWNL.initialize(new FileInputStream(wordnetPath)); // WordNet
} catch( Exception ex ) { ex.printStackTrace(); }
// Start the Parser
parser = Ling.createParser(serializedGrammar);
options = parser.getOp();
// Load the datafiles
loadData();
// Create the features
String shorty = parsefile.substring(parsefile.lastIndexOf("/")+1,
parsefile.length());
createEventFeatures(shorty);
// createRelationFeatures(infoFile);
}
开发者ID:nchambers,项目名称:schemas,代码行数:20,代码来源:GigaEventParser.java
示例4: getDictionary
import net.didion.jwnl.JWNL; //导入依赖的package包/类
private static Dictionary getDictionary() {
synchronized (WordNet.class) {
if (dictionary == null) {
JWNL.shutdown(); // in case it was previously initialized
try {
final String properties = Resources.toString(
WordNet.class.getResource("jwnl.xml"), Charsets.UTF_8).replace(
"DICTIONARY_PATH_PLACEHOLDER", dictionaryPath);
final InputStream stream = new ByteArrayInputStream(
properties.getBytes(Charsets.UTF_8));
JWNL.initialize(stream);
dictionary = Dictionary.getInstance();
} catch (final Throwable ex) {
JWNL.shutdown();
throw new Error("Cannot initialize JWNL using dictionary path '"
+ dictionaryPath + "'", ex);
}
}
return dictionary;
}
}
开发者ID:dkmfbk,项目名称:pikes,代码行数:22,代码来源:WordNet.java
示例5: toString
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public String toString() {
if (_cachedToString == null) {
StringBuffer words = new StringBuffer();
for (int i = 0; i < getWordsSize(); ++i) {
if (i > 0) words.append(", ");
words.append(getWord(i).getLemma());
}
if (getGloss() != null)
words.append(" -- (" + getGloss() + ")");
_cachedToString =
JWNL.resolveMessage("DATA_TOSTRING_009", new Object[]{new Long(getOffset()), getPOS(), words.toString()});
}
return _cachedToString;
}
开发者ID:duguyue100,项目名称:chomsky,代码行数:17,代码来源:Synset.java
示例6: toString
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public String toString() {
if (_cachedToString == null) {
String str = "";
if (size() == 0) {
str = JWNL.resolveMessage("DATA_TOSTRING_003");
} else {
StringBuffer buf = new StringBuffer();
Iterator itr = getValidPOSSet().iterator();
while (itr.hasNext()) {
buf.append(getIndexWord((POS)itr.next()).toString());
}
str = buf.toString();
}
_cachedToString = JWNL.resolveMessage("DATA_TOSTRING_004", str);
}
return _cachedToString;
}
开发者ID:duguyue100,项目名称:chomsky,代码行数:18,代码来源:IndexWordSet.java
示例7: testGetWordSenses
import net.didion.jwnl.JWNL; //导入依赖的package包/类
/**
* Pulls a noun "tank" from the dictionary and checks to see if it has 5 senses.
*
*/
public void testGetWordSenses() {
try {
JWNL.initialize(TestDefaults.getInputStream());
IndexWord word = Dictionary.getInstance().getIndexWord(POS.NOUN, "tank");
assertTrue(word.getSenseCount() == 5);
word = Dictionary.getInstance().getIndexWord(POS.VERB, "eat");
assertTrue(word.getSenseCount() == 6);
word = Dictionary.getInstance().getIndexWord(POS.ADJECTIVE, "quick");
assertTrue(word.getSenseCount() == 6);
word = Dictionary.getInstance().getIndexWord(POS.ADJECTIVE, "big");
assertTrue(word.getSenseCount() == 13);
} catch(JWNLException e) {
fail("Exception in testGetSenses caught");
e.printStackTrace();
}
}
开发者ID:duguyue100,项目名称:chomsky,代码行数:26,代码来源:Wordnet30SynsetTest.java
示例8: init
import net.didion.jwnl.JWNL; //导入依赖的package包/类
/** Initialise this resource, and return it. */
public Resource init() throws ResourceInstantiationException {
if (null == this.propertyUrl) {
throw new ResourceInstantiationException("property file not set");
}
try {
InputStream inProps = this.propertyUrl.openStream();
JWNL.initialize(inProps);
this.wnDictionary = Dictionary.getInstance();
Assert.assertNotNull(this.wnDictionary);
}
catch(Exception e) {
throw new ResourceInstantiationException(e);
}
return this;
}
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:22,代码来源:JWNLWordNetImpl.java
示例9: unload
import net.didion.jwnl.JWNL; //导入依赖的package包/类
@Override
public void unload() {
this.mCache.clear();
if (mDictionary != null)
mDictionary.close();
if (mInit) {
Dictionary.uninstall();
JWNL.shutdown();
}
}
开发者ID:SI3P,项目名称:supWSD,代码行数:14,代码来源:JWNLLemmatizer.java
示例10: unload
import net.didion.jwnl.JWNL; //导入依赖的package包/类
@Override
public void unload() {
if(mDictionary!=null)
mDictionary.close();
if(mInit){
Dictionary.uninstall();
JWNL.shutdown();
}
}
开发者ID:SI3P,项目名称:supWSD,代码行数:12,代码来源:SensEvalMNS.java
示例11: WordNet
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public WordNet(String wordnetPath) {
// Load WordNet
try {
if( wordnetPath.length() > 0 ) {
JWNL.initialize(new FileInputStream(wordnetPath));
System.out.println("WordNet initialized from " + wordnetPath);
}
else
System.out.println("ERROR: could not find wordnetPath");
} catch( Exception ex ) { ex.printStackTrace(); }
}
开发者ID:nchambers,项目名称:probschemas,代码行数:12,代码来源:WordNet.java
示例12: Wordnet
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public Wordnet() {
String propsFile = "file_properties.xml";
try {
JWNL.initialize(new FileInputStream(propsFile));
dict = Dictionary.getInstance();
} catch (Exception ex) {
ex.printStackTrace();
}
}
开发者ID:nikolamilosevic86,项目名称:Marvin,代码行数:10,代码来源:Wordnet.java
示例13: FeatureIndices
import net.didion.jwnl.JWNL; //导入依赖的package包/类
public FeatureIndices(String[] args) {
handleParameters(args);
// Load WordNet first
try {
JWNL.initialize(new FileInputStream(wordnetPath)); // WordNet
} catch( Exception ex ) { ex.printStackTrace(); }
// Load indices if -preload flag was given
if( preload ) loadIndices();
}
开发者ID:nchambers,项目名称:schemas,代码行数:12,代码来源:FeatureIndices.java
示例14: ConvertToRoots
import net.didion.jwnl.JWNL; //导入依赖的package包/类
ConvertToRoots(String args[]) {
handleParameters(args);
// Load WordNet
try {
JWNL.initialize(new FileInputStream(wordnetPath)); // WordNet
} catch( Exception ex ) { ex.printStackTrace(); }
}
开发者ID:nchambers,项目名称:schemas,代码行数:9,代码来源:ConvertToRoots.java
示例15: 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);
}
开发者ID:claritylab,项目名称:lucida,代码行数:48,代码来源:WordNetAnswerTypeMapping.java
示例16: 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);
}
开发者ID:claritylab,项目名称:lucida,代码行数:43,代码来源:FocusFinder.java
示例17: initialize
import net.didion.jwnl.JWNL; //导入依赖的package包/类
/**
* Initializes the wrapper for the WordNet dictionary.
*
* @param properties property file
*/
public static boolean initialize(String properties) {
try {
File file = new File(properties);
JWNL.initialize(new FileInputStream(file));
dict = net.didion.jwnl.dictionary.Dictionary.getInstance();
} catch (Exception e) {
return false;
}
return true;
}
开发者ID:claritylab,项目名称:lucida,代码行数:18,代码来源:WordNet.java
示例18: initializeJWNL
import net.didion.jwnl.JWNL; //导入依赖的package包/类
/**
* Used by JWNL-based Morphy implementations.
* @return
*/
public static boolean initializeJWNL()
{
try
{
JWNL.initialize(
getJWNLConfigFileStream(
WORDNET_PROPERTY,
JWNL_FILE_PROPERTIES_XML,
JWNL_DIR_PROPERTIES_XML
)
);
return true;
}
catch (Exception ex)
{
String estr = "Error: Unable to initialize JWNL: " + ex.toString() + "\n";
Throwable th = ex.getCause();
while (th != null)
{
estr += th.toString() + "\n";
th = th.getCause();
}
System.err.println(estr);
return false;
}
}
开发者ID:opencog,项目名称:relex,代码行数:31,代码来源:MorphyFactory.java
示例19: FileManagerImpl
import net.didion.jwnl.JWNL; //导入依赖的package包/类
/**
* Construct a file manager backed by a set of files contained
* in the default WN search directory.
*/
public FileManagerImpl(String searchDir, Class dictionaryFileType) throws IOException {
checkFileType(dictionaryFileType);
_files = new DictionaryCatalogSet(searchDir, dictionaryFileType);
_files.open();
String sense = System.getProperty("file.separator") + "index.sense";
if (JWNL.getVersion().getNumber() < 2.1) {
sense = System.getProperty("file.separator") + "sense.idx";
}
senseFile = new File(searchDir + sense);
Grep.setFile(senseFile);
}
开发者ID:duguyue100,项目名称:chomsky,代码行数:17,代码来源:FileManagerImpl.java
示例20: toString
import net.didion.jwnl.JWNL; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public String toString() {
if (_cachedToString == null) {
_cachedToString =
JWNL.resolveMessage("DATA_TOSTRING_001", new Object[] { getLemma(), getExceptionsAsString() });
}
return _cachedToString;
}
开发者ID:duguyue100,项目名称:chomsky,代码行数:11,代码来源:Exc.java
注:本文中的net.didion.jwnl.JWNL类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论