【问题标题】:Get vocabulary list in Galago获取 Galago 中的词汇表
【发布时间】:2016-02-20 13:55:06
【问题描述】:

我正在使用 Galago 检索工具包(Lemur 项目的一部分),我需要一个集合中所有词汇术语的列表(所有唯一术语)。实际上我需要一个List <String>Set <String> 非常感谢让我知道如何获得这样的列表?

【问题讨论】:

    标签: search-engine information-retrieval lemur


    【解决方案1】:

    “DumpKeysFn”类似乎给出了集合的所有键(唯一项)。代码应该是这样的:

    public static Set <String> getAllVocabularyTerms (String fileName) throws IOException{
        Set <String> result = new HashSet<> ();
        IndexPartReader reader = DiskIndex.openIndexPart(fileName);
        if (reader.getManifest().get("emptyIndexFile", false)) {
            // do something!
        }
    
        KeyIterator iterator = reader.getIterator();
        while (!iterator.isDone()) {
          result.add(iterator.getKeyString());
          iterator.nextKey();
        }
        reader.close();
        return result;
    }
    

    【讨论】:

    • 我只想添加它来使用它,如果您想要词干化的术语,您可能传递的文件名是“postings.krovetz”,或者如果您想要未统计的术语,则可能是“postings”。典型的 Java 反馈:使用 try-with-resources 块而不是显式关闭调用。
    猜你喜欢
    • 2021-10-18
    • 1970-01-01
    • 2016-10-07
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多