📄 section.cpp
字号:
// Section.cpp: implementation of the CSection class.
//
//////////////////////////////////////////////////////////////////////
#include "..\headfile\Section.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSection::CSection()
{
m_SectionIndex = 0;
}
CSection::~CSection()
{
}
CSection::CSection(const string §ionStr, int index)
{
m_SectionIndex = index;
int iCurrentPos = 0;
int iSentenceIndex = 0;
string Str;
while(1)
{
unsigned int iPeriodPos = sectionStr.find_first_of('.', iCurrentPos);
unsigned int iExclamationPos = sectionStr.find_first_of('!', iCurrentPos);
unsigned int iQueryPos = sectionStr.find_first_of('?', iCurrentPos);
unsigned int iMinPos = __min(__min(iPeriodPos, iExclamationPos), iQueryPos);
Str = sectionStr.substr(iCurrentPos, iMinPos - iCurrentPos);
CSentence Sentence(Str, iSentenceIndex);
m_SentenceList.push_back(Sentence);
iCurrentPos = iMinPos + 1;
if (iCurrentPos == sectionStr.size())
{
break;
}
iSentenceIndex++;
}
}
int CSection::FindWord(const string &wordname)
{
vector<CSentence>::iterator senIterator;
int sum = 0;
for (senIterator=m_SentenceList.begin(); senIterator!=m_SentenceList.end(); senIterator++)
{
sum += senIterator->FindWord(wordname, m_SectionIndex);
}
return sum;
}
int CSection::DisplayWord(map<string, int> &A)
{
vector<CSentence>::iterator senIterator;
for (senIterator=m_SentenceList.begin(); senIterator!=m_SentenceList.end(); senIterator++)
{
senIterator->DisplayWord(A);
}
return SUCCESS;
}
int CSection::Quit(void)
{
vector<CSentence>::iterator senIterator;
for (senIterator=m_SentenceList.begin(); senIterator!=m_SentenceList.end(); senIterator++)
{
senIterator->Quit();
}
m_SentenceList.clear();
return SUCCESS;
}
int CSection::GetTotalWord(void)
{
int sum = 0;
vector<CSentence>::iterator senIterator;
for (senIterator=m_SentenceList.begin(); senIterator!=m_SentenceList.end(); senIterator++)
{
sum += senIterator->GetTotalWord();
}
return sum;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -