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


C++ TermFrequencyMap类代码示例

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


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

示例1: TEST

// Multi-language test_1: test independent stemming per sub-document
TEST(FTSSpec, NestedLanguages_PerArrayItemStemming) {
    BSONObj indexSpec = BSON("key" << BSON("a.b.c"
                                           << "text"));
    FTSSpec spec(assertGet(FTSSpec::fixSpec(indexSpec)));
    TermFrequencyMap tfm;

    BSONObj obj = fromjson(
                      "{ a :"
                      "  { b :"
                      "    [ { c : \"walked\", language : \"english\" },"
                      "      { c : \"camminato\", language : \"italian\" },"
                      "      { c : \"ging\", language : \"german\" } ]"
                      "   }"
                      " }");

    spec.scoreDocument(obj, &tfm);

    set<string> hits;
    hits.insert("walk");
    hits.insert("cammin");
    hits.insert("ging");

    for (TermFrequencyMap::const_iterator i = tfm.begin(); i != tfm.end(); ++i) {
        string term = i->first;
        ASSERT_EQUALS(1U, hits.count(term));
    }
}
开发者ID:Machyne,项目名称:mongo,代码行数:28,代码来源:fts_spec_test.cpp

示例2: TEST

        // Multi-language test_3: test nested arrays
        TEST( FTSSpec, NestedLanguages_NestedArrays ) {
            BSONObj indexSpec = BSON( "key" << BSON( "a.b.c" << "text" ) );
            FTSSpec spec( FTSSpec::fixSpec( indexSpec ) );
            TermFrequencyMap tfm;

            BSONObj obj = fromjson(
                "{ language : \"english\","
                "  a : ["
                "  { language : \"danish\","
                "    b :"
                "    [ { c : [\"foredrag\"] },"
                "      { c : [\"foredragsholder\"] },"
                "      { c : [\"lector\"] } ]"
                "  } ]"
                "}" );

            spec.scoreDocument( obj,
                                FTSLanguage::makeFTSLanguage( "english" ).getValue(),
                                "",
                                false,
                                &tfm );

            set<string> hits;
            hits.insert("foredrag");
            hits.insert("foredragshold");
            hits.insert("lector");

            for (TermFrequencyMap::const_iterator i = tfm.begin(); i!=tfm.end(); ++i) {
                string term = i->first;
                ASSERT_EQUALS( 1U, hits.count( term ) );
            }

        }
开发者ID:Terracorrupt,项目名称:mongo,代码行数:34,代码来源:fts_spec_test.cpp

示例3: TEST

        TEST( FTSSpec, NestedArraysPos2 ) {
            BSONObj user = BSON( "key" << BSON( "$**" << "fts" ) );
            FTSSpec spec( FTSSpec::fixSpec( user ) );

            // The wildcard spec implies a full recursive traversal, so "term" should be indexed.
            BSONObj obj = fromjson("{a: {b: [['term']]}}"); // directly nested arrays
            TermFrequencyMap m;
            spec.scoreDocument( obj,
                                FTSLanguage::makeFTSLanguage( "english" ).getValue(),
                                "",
                                false,
                                &m );
            ASSERT_EQUALS( 1U, m.size() );
        }
开发者ID:Convey-Compliance,项目名称:mongo,代码行数:14,代码来源:fts_spec_test.cpp

示例4: TEST

        TEST( FTSSpec, ScoreSingleField1 ) {
            BSONObj user = BSON( "key" << BSON( "title" << "fts" <<
                                                "text" << "fts" ) <<
                                 "weights" << BSON( "title" << 10 ) );

            FTSSpec spec( FTSSpec::fixSpec( user ) );

            TermFrequencyMap m;
            spec.scoreDocument( BSON( "title" << "cat sat run" ), &m );
            ASSERT_EQUALS( 3U, m.size() );
            ASSERT_EQUALS( m["cat"], m["sat"] );
            ASSERT_EQUALS( m["cat"], m["run"] );
            ASSERT( m["cat"] > 0 );
        }
开发者ID:Cassie90,项目名称:mongo,代码行数:14,代码来源:fts_spec_test.cpp


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