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


C++ ParseTree::isPCFG方法代码示例

本文整理汇总了C++中ParseTree::isPCFG方法的典型用法代码示例。如果您正苦于以下问题:C++ ParseTree::isPCFG方法的具体用法?C++ ParseTree::isPCFG怎么用?C++ ParseTree::isPCFG使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParseTree的用法示例。


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

示例1: trimNsave

    void trimNsave(std::ofstream& ofs, double tsgCut, double tagCut, double adjCut) {

        ofs << int(nSym) << "\n";
        for(size_t i=0;i<nSym;++i) {
            ofs << syms[i] << "\n";
        }
        
        getG();        
        
        vector<pair<unsigned int,double> > srt;
        for(I2Dmap::iterator iter = tsgP.begin();iter != tsgP.end();++iter) {
            ParseTree* tree = getTree(iter->first);
            if(iter->second > tsgCut || tree->isPCFG()) {
                srt.push_back(*iter);
            } else {
                //printf("ELIM %s\n",toString(tree).c_str());
            }
            delete tree;
        }
        sort(srt.begin(),srt.end(),Rulesort(this));
        ofs << int(srt.size()) << "\n";
        printf("%d -> %d TSG rules\n",int(nTSG),int(srt.size()));
        
        for(vector<pair<unsigned int,double> >::iterator iter= srt.begin();iter!=srt.end();++iter) {
            unsigned int rSym = iter->first;
            double prob = iter->second;
            ParseTree* tree = getTree(rSym);
            ofs << toString(tree) << "\n" << prob << "\n";
            delete tree;
        }

        srt.clear();

        set<unsigned int> allowB;
        for(unsigned int i =nSym*2+1;i<goodmanIndex;++i) {
            unsigned int bS = baseSym[i];
            if(ptsyms.count(bS) == 0 && bS != nSym*2 && tagP.count(i) == 0) { 
                string s = getAKey(i);
                if(aKeys.count(s) > 0 && adjoinP[aKeys[s]] > adjCut) {
                    allowB.insert(baseSym[i]);
                }
            }
        }
                
        for(I2Dmap::iterator iter = tagP.begin();iter != tagP.end();++iter) {
            ParseTree* tree = getTree(iter->first);
            if(iter->second > tagCut && allowB.count(baseSym[iter->first]) > 0) 
                srt.push_back(*iter);
            delete tree;
        }
        sort(srt.begin(),srt.end(),Rulesort(this));
        ofs << int(srt.size()) << "\n";
        printf("%d -> %d TAG rules\n",int(nTAG),int(srt.size()));
        
        for(vector<pair<unsigned int,double> >::iterator iter= srt.begin();iter!=srt.end();++iter) {
            unsigned int rSym = iter->first;
            double prob = iter->second;
            ParseTree* tree = getTree(rSym);
            ofs << toString(tree) << "\n" << prob << "\n";
            delete tree;
        }

        
        vector<pair<string,double> > aaa;
        for(S2Imap::iterator i = aKeys.begin(); i != aKeys.end();++i) {
            double p = adjoinP[i->second];
            if(p > adjCut)
                aaa.push_back(make_pair(i->first,p));
        }
        printf("%d -> %d Adjunction groups\n",int(aKeys.size()),int(aaa.size()));
        ofs << int(aaa.size()) << "\n";
        sort(aaa.begin(),aaa.end(),Psort());
        for(size_t i=0;i<aaa.size();++i) {
            ofs << aaa[i].first << "\n" << aaa[i].second << "\n";
        }
        
    }
开发者ID:chonger,项目名称:BucketParser,代码行数:77,代码来源:BucketGrammar.hpp


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