it.uniroma1.lcl.jlt.util.Language Java Examples

The following examples show how to use it.uniroma1.lcl.jlt.util.Language. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TextualSimilarity.java    From ADW with GNU General Public License v3.0 6 votes vote down vote up
/**
 * returns 
 * @param sentence
 * 			input sentence, space delimited
 * @param discardStopWords
 * 			true if stopwords are to be discarded from the sentence 			
 * @return
 * 		a pair containing <list of word-pos, remaining not-handled terms>  
 * 		
 */
public Pair<List<String>, List<String>> getStanfordSentence(String sentence)
{
	List<WordLemmaTag> wlts = SentenceProcessor.getInstance().processSentence(sentence, false);
	
	List<String> terms = null;
	StanfordSentence sSentence = StanfordSentence.fromLine(Strings.join(wlts," "));
	
	try
	{
		 terms = sSentence.getTerms(TAGS, 
				 Language.EN, 
				 null, 
				 MultiwordBelongingTo.WORDNET, 
				 CompoundingParameter.ALLOW_MULTIWORD_EXPRESSIONS,
				 CompoundingParameter.APPEND_POS);	 
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}

	//discards OOVs, and tries to map incorrect pos-tags to the correct ones
	return fixTerms(terms, discardStopwords);
}
 
Example #2
Source File: RevisedLesk.java    From lesk-wsd-dsm with GNU General Public License v3.0 5 votes vote down vote up
private SnowballStemmer getStemmer(Language language) {
    if (language.equals(Language.EN)) {
        return new porterStemmer();
    } else if (language.equals(Language.ES)) {
        return new spanishStemmer();
    } else if (language.equals(Language.FR)) {
        return new frenchStemmer();
    } else if (language.equals(Language.DE)) {
        return new germanStemmer();
    } else if (language.equals(Language.IT)) {
        return new italianStemmer();
    } else {
        return null;
    }
}
 
Example #3
Source File: RevisedLesk.java    From lesk-wsd-dsm with GNU General Public License v3.0 5 votes vote down vote up
private List<BabelSense> lookupSense(Language language, String lemma, POS postag) throws IOException {
    List<BabelSense> senses = babelNet.getSenses(language, lemma, postag, BabelSenseSource.WN);
    if (senses == null || senses.isEmpty()) {
        senses = babelNet.getSenses(language, lemma.replace(" ", "_"), postag, BabelSenseSource.WN);
    }
    if (senses == null || senses.isEmpty()) {
        senses = babelNet.getSenses(language, lemma, postag, BabelSenseSource.WNTR);
    }
    if (senses == null || senses.isEmpty()) {
        senses = babelNet.getSenses(language, lemma.replace(" ", "_"), postag, BabelSenseSource.WNTR);
    }
    if (senses == null || senses.isEmpty()) {
        senses = babelNet.getSenses(language, lemma, postag);
    }
    if (senses == null || senses.isEmpty()) {
        senses = babelNet.getSenses(language, lemma.replace(" ", "_"), postag);
    }
    /*
     if (senses == null || senses.isEmpty()) {
     senses = babelNet.getSenses(language, lemma);
     }
     if (senses == null || senses.isEmpty()) {
     senses = babelNet.getSenses(language, lemma.replace(" ", "_"));
     }
     */
    if (senses == null || senses.isEmpty()) {
        Logger.getLogger(RevisedLesk.class.getName()).log(Level.WARNING, "No senses for {0}, pos-tag {1}", new Object[]{lemma, postag});
    }
    //remove duplicate senses
    if (senses != null && !senses.isEmpty()) {
        Set<String> ids = new HashSet<>();
        for (int i = senses.size() - 1; i >= 0; i--) {
            if (!ids.add(senses.get(i).getSynset().getId())) {
                senses.remove(i);
            }
        }
    }
    return senses;
}
 
Example #4
Source File: TestBabelNet.java    From lesk-wsd-dsm with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    try {
        BabelNet babelNet = BabelNet.getInstance();
        List<BabelSense> senses = babelNet.getSenses(Language.IT, args[0],POS.NOUN,BabelSenseSource.WNTR);
        for (BabelSense sense:senses) {
            System.out.println(sense.getSynset().getId()+"\t"+sense.getPosition());
        }
    } catch (IOException ex) {
        Logger.getLogger(TestBabelNet.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #5
Source File: BabelfyAnnotator.java    From gerbil with GNU Affero General Public License v3.0 4 votes vote down vote up
protected synchronized List<SemanticAnnotation> sendRequest(IBabelfy bfy, String chunk, BabelfyConstraints constraints) {
    return bfy.babelfy(chunk, Language.EN, constraints);
}
 
Example #6
Source File: BabelfyAnnotator.java    From gerbil with GNU Affero General Public License v3.0 4 votes vote down vote up
protected synchronized List<SemanticAnnotation> sendRequest(IBabelfy bfy, String chunk,
        BabelfyConstraints constraints) {
    return bfy.babelfy(chunk, Language.EN, constraints);
}
 
Example #7
Source File: RevisedLesk.java    From lesk-wsd-dsm with GNU General Public License v3.0 2 votes vote down vote up
/**
 *
 * @param language
 */
public RevisedLesk(Language language) {
    this.language = language;
}
 
Example #8
Source File: RevisedLesk.java    From lesk-wsd-dsm with GNU General Public License v3.0 2 votes vote down vote up
/**
 *
 * @param language
 * @param dsm
 */
public RevisedLesk(Language language, VectorStore dsm) {
    this.language = language;
    this.dsm = dsm;
}
 
Example #9
Source File: RevisedLesk.java    From lesk-wsd-dsm with GNU General Public License v3.0 2 votes vote down vote up
/**
 *
 * @return
 */
public Language getLanguage() {
    return language;
}
 
Example #10
Source File: RevisedLesk.java    From lesk-wsd-dsm with GNU General Public License v3.0 2 votes vote down vote up
/**
 *
 * @param language
 */
public void setLanguage(Language language) {
    this.language = language;
}