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


C++ CSentence::GetSentenceBeginStr方法代码示例

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


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

示例1: ReadAndProcessSentences

bool CSentencesCollection::ReadAndProcessSentences(const CPlmLineCollection* piPlmLine)
{
    const size_t LinesCount =  piPlmLine->m_Items.size();
    
    if( !m_pSyntaxOptions->IsValid())
            return false;
    

    if (m_bEnableProgressBar)
            printf ("Starting Syntax\n");

    time_t t1;
    time  (&t1);
    
    for (size_t LineNo = 0; LineNo < LinesCount; ) 
    {
        if (m_bEnableProgressBar)
                printf ("%i of %i       \r", LineNo, LinesCount);

        CSentence* S = m_pSyntaxOptions->NewSentence();
        if (!S)
        {
            m_pSyntaxOptions->OutputErrorString("Cannot allocate space for the new sentence!");
            return false;
        };
        try
        {

            S->m_pSyntaxOptions = m_pSyntaxOptions;

            bool bResult = S->ReadNextFromPlmLines(piPlmLine,LineNo);

            if (m_bLogProcessedSentence)
            {
                FILE * fp = fopen ("last_read_sentence.log", "w");
                fprintf (fp, "%s\n",S->GetSentenceBeginStr().c_str());
                fclose(fp);
            };

            if( !bResult )
            {
                //  a parse error occurs 
                delete S;
                return false;		
            };

        }
        catch (...)
        {

            m_pSyntaxOptions->OutputErrorString("Cannot read a sentence from Mapost");
            delete S;
            return false;
        };

        
        if( S->m_Words.empty() )
        {
            // no not-empty sentence can be found, we are at the end of the text
            delete S;
            break;
        }


        try
        {
            bool bRes = S->BuildClauses();

            if( !bRes )
            {
                delete S;
                return false;
            };

            S->CalculatePrimitiveClausesCount();

            
            if (m_bEnableProgressBar)
            {
                if (S->m_bPanicMode)
                    printf ("    found a \"panic\" sentence\n");
            };

            m_vectorSents.push_back(S);

        }
        catch (...)
        {
            if (m_bEnableProgressBar)
            {
                printf ("\n");
                if (!S->m_Words.empty())
                    printf ("exception at offset %i\n", S->m_Words[0].m_GraphematicalUnitOffset);
            };
             
            delete S;
            m_pSyntaxOptions->OutputErrorString("An exception in Synan occurred!");
            return false;
        };
        
//.........这里部分代码省略.........
开发者ID:arcady-chugunov,项目名称:thesis,代码行数:101,代码来源:SentencesCollection.cpp


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