本文整理汇总了Java中it.uniroma1.lcl.jlt.util.Language类的典型用法代码示例。如果您正苦于以下问题:Java Language类的具体用法?Java Language怎么用?Java Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Language类属于it.uniroma1.lcl.jlt.util包,在下文中一共展示了Language类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
BabelMorph bm = BabelMorph.getInstance();
System.out.println(bm.getBabelMorphVersion());
//retrieve all the available languages
Set<Language> languages = bm.getBabelMorphLanguages();
System.out.println("available languages:\n"+languages.toString());
//retrieve all the available part-of-speech
Set<POS> pos = bm.getBabelMorphPoS();
System.out.println("available parts-of-speech:\n"+pos.toString());
System.out.println("word stats:");
countAllWordsByPOS(bm);
System.out.println("lemma stats:");
countAllLemmasByPOS(bm);
}
开发者ID:raganato,项目名称:BabelMorph,代码行数:19,代码来源:Stats.java
示例2: getStanfordSentence
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* 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);
}
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:35,代码来源:TextualSimilarity.java
示例3: testTranslations
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* A demo to see the translations of a word.
*
* @param lemma
* @param languageToSearch
* @param languagesToPrint
* @throws IOException
*/
public static void testTranslations(String lemma, Language languageToSearch,
Language... languagesToPrint) throws IOException {
BabelNet bn = BabelNet.getInstance();
List<Language> allowedLanguages = Arrays.asList(languagesToPrint);
Multimap<Language, ScoredItem<String>> translations =
bn.getTranslations(languageToSearch, lemma);
for (Language language : translations.keySet()) {
if (allowedLanguages.contains(language)) {
System.out.print(""+language);
for (ScoredItem<String> item : translations.get(language)) {
System.out.print("\t"+item);
}
System.out.println();
}
}
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:27,代码来源:PrintTranslations.java
示例4: getDBPediaURIs
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Get the DBPedia URIs of the {@link BabelSense}s in a specific language
* found in <b>this</b> {@link BabelSynset}.
*
* @param languages
* @return the DBPedia URIs of the {@link BabelSense}s in this synset.
* @see BabelSense#getDBPediaURI()
*/
public List<String> getDBPediaURIs(Language... languages)
{
List<String> uris = new ArrayList<String>();
List<Language> langs = Arrays.asList(languages);
for (BabelSense sense : senses)
{
if (sense.getSource() != BabelSenseSource.WIKIRED
&&
(langs.isEmpty() || langs.contains(sense.getLanguage())))
{
String dBPediaURI = sense.getDBPediaURI();
if (dBPediaURI != null) uris.add(dBPediaURI);
}
}
return uris;
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:27,代码来源:BabelSynset.java
示例5: getSenses
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Gets the {@link BabelSense} for the input word in the given language
*
* @param language language of the sense
* @param lemma lemma of the sense
* @param sources possible sources for the sense
* @return the {@link BabelSense} for the input word in the given language
*/
public List<BabelSense> getSenses(Language language, String lemma, BabelSenseSource... sources)
{
List<BabelSenseSource> sourceList = sources.length == 0 ? null : Arrays.asList(sources);
List<BabelSense> result = new ArrayList<BabelSense>();
for (BabelSense sense : senses)
{
if (sense.getSimpleLemma().equalsIgnoreCase(lemma)
&& sense.getLanguage().equals(language)
&& (sourceList == null || sourceList.contains(sense.getSource())))
{
result.add(sense);
}
}
return result;
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:25,代码来源:BabelSynset.java
示例6: toString
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Prints the {@link BabelSense}s of <b>this</b> {@link BabelSynset} only
* for a specific set of languages.
*
* @param languages
* @return a stringified representation of <b>this</b> Babel synset using
* only the senses in a specific set of languages
*/
public String toString(Language... languages)
{
StringBuffer sb = new StringBuffer("{");
Set<Language> languageSet = new HashSet<Language>(Arrays.asList(languages));
for (BabelSense sense : senses)
{
if (!languageSet.isEmpty() && !languageSet.contains(sense.getLanguage())) continue;
if (sb.length() > 1) sb.append(",");
sb.append(" ").append(sense.toString());
}
sb.append(" }");
return sb.toString();
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:25,代码来源:BabelSynset.java
示例7: testGraph
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* A demo to explore the BabelNet graph.
*
*
* @param synset
* @throws IOException
*/
public static void testGraph(BabelSynset synset) throws IOException
{
BabelNet bn = BabelNet.getInstance();
List<BabelNetGraphEdge> successorsEdges = bn.getSuccessorEdges(synset.getId());
System.out.println("SYNSET ID:" + synset.getId());
System.out.println("# OUTGOING EDGES: " + successorsEdges.size());
for (BabelNetGraphEdge edge : successorsEdges)
{
System.out.println("\tEDGE " + edge);
System.out.println("\t" + bn.getSynsetFromId(edge.getTarget()).toString(Language.EN));
System.out.println();
}
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:23,代码来源:BabelNetDemo.java
示例8: testTranslations
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* A demo to see the translations of a word.
*
* @param lemma
* @param languageToSearch
* @param languagesToPrint
* @throws IOException
*/
public static void testTranslations(String lemma, Language languageToSearch,
Language... languagesToPrint) throws IOException
{
BabelNet bn = BabelNet.getInstance();
List<Language> allowedLanguages = Arrays.asList(languagesToPrint);
Multimap<Language, ScoredItem<String>> translations =
bn.getTranslations(languageToSearch, lemma);
System.out.println("TRANSLATIONS FOR " + lemma);
for (Language language : translations.keySet())
{
if (allowedLanguages.contains(language))
System.out.println("\t"+language+"=>"+translations.get(language));
}
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:25,代码来源:BabelNetDemo.java
示例9: testImages
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
public static void testImages(String lemma, Language language) throws IOException
{
BabelNet bn = BabelNet.getInstance();
System.out.println("SYNSETS WITH word: \""+ lemma + "\"");
List<BabelSynset> synsets = bn.getSynsets(language, lemma);
Collections.sort(synsets, new BabelSynsetComparator(lemma));
for (BabelSynset synset : synsets)
{
System.out.println(" =>(" + synset.getId() + ")" +
" MAIN LEMMA: " + synset.getMainSense());
for (BabelImage img : synset.getImages())
{
System.out.println("\tIMAGE URL:" + img.getURL());
System.out.println("\tIMAGE VALIDATED URL:" + img.getValidatedURL());
System.out.println("\t==");
}
System.out.println(" -----");
}
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:20,代码来源:BabelNetDemo.java
示例10: getBabelMorphLanguages
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
*
* @return the available languages
*/
public Set<Language> getBabelMorphLanguages()throws IOException
{
Set<Language> languages = new HashSet<>();
Terms terms = SlowCompositeReaderWrapper.wrap(morphologicalDictionary.getIndexReader()).terms(BabelMorphIndexField.LANGUAGE.toString());
TermsEnum termsEnum = terms.iterator();
BytesRef text;
while((text = termsEnum.next()) != null) {
languages.add(Language.valueOf(text.utf8ToString()));
}
return languages;
}
开发者ID:raganato,项目名称:BabelMorph,代码行数:17,代码来源:BabelMorph.java
示例11: getBabelMorphFromDocument
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Gets a {@link BabelMorphWord} from a {@link Document}
*
* @param doc
* a Lucene {@link Document} record for a certain WktMorphWord
* @return an instance of a {@link BabelMorphWord} from a {@link Document}
*/
public static BabelMorphWord getBabelMorphFromDocument(Document doc)
{
try
{
String queryLanguage = doc.get(BabelMorphIndexField.LANGUAGE.toString());
Language lang = Language.valueOf(queryLanguage);
String queryLemma = doc.get(BabelMorphIndexField.LEMMA.toString());
String queryPos = doc.get(BabelMorphIndexField.POS.toString());
POS p = POS.valueOf(queryPos);
String[] queryForms = doc.getValues(BabelMorphIndexField.FORM.toString());
String[] queryInfos = doc.getValues(BabelMorphIndexField.INFO.toString());
if( lang == null || queryLemma == null ||
queryPos == null || p == null || queryForms == null ) return null;
HashMultimap<String, String> multimap = HashMultimap.create();
for(int i=0;i<queryForms.length;i++)
multimap.put(queryForms[i], queryInfos[i]);
BabelMorphWord bmw = new BabelMorphWord(queryLemma, lang, p, multimap);
return bmw;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
开发者ID:raganato,项目名称:BabelMorph,代码行数:38,代码来源:BabelMorph.java
示例12: SensesAction
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Initialize the action.
*
* @param babelnet the BabelNet instance.
* @param language the language.
* @param synsetsFilename the synsets input file.
* @param sensesFilename the senses output file.
* @param logger the logger instance.
*/
public SensesAction(BabelNet babelnet, Language language, String synsetsFilename, String sensesFilename, Logger logger) {
this.babelnet = babelnet;
this.language = language;
this.synsetsFilename = synsetsFilename;
this.sensesFilename = sensesFilename;
this.logger = logger;
logger.log(Level.INFO, "Reading synsets from \"{0}\"", synsetsFilename);
logger.log(Level.INFO, "Writing senses to \"{0}\"", sensesFilename);
}
开发者ID:nlpub,项目名称:babelnet-extract,代码行数:19,代码来源:SensesAction.java
示例13: ClustersAction
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Initialize the action.
*
* @param babelnet the BabelNet instance.
* @param language the language.
* @param pos the part of speech.
* @param clustersFilename the clusters input file.
* @param wordsFilename the words output file.
* @param synsetsFilename the synsets output file.
* @param logger the logger instance.
*/
public ClustersAction(BabelNet babelnet, Language language, BabelPOS pos, String clustersFilename, String wordsFilename, String synsetsFilename, Logger logger) {
this.babelnet = babelnet;
this.language = language;
this.pos = pos;
this.clustersFilename = clustersFilename;
this.wordsFilename = wordsFilename;
this.synsetsFilename = synsetsFilename;
this.logger = logger;
logger.log(Level.INFO, "Reading clusters from \"{0}\"", clustersFilename);
logger.log(Level.INFO, "Writing words to \"{0}\"", wordsFilename);
logger.log(Level.INFO, "Writing synsets to \"{0}\"", synsetsFilename);
}
开发者ID:nlpub,项目名称:babelnet-extract,代码行数:24,代码来源:ClustersAction.java
示例14: bankBonusPayStock
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
@Test
public void bankBonusPayStock() throws IOException {
List<Word> sentence = Arrays.asList(
new Word[]{new Word("bank", "n", Language.EN), new Word("bonus", "n", Language.EN),
new Word("pay", "v", Language.EN), new Word("stock", "n", Language.EN)});
disambiguate(sentence, babelnetKb, degreeScorer);
}
开发者ID:lumenrobot,项目名称:relex-id,代码行数:8,代码来源:BabelNetTest.java
示例15: getStemmer
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
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;
}
}
开发者ID:pippokill,项目名称:lesk-wsd-dsm,代码行数:16,代码来源:RevisedLesk.java
示例16: lookupSense
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
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;
}
开发者ID:pippokill,项目名称:lesk-wsd-dsm,代码行数:40,代码来源:RevisedLesk.java
示例17: main
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* @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);
}
}
开发者ID:pippokill,项目名称:lesk-wsd-dsm,代码行数:15,代码来源:TestBabelNet.java
示例18: getValidatedURL
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Gets a verified version of the full input URL <b>this</b> image. Checks
* whether possible URLs of this image exist or return 404.
*
* @return a validated, known-to-exists, URL from which an image can be
* retrieved.
*/
private static String getValidatedURL(String url, Language language)
{
String validated = "";
if (testURLexists(url))
{
validated = url;
}
else
{
String alternateUrl =
BACKOFF_URL_PREFIX + language.name().toLowerCase() + "/" +
url.substring(URL_PREFIX.length());
if (testURLexists(alternateUrl)) validated = alternateUrl;
}
// not much to do here...
if (validated.isEmpty()) return null;
// check that it is not already URL encoded
if (isURLEncoded(validated)) return validated;
try
{
// encode the URL in an appropriate way
int idx = validated.indexOf("/", 7);
String host = validated.substring(7, idx);
String path = validated.substring(idx);
URI uri = new URI("http", host, path, null);
return uri.toASCIIString();
}
catch (URISyntaxException e) { return null; }
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:41,代码来源:BabelImage.java
示例19: main
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length < 1) {
System.err.println("Please specify a word to look up on the command line.");
return;
}
try
{
String word = args[1];
Set<Language> languages = new HashSet<Language>();
// = BabelNetConfiguration.getInstance().getBabelLanguages();
languages.add(Language.ES);
languages.add(Language.DE);
languages.add(Language.EN);
Language source;
if (args[0].equals("en")) {
source = Language.EN;
} else if (args[0].equals("fr")) {
source = Language.FR;
} else if (args[0].equals("nl")) {
source = Language.NL;
} else {
throw new Exception();
}
testTranslations(word, source, languages.toArray(new Language[languages.size()]));
}
catch (Exception e)
{
e.printStackTrace();
}
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:33,代码来源:PrintTranslations.java
示例20: getCategories
import it.uniroma1.lcl.jlt.util.Language; //导入依赖的package包/类
/**
* Gets the categories ({@link BabelCategory}s) of <b>this</b>
* {@link BabelSynset} in a specific language.
*
* @return the categories ({@link BabelCategory}s) of <b>this</b>
* {@link BabelSynset} in a certain language.
*/
public List<BabelCategory> getCategories(Language... languages)
{
List<Language> langs = Arrays.asList(languages);
List<BabelCategory> languageCategories = new ArrayList<BabelCategory>();
for (BabelCategory category : categories)
if (langs.contains(category.getLanguage()))
languageCategories.add(category);
return languageCategories;
}
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:19,代码来源:BabelSynset.java
注:本文中的it.uniroma1.lcl.jlt.util.Language类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论