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


Java BabelSense类代码示例

本文整理汇总了Java中it.uniroma1.lcl.babelnet.BabelSense的典型用法代码示例。如果您正苦于以下问题:Java BabelSense类的具体用法?Java BabelSense怎么用?Java BabelSense使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

import it.uniroma1.lcl.babelnet.BabelSense; //导入依赖的package包/类
/**
 * Process the data and write the outputs.
 *
 * @throws IOException when an I/O error has occurred.
 */
public void run() throws IOException {
    writeRecords(synsetsFilename, csv -> {
        babelnet.getSynsetIterator().forEachRemaining(synset -> {
            try {
                final List<BabelSense> senses = synset.getSenses(language);
                if (senses.isEmpty()) return;

                final String synsetID = synset.getId().toString();

                final Set<String> lemmas = senses.stream().map(BabelSense::getSimpleLemma).collect(toSet());
                csv.printRecord(synsetID, lemmas.size(), lemmas.stream().collect(joining(", ")));

                logger.log(Level.INFO, "Extracted {0}", synsetID);
            } catch (final IOException ex) {
                throw new RuntimeException(ex);
            }
        });
    });

    logger.log(Level.INFO, "Done");
}
 
开发者ID:nlpub,项目名称:babelnet-extract,代码行数:27,代码来源:SynsetsAction.java

示例2: lookupSense

import it.uniroma1.lcl.babelnet.BabelSense; //导入依赖的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

示例3: main

import it.uniroma1.lcl.babelnet.BabelSense; //导入依赖的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

示例4: getMaxSenseOccurrences

import it.uniroma1.lcl.babelnet.BabelSense; //导入依赖的package包/类
/**
 *
 * @param sense
 * @return
 */
public float getMaxSenseOccurrences(BabelSense sense) {
    float maxOcc = 0;
    for (int l = 0; l < sense.getSynset().getWordNetOffsets().size(); l++) {
        Float occ = getSynsetOccurrences(sense.getSynset().getWordNetOffsets().get(l));
        if (occ != null && occ > maxOcc) {
            maxOcc = occ;
        }
    }
    return maxOcc;
}
 
开发者ID:pippokill,项目名称:lesk-wsd-dsm,代码行数:16,代码来源:SenseFreqAPI.java

示例5: getMaxSenseProbability

import it.uniroma1.lcl.babelnet.BabelSense; //导入依赖的package包/类
/**
 *
 * @param key
 * @param sense
 * @param maxSize
 * @return
 */
public float getMaxSenseProbability(String key, BabelSense sense, int maxSize) {
    float maxProb = 0;
    for (int l = 0; l < sense.getSynset().getWordNetOffsets().size(); l++) {
        float prob = getSynsetProbability(key, sense.getSynset().getWordNetOffsets().get(l), maxSize);
        if (prob > maxProb) {
            maxProb = prob;
        }
    }
    return maxProb;
}
 
开发者ID:pippokill,项目名称:lesk-wsd-dsm,代码行数:18,代码来源:SenseFreqAPI.java


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