本文整理汇总了C++中Token::GetText方法的典型用法代码示例。如果您正苦于以下问题:C++ Token::GetText方法的具体用法?C++ Token::GetText怎么用?C++ Token::GetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_selectFile_clicked
void MainWindow::on_selectFile_clicked()
{
QFileDialog dialog;
if (dialog.exec())
{
if (!dialog.selectedFiles().size()) return;
int counter = 0;
QFile file(dialog.selectedFiles()[0]);
file.open(QFile::ReadOnly);
Tokenizer tokenizer(file);
Token tok;
QString sb;
QString sb1k;
QString sb32k;
do
{
tok = tokenizer.Next();
if (tok.GetType() == Token::eof) break;
if (!(counter++ % 256))
{
std::cout << "counter: " << counter << std::endl;
}
sb1k = sb1k % tok.GetText();
if (sb1k.size() == 256)
{
sb32k = sb32k % sb1k;
sb1k.clear();
if (sb32k.size() == 32768)
{
sb = sb % sb32k;
sb32k.clear();
}
}
} while (true);
if (sb1k.size())
{
sb32k = sb32k % sb1k;
}
if (sb32k.size())
{
sb = sb % sb32k;
}
ui->textBrowser->setText(sb);
file.close();
}
}
示例2: TestText
void TestToken::TestText()
{
SpeechSet* speechSet = new SpeechSet();
Speech* speech = new Speech(speechSet);
Segment* segment = Segment::CreateWithDuration(0, 10000, speech);
Token* token = Token::CreateWithDuration(0, 0, segment);
token->SetSourceText("hop");
assert(token->GetText() == "hop");
//JGF Note: I only added the full test cases for optional frags for the SetProperty("align.optionally", "both") test
Properties::SetProperty("align.optionally", "both");
// (hop)
token->SetSourceText("(hop)");
assert(token->GetSourceText() == "(hop)");
assert(token->GetText() == "hop");
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
assert(token->IsOptional());
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "hop");
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "hop");
// hop-
Properties::SetProperty("align.fragment_are_correct", "false");
token->SetSourceText("hop-");
assert(token->GetSourceText() == "hop-");
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "hop");
assert(token->GetFragmentStatus() == Token::BEGIN_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "hop-");
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
// (hop-)
Properties::SetProperty("align.fragment_are_correct", "false");
token->SetSourceText("(hop-)");
assert(token->GetSourceText() == "(hop-)");
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "hop");
assert(token->GetFragmentStatus() == Token::BEGIN_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "hop-");
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
// -hop
Properties::SetProperty("align.fragment_are_correct", "false");
token->SetSourceText("-hop");
assert(token->GetSourceText() == "-hop");
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "hop");
assert(token->GetFragmentStatus() == Token::END_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "-hop");
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
// (-hop)
Properties::SetProperty("align.fragment_are_correct", "false");
token->SetSourceText("(-hop)");
assert(token->GetSourceText() == "(-hop)");
Properties::SetProperty("align.fragment_are_correct", "true");
cout << "Get " << token->GetText() << endl;
assert(token->GetText() == "hop");
assert(token->GetFragmentStatus() == Token::END_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "-hop");
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
Properties::SetProperty("align.optionally", "ref");
speechSet->SetOrigin("ref");
token->SetSourceText("(hop)");
assert(token->GetSourceText() == "(hop)");
assert(token->GetText() == "hop");
assert(token->IsOptional());
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "hop");
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "hop");
token->SetSourceText("(hop-)");
assert(token->GetSourceText() == "(hop-)");
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "hop");
assert(token->GetFragmentStatus() == Token::BEGIN_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "hop-");
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
Properties::SetProperty("align.optionally", "ref");
speechSet->SetOrigin("hyp");
token->SetSourceText("(hop)");
assert(token->GetSourceText() == "(hop)");
assert(token->GetText() == "(hop)");
assert(!token->IsOptional());
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "(hop)");
Properties::SetProperty("align.fragment_are_correct", "false");
assert(token->GetText() == "(hop)");
token->SetSourceText("(hop-)");
assert(token->GetSourceText() == "(hop-)");
Properties::SetProperty("align.fragment_are_correct", "true");
assert(token->GetText() == "(hop-)");
assert(token->GetFragmentStatus() == Token::NOT_FRAGMENT);
Properties::SetProperty("align.fragment_are_correct", "false");
//.........这里部分代码省略.........