• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Sentence类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: clear

  bool Lattice::assign(utils::piece::const_iterator& iter, utils::piece::const_iterator end)
  {
    namespace qi = boost::spirit::qi;
    namespace standard = boost::spirit::standard;
    
    clear();
    
    // empty lattice...
    if (iter == end) return true;
    
    utils::piece::const_iterator iter_back = iter;
    
    if (qi::phrase_parse(iter, end, lattice_grammar_parser_impl::instance(), standard::space, lattice)) {
      initialize_distance();
      return true;
    } else {
      clear();
      
      // fallback to sentence...
      iter = iter_back;
      Sentence sentence;
      
      if (sentence.assign(iter, end)) {
	Sentence::const_iterator iter_end = sentence.end();
	for (Sentence::const_iterator iter = sentence.begin(); iter != iter_end; ++ iter)
	  lattice.push_back(arc_set_type(1, arc_type(*iter)));
	
	return true;
      } else {
	clear();
	return false;
      }
    }
  }
开发者ID:hitochan777,项目名称:cicada,代码行数:34,代码来源:lattice.cpp


示例2: isPELCNFLiteral

bool isPELCNFLiteral(const Sentence& sentence) {
    if (sentence.getTypeCode() == Atom::TypeCode
            || sentence.getTypeCode() == BoolLit::TypeCode
            || sentence.getTypeCode() == LiquidOp::TypeCode) {
        return true;
    }
    if (sentence.getTypeCode() == Negation::TypeCode) {
        const Negation& neg = static_cast<const Negation&>(sentence);

        // TODO: necessary to check for double negation?
        if (neg.sentence()->getTypeCode() == Negation::TypeCode) return false;
        return isPELCNFLiteral(*neg.sentence());
    }
    if (sentence.getTypeCode() == DiamondOp::TypeCode) {
        const DiamondOp& dia = static_cast<const DiamondOp&>(sentence);
        if (       dia.sentence()->getTypeCode()    == Atom::TypeCode
                || dia.sentence()->getTypeCode()    == BoolLit::TypeCode
                || dia.sentence()->getTypeCode()    == LiquidOp::TypeCode) {  // TODO add liquidop
            return true;
        }
        return false;
    }
    if (sentence.getTypeCode() == Conjunction::TypeCode) {
        const Conjunction& con = static_cast<const Conjunction&>(sentence);
        if ((con.left()->getTypeCode() == Atom::TypeCode
                || con.left()->getTypeCode() == BoolLit::TypeCode)
              && (con.right()->getTypeCode() == Atom::TypeCode
                || con.right()->getTypeCode() == BoolLit::TypeCode)) {
            return true;
        }
        return false;
    }

    return false;
}
开发者ID:selmanj,项目名称:repel,代码行数:35,代码来源:Sentence.cpp


示例3: kahnsOrDragons

IChoiceTag* IChoiceTag::Create(Sentence& sentence)
{
    static Sentence kahnsOrDragons("As THIS enters the battlefield, choose Khans or Dragons.");
    static Sentence opponentChoose("An opponent chooses one " HYPEN);

    if (kahnsOrDragons.IsEqualTo(sentence))
    {
        sentence.Clear();
        return new KahnsOrDragons;
    }

    if (opponentChoose.IsEqualTo(sentence))
    {
        sentence.Clear();
        return new OpponentChoose;
    }

	auto first = sentence.Find(
		[](IObjectTag* tag) -> bool { return tag->GetType() == ObjectType::Choose; });

	if (first.found)
	{
		auto second = sentence.Find(
			[](IObjectTag* tag) -> bool { return tag->GetType() == ObjectType::BigSeperator; }, 
			first.iterator);

		if (second.found)
		{
			return new ChoiceBegin(sentence.Splice(second.iterator));
		}
	}
    return nullptr;
}
开发者ID:eiaserinnys,项目名称:MtgParser,代码行数:33,代码来源:ChoiceTag.cpp


示例4: askOr

bool KnowLedgeBasedAgent::askOr(string query, vector<string>& theta)
{
    Predicate p = TextParser::GetPredicate(query);
    if (predicateMap.find(p.name) != predicateMap.end())
    {
        vector<int>rules = predicateMap[p.name];
        bool flag = false;
        for (int ruleIterator = 0; ruleIterator < rules.size(); ruleIterator++)
        {
            Sentence sentence = KnowledgeBase[rules[ruleIterator]-1];
            vector<string> premise = sentence.GetPremise();
            string conclusion = sentence.GetConclusion();
            Predicate q = TextParser::GetPredicate(conclusion);
            string substitution = "";
            bool unificationResult = Unify(p, q, substitution);
            if (!unificationResult) continue;
            if (find(theta.begin(), theta.end(), substitution) == theta.end())
            {
                theta.push_back(*new string(substitution));
            }
            bool validity = askAnd(premise, theta);
            if (validity) flag = true;
            else flag = false;
        }
        if(flag) return true;
        else return false;
    }
    else return false;
}
开发者ID:Warun26,项目名称:LogicInference,代码行数:29,代码来源:KnowledgeBasedAgent.cpp


示例5: MakePerceptSentence

void KnowLedgeBasedAgent::Tell(string percept)
{
    t = t+1;
    Sentence sentence = MakePerceptSentence(percept);
    KnowledgeBase.push_back(sentence);
    Predicate conclusion = TextParser::GetPredicate(sentence.GetConclusion());
    if (predicateMap.find(conclusion.name) == predicateMap.end())
    {
        vector<int> conclusionId;
        conclusionId.push_back(t);
        predicateMap[conclusion.name] = conclusionId;
        if (conclusion.arg1[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg1) == constants.end())
            constants.push_back(conclusion.arg1);
        if (conclusion.arg2[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg2) == constants.end())
            constants.push_back(conclusion.arg2);
        }
    else
    {
        (predicateMap[conclusion.name]).push_back(t);
        if (conclusion.arg1[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg1) == constants.end())
            constants.push_back(conclusion.arg1);
        if (conclusion.arg2[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg2) == constants.end())
            constants.push_back(conclusion.arg2);
    }
    vector<string> premises = sentence.GetPremise();
    for (int i=0; i<premises.size(); i++)
    {
        Predicate premise = TextParser::GetPredicate(premises[i]);
        if (premise.arg1[0] != 'x' && find(constants.begin(), constants.end(), premise.arg1) == constants.end())
            constants.push_back(premise.arg1);
        if (premise.arg2[0] != 'x' && find(constants.begin(), constants.end(), premise.arg2) == constants.end())
            constants.push_back(premise.arg2);
    }
}
开发者ID:Warun26,项目名称:LogicInference,代码行数:34,代码来源:KnowledgeBasedAgent.cpp


示例6: readWordFile

 void readWordFile(string filePath)
 {
     ifstream in(filePath.c_str());
     int sentenceId, wordNo, wordId;
     SentenceLine sentenceline;
     int lastSentenceId = 1;
     while (in>>sentenceId>>wordNo>>wordId)
     {
         if (sentenceId!=lastSentenceId&&sentenceId>1)
         {
             Sentence s;
             s.ReadLine(sentenceline);
             if (sentenceId-lastSentenceId>1) // some files the sentenceId is not continous, treat it as zero length sentence
             {
                 for (int i=0; i<sentenceId-lastSentenceId-1; i++)
                 {
                     Sentence tmp;
                     AppendSentence(tmp);
                 }
             }
             AppendSentence(s);  //note that byte is zero, need to correct and Combine Step
             sentenceline.clear();
             lastSentenceId= sentenceId;
         }
         sentenceline.push_back(wordId);
     }
     Sentence s;
     s.ReadLine(sentenceline);
     AppendSentence(s);
     in.close();
 }
开发者ID:sjavdani,项目名称:statsproj,代码行数:31,代码来源:GreedyAlgo.cpp


示例7: decltype

long DataManager::readPOSFile(const char* filePath, const std::function<void (Sentence*)> placementFunction)
{
    Sentence *sentence = nullptr;
    long counter = 0;
    decltype(readLine()) line = nullptr;

    if (openFile(filePath, true)) {
        while ((line = readLine()) != nullptr) {
            if (strlen(line) == 0) {
                if (sentence) {
                    placementFunction(sentence);
                    sentence = nullptr;
                }
                continue;
            }

            auto indexOfTab = line;

            for (; *indexOfTab != '\0'; indexOfTab++) {
                if (*indexOfTab == '\t') {
                    *(indexOfTab++) = '\0';
                    break;
                }
            }

            if (!sentence)
                sentence = new Sentence();

            sentence->addWord(line, indexOfTab);
        }
    }

    return counter;
}
开发者ID:Poligun,项目名称:Tagger,代码行数:34,代码来源:data_manager.cpp


示例8: parse

    void Run::parse(const std::string &sInputFile, const std::string &sOutputFile,
                    const std::string &sFeatureFile) const {

        Sentence sentence;
        DependencyTree tree;

        std::cout << "Parsing started" << std::endl;

        auto time_begin = time(NULL);

        std::unique_ptr<DepParser> parser(new DepParser(sFeatureFile, sFeatureFile, ParserState::PARSE));
        std::ifstream input(sInputFile);
        std::ofstream output(sOutputFile);
        if (input) {
            while (input >> sentence) {
                if (sentence.size() < MAX_SENTENCE_SIZE) {
                    parser->parse(sentence, &tree);
                    output << tree;
                    tree.clear();
                }
            }
        }
        input.close();
        output.close();

        auto time_end = time(NULL);

        auto seconds = difftime(time_end, time_begin);

        std::cout << "Parsing has finished successfully. Total time taken is: " << difftime(time_end, time_begin) <<
        "s" << std::endl;
    }
开发者ID:yangzhixuan,项目名称:xParser,代码行数:32,代码来源:emptyeisnergc3rd_run.cpp


示例9: year_is_found

// "((this|next|last) year)|(\d\d\d\d)"
int year_is_found( Sentence& mSentence, struct tm* mFillin=NULL )
{
    int retval=0;
    retval = mSentence.is_found_in_sentence("this year");
    if (retval)
    {
        if (mFillin) mFillin->tm_year = retval = bd_now.tm_year;
        return retval;
    } else if ((retval = mSentence.is_found_in_sentence("next year")))
    {
        if (mFillin) mFillin->tm_year = retval = bd_now.tm_year+1;
        return retval;
    } else if ((retval = mSentence.is_found_in_sentence("last year")))
    {
        if (mFillin) mFillin->tm_year = retval = bd_now.tm_year-1;
        return retval;
    }
    /* Scan numbers 1900 to 2016 */
    char year_ascii[4];
    for (int year=1900; year<2100; year++) {
        sprintf(year_ascii, "%d", year);
        if (mSentence.is_found_in_sentence( year_ascii )) {
            if (mFillin) mFillin->tm_year = year-1900;
            return mSentence.get_word_index(year_ascii);
        }
    }
    return retval;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:29,代码来源:qualitative_time.cpp


示例10: doTranslate

// 인자로 주어진 파일로부터 한문장씩 읽어 이를 번역
void doTranslate(char* pInFile, Manual& out, int wantedLang)
{
	ifstream ifs(pInFile);
	if (!ifs)
	{
		cout << "Can't open file : " << pInFile << endl;
		return;
	}
	string result;
	Sentence next;
	while (!(next = getSentence(ifs)).getString().empty())
	{
		switch (next.getType())
		{
		case NORMAL_SENTENCE: // 평서문
			result = TransNormalSentence(next.getString(), wantedLang);
			break;
		case INTERROGATIVE_SENTENCE: // 의문문
			result = TransInterrogativeSentence(next.getString(), wantedLang);
			break;
		case IMPERATIVE_SENTENCE: // 명령문
			result = TransImperativeSentence(next.getString(), wantedLang);
			break;
		default:
			cout << "Untranslatable sentence type" << endl;
			return;
		}
		out.addContents(result);

	}
}
开发者ID:CppKorea,项目名称:DesignPatternStudy,代码行数:32,代码来源:Builder2.cpp


示例11: CreateConstantExpression

VbCodeExpressionPtr VbCodeExpressionFactory::CreateConstantExpression(const Sentence& sentence)
{
	if (sentence.GetNodes().size() != 1)
		throw std::runtime_error("Literal should contain exactly 1 token.");
	auto& value = VbCodeValueFactory::Create(sentence.GetNodes()[0]->AsToken());
	return std::make_shared<VbCodeConstantExpression>(value);
}
开发者ID:jmfb,项目名称:ConvertVb6ToCs,代码行数:7,代码来源:VbCodeExpressionFactory.cpp


示例12: range

/** constructor; just initialize the base class */
TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const &input, size_t maxNoTransOptPerCoverage, float translationOptionThreshold)
  : TranslationOptionCollection(input, maxNoTransOptPerCoverage, translationOptionThreshold)
{
  size_t size = input.GetSize();
  m_inputPathMatrix.resize(size);
  for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) {
    for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
      size_t endPos = startPos + phaseSize -1;
      vector<InputPath*> &vec = m_inputPathMatrix[startPos];

      WordsRange range(startPos, endPos);
      Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos)));
      const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos);

      InputPath *node;
      if (range.GetNumWordsCovered() == 1) {
        node = new InputPath(subphrase, labels, range, NULL, NULL);
        vec.push_back(node);
      } else {
        const InputPath &prevNode = GetInputPath(startPos, endPos - 1);
        node = new InputPath(subphrase, labels, range, &prevNode, NULL);
        vec.push_back(node);
      }

      m_phraseDictionaryQueue.push_back(node);
    }
  }
}
开发者ID:Kitton,项目名称:mosesdecoder,代码行数:29,代码来源:TranslationOptionCollectionText.cpp


示例13: makeNGram

	// make N-gram
	Sentence makeNGram(const Sentence& sent, Position begin, unsigned int n)
	{
		Sentence ret;
		auto it1 = sent.begin() + begin;
		auto it2 = it1 + n;
		ret.insert(ret.end(), it1, it2);
		return move(ret);
	}
开发者ID:ahclab,项目名称:greedyseg,代码行数:9,代码来源:split_gdp.cpp


示例14: PrintSentence

void ParallelCorpus::PrintSentence(
    const Sentence& sentence, const Vocab& vocab, std::ostream& out) const {
  if (sentence.size() > 0) {
    out << vocab.GetWord(sentence.at(0));
  }
  for (int i = 1; i < sentence.size(); ++i) {
    out << " " << vocab.GetWord(sentence.at(i));
  }
}
开发者ID:jrs026,项目名称:SentenceAlignment,代码行数:9,代码来源:parallel_corpus.cpp


示例15: putSentence

// render a sentence in words
void putSentence(const Wordlist& wlist, const Sentence sent)
{
  for (Sentence::const_iterator i = sent.begin() ; i != sent.end() ; ++i) {
    if (*i != 0) 
      cout << wlist[*i-1] << " " ;
  }
  cout << endl ;

}
开发者ID:Deseaus,项目名称:GF,代码行数:10,代码来源:gfex.cpp


示例16: parse_qualitative_1_time

int parse_qualitative_1_time( Sentence& mSentence, time_t& sTime )
{
	// Parse Qualitative time:
	parsed_qualitative_duration = mSentence.are_found_in_sentence( "in the last %d (day|days|hour|hours|minute|minutes|seconds)" ) || 
								  mSentence.are_found_in_sentence( "between" );	// hour, day, 5 hours, 5 minutes.
	
	parsed_qualitative_duration  = mSentence.are_found_in_sentence( "at [specific time ie five thirty]" );
	parsed_qualitative_time = parsed_qualitative_duration;	
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:9,代码来源:qualitative_time.cpp


示例17: ExtractPrgFeatures

void SRLBaselineExt::ExtractPrgFeatures(vector< vector<string> >& vecPrgFeatures) const
{
    vecPrgFeatures.clear();

    Sentence sentence;

    vector<string> vecRows;
    convert2ConllFormat(vecRows);

    sentence.from_corpus_block(vecRows);
    const size_t row_count = sentence.get_row_count();

    m_featureExtractor->set_target_sentence(sentence);

    m_featureExtractor->calc_node_features();

    vector< vector<string> > vec_feature_values;
    for (size_t i = 0; i < m_prgFeatureNumbers.size(); ++i)
    {
        vector<string> feature_values;

        const int feature_number = m_prgFeatureNumbers[i];
        const string& feature_prefix = m_prgFeaturePrefixes[i];
        bool feature_empty_flag = false;
        try {
            m_featureExtractor->get_feature_for_rows(feature_number, feature_values);
        } catch (...) {
            feature_empty_flag = true;
        }

        if (feature_empty_flag)
        {
            feature_values.clear();
            for (size_t row = 0; row <= row_count; ++row)
            {
                feature_values.push_back("");
            }
        }

        vec_feature_values.push_back(feature_values);
    }

    for (size_t row = 1; row <= row_count; ++row)
    {
        vector<string> instance;
        for (size_t i = 0; i < m_prgFeatureNumbers.size(); ++i)
        {
            string feature = m_prgFeaturePrefixes[i] + "@"
                + vec_feature_values[i][row];
            instance.push_back(feature);
        }
        vecPrgFeatures.push_back(instance);
    }
}
开发者ID:153370771,项目名称:ltp,代码行数:54,代码来源:SRLBaselineExt.cpp


示例18: is_order_complete

int RestaurantOrder::is_order_complete( Sentence& mSentence )
{
    orderFoundComplete = mSentence.are_found_in_sentence( "no more" ) ||
    mSentence.are_found_in_sentence( "that's it" ) ||
    mSentence.are_found_in_sentence( "that's all" ) ||
    mSentence.is_found_in_sentence( "no" );    
    if (orderFoundComplete)
        return 1;
    else
        return 0;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:11,代码来源:menus_orders.cpp


示例19: crf_decode_forward_backward

void
crf_decode_forward_backward(Sentence & s, CRF_Model & m, vector< map<string, double> > & tagp)
{
  CRF_Sequence cs;
  for (size_t j = 0; j < s.size(); j++) cs.add_state(crfstate(s, j));

  m.decode_forward_backward(cs, tagp);
  //  m.decode_viterbi(cs);

  for (size_t k = 0; k < s.size(); k++) s[k].prd = cs.vs[k].label;
}
开发者ID:Akirato,项目名称:LaposTagger,代码行数:11,代码来源:crfpos.cpp


示例20: crf_decode_nbest

void
crf_decode_nbest(Sentence & s, CRF_Model & m, 
		 vector<pair<double, vector<string> > > & nbest_seqs, int n)
{
  CRF_Sequence cs;
  for (size_t j = 0; j < s.size(); j++) cs.add_state(crfstate(s, j));

  m.decode_nbest(cs, nbest_seqs, n, 0);

  for (size_t k = 0; k < s.size(); k++) s[k].prd = cs.vs[k].label;

}
开发者ID:Akirato,项目名称:LaposTagger,代码行数:12,代码来源:crfpos.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Seperator类代码示例发布时间:2022-05-30
下一篇:
C++ SensorFusion类代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap