当前位置: 首页>>代码示例>>Java>>正文


Java JWNLException.printStackTrace方法代码示例

本文整理汇总了Java中net.sf.extjwnl.JWNLException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java JWNLException.printStackTrace方法的具体用法?Java JWNLException.printStackTrace怎么用?Java JWNLException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.extjwnl.JWNLException的用法示例。


在下文中一共展示了JWNLException.printStackTrace方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDerivedAdjective

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
/**
	 * Returns the derived adjective with the same word form for the most common sense of the given noun if exists.
	 *
	 * @param noun the noun
	 */
	public String getDerivedAdjective(String noun) {
		try {
			IndexWord nounIW = dict.lookupIndexWord(POS.NOUN, noun);

			List<Synset> senses = nounIW.getSenses();

			Synset mainSense = senses.get(0);

			List<Pointer> pointers = mainSense.getPointers(PointerType.DERIVATION);

			for (Pointer pointer : pointers) {
				Synset derivedSynset = pointer.getTargetSynset();
				if(derivedSynset.getPOS() == POS.ADJECTIVE) {
//					return derivedSynset.getWords().get(0).getLemma();
				}
				if(derivedSynset.getPOS() == POS.VERB) {
					System.out.println(derivedSynset);
				}
			}
		} catch (JWNLException e) {
			e.printStackTrace();
		}
		return null;
	}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:30,代码来源:WordNetUtils.java

示例2: getDerivedAdjective

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
/**
 * Returns the derived adjective with the same word form for the most common
 * sense of the given noun if exists.
 *
 * @param noun
 *            the noun
 */
public String getDerivedAdjective(String noun) {
	try {
		IndexWord nounIW = dict.lookupIndexWord(POS.NOUN, noun);

		List<Synset> senses = nounIW.getSenses();

		Synset mainSense = senses.get(0);

		List<Pointer> pointers = mainSense.getPointers(PointerType.DERIVATION);

		for (Pointer pointer : pointers) {
			Synset derivedSynset = pointer.getTargetSynset();
			if (derivedSynset.getPOS() == POS.ADJECTIVE) {
				// return derivedSynset.getWords().get(0).getLemma();
			}
			if (derivedSynset.getPOS() == POS.VERB) {
				System.out.println(derivedSynset);
			}
		}
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:32,代码来源:WordNetUtils.java

示例3: TagAgent

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
public TagAgent(ServletContext context, EventTagCerealWrapper tag,
		SmartfollowReport report) {
	this.context = context;

	this.tag = tag;
	this.report = report;

	// Log progress
	log("Initializing Agent for " + tag.getTagText());

	/*
	 * Try to turn the tag into a machine-readable sentence This also
	 * initializes convertedTagWords and posTags If an exception is throw...
	 * that really confuses things Thrown because there was an issue getting
	 * NLP Dictionary
	 */
	try {
		log("Identifying elements of text");
		dissectText(context, tag.getTagText());
	} catch (JWNLException e) {
		// Done derped
		e.printStackTrace();
		log("Wordnet Error...");
		System.out.print("Unable to dissect text");
	}
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:27,代码来源:TagAgent.java

示例4: getSynonyms

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
public List<String> getSynonyms(String lemma) {
	HashSet<String> words = new HashSet<String>();
	try {
		IndexWord lemmaIndex = dictionary.lookupIndexWord(POS.VERB, lemma);

		if (lemmaIndex != null) {

			List<Synset> synsets = lemmaIndex.getSenses();

			for (Synset synset : synsets) {
				words.add(synset.getWords().get(0).getLemma());
			}

		}

	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return Lists.newArrayList(words);
}
 
开发者ID:impro3-nerdle,项目名称:nerdle,代码行数:21,代码来源:WordNetHelper.java

示例5: WordNetUtils

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
public WordNetUtils() {
	try {
		dict = Dictionary.getDefaultResourceInstance();
	} catch (JWNLException e) {
		e.printStackTrace();
	}
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:8,代码来源:WordNetUtils.java

示例6: getStrictExpansion

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
public static List<String> getStrictExpansion(String inputWord) {
    List<String> expansion = null;
    try {
        IndexWordSet wordSet = dictionary.lookupAllIndexWords(inputWord);
        if (wordSet.size() == 1) {
            IndexWord indexWord = wordSet.getIndexWordCollection().iterator().next();
            String lemma = indexWord.getLemma();
            List<Synset> senses = indexWord.getSenses();
            if (senses.size() == 1) {
                List<Word> words = senses.get(0).getWords();
                if (words.size() > 1) {
                    expansion = new ArrayList<>();
                    for (Word word : words) {
                        if (!word.getLemma().equals(lemma)) {
                            expansion.add(word.getLemma());
                        }
                    }
                }
            }
        }
    } catch (JWNLException e) {
        e.printStackTrace();
    }
    return expansion;
}
 
开发者ID:oaqa,项目名称:LiveQA,代码行数:26,代码来源:WordNetExpansion.java

示例7: WordInfo

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
public WordInfo(String word, POS pos) {

		this.word = word.toLowerCase();
		this.pos = pos;
		
		// If there is an identified part of speech, lookup the indexed word
		if (pos != null) {
			try {
				// If there is a defined part of speech, try to get the synset

				// Synset synset = null;
				// if (pos == POS.ADJECTIVE) {
				// synset = new AdjectiveSynset(Constants.getDictionary());
				// } else if (pos == POS.VERB) {
				// synset = new VerbSynset(Constants.getDictionary());
				// } else {
				//
				// synset = new Synset(Constants.getDictionary(), pos);
				// }

				indexWord = Constants.getDictionary()
						.lookupIndexWord(pos, word);
				
			} catch (JWNLException e) {
				e.printStackTrace();
				// all good, synset is null;
				// TODO: Log word and reason

			}
		}

	}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:33,代码来源:WordInfo.java

示例8: getSynsets

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
/**
 * A PointerType connects two synsets S1->PointerType->S2 Randomly generate
 * S1 based on POS frequencies and find S2
 * 
 * @param pt
 *            - some PointerType
 * @return a synset tuple (S1, S2) or null on timeout
 */
private static Synset[] getSynsets(PointerType pt) {
	Synset source, target;
	List<PointerTarget> targets;
	List<POS> validPOS = new ArrayList<POS>();
	IndexWord base;
	POS key;

	try {
		long startTime = System.currentTimeMillis();

		// Get valid parts of speech for this pointer type and choose one of
		// them at random
		// Use this to retrieve a random word
		validPOS = getApplicablePOS(pt);

		do {
			key = getRandomPOS(validPOS);
			base = dictionary.getRandomIndexWord(key);
			source = base.getSenses().get(0);
			targets = source.getTargets(pt);
		} while (targets.size() == 0
				&& System.currentTimeMillis() - startTime < TIMEOUT);

		if (targets.size() != 0) {
			target = targets.get(0).getSynset();
		} else {
			// timeout
			return null;
		}
	} catch (JWNLException e) {
		System.err.println("Error retrieving senses for PointerType: "
				+ pt.getLabel());
		e.printStackTrace();
		return null;
	}

	return new Synset[] { source, target };
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:47,代码来源:QueryHelper.java

示例9: WordNetHelper

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private WordNetHelper() {
	try {
		dictionary = Dictionary.getDefaultResourceInstance();
	} catch (JWNLException e) {
		e.printStackTrace();
	}
}
 
开发者ID:impro3-nerdle,项目名称:nerdle,代码行数:8,代码来源:WordNetHelper.java

示例10: runQuery

import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
public ScoreDoc[] runQuery(String qno, String queryTerms){
    ScoreDoc[] hits = null;
    System.out.println("Query No.: " + qno + " " + queryTerms);

    try {

        //Multi-field query
        String[] fields = new String[]{"title", "content"};

        // A query builder for constructing a complex query
        BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();

        // Boost the original query by a factor of 5
        // Query terms are important but the original terms are importantER
        BoostQuery termQuery = new BoostQuery(parser.parse(queryTerms), 5.0f);

        // Add it to the query builder
        queryBuilder.add(termQuery, BooleanClause.Occur.MUST);

        // Print out what Lucene generated
        // System.out.println(query.toString());

        // Find the synonyms of each term in the original query
        StringBuilder sb = new StringBuilder();
        for (String queryTerm : queryTerms.trim().split(" ")) {
            try {
                Set<String> synonyms = SynonymProvider.getSynonyms(queryTerm);

                if (synonyms == null) {
                    continue;
                }

                Iterator<String> it = synonyms.iterator();

                while (it.hasNext()) {
                    sb.append(it.next());
                    sb.append(" ");
                }

            } catch (JWNLException e) {
                e.printStackTrace();
            }

        }
        String querySynonymized = sb.toString();

        // If we found some synonyms, construct a query and add it to the query builder
        if (querySynonymized.length() > 0) {
            Query queryExpanded = parser.parse(querySynonymized);
            queryBuilder.add(queryExpanded, BooleanClause.Occur.SHOULD);
        }

        // Construct the final query and run it
        Query finalQuery = queryBuilder.build();

        try {
            TopDocs results = searcher.search(finalQuery, 1000);
            hits = results.scoreDocs;
        }
        catch (IOException ioe){
            System.out.println(" caught a " + ioe.getClass() + "\n with message: " + ioe.getMessage());
        }


    } catch (ParseException pe){
        System.out.println("Cant parse query");
    }
    return hits;
}
 
开发者ID:lucene4ir,项目名称:lucene4ir,代码行数:70,代码来源:RetrievalAppQueryExpansion.java


注:本文中的net.sf.extjwnl.JWNLException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。