本文整理汇总了C++中sequence::size方法的典型用法代码示例。如果您正苦于以下问题:C++ sequence::size方法的具体用法?C++ sequence::size怎么用?C++ sequence::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sequence
的用法示例。
在下文中一共展示了sequence::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
viterbi_trellis crf::viterbi_scorer::viterbi(const sequence& seq)
{
// we only need the scores for the states as the transition scores, set
// up during construction, will never change between sequences
scorer_.state_scores(*model_, seq);
viterbi_trellis table{seq.size(), model_->num_labels()};
// initialize first column of trellis. We use the original state() and
// trans() matrices because we are working in the log domain.
for (label_id lbl{0}; lbl < model_->num_labels(); ++lbl)
table.probability(0, lbl, scorer_.state(0, lbl));
// compute remaining columns of trellis using recursive formulation
for (uint64_t t = 1; t < seq.size(); ++t)
{
for (label_id lbl{0}; lbl < model_->num_labels(); ++lbl)
{
double max_score = std::numeric_limits<double>::lowest();
for (label_id in{0}; in < model_->num_labels(); ++in)
{
auto score = table.probability(t - 1, in)
+ scorer_.trans(in, lbl);
if (score > max_score)
{
max_score = score;
table.previous_tag(t, lbl, in);
}
}
table.probability(t, lbl, max_score + scorer_.state(t, lbl));
}
}
return table;
}
示例2: if
// is end of a chunk (IOB1)?
int evaluation::is_end_of_chunk_iob1(int human_model, int i, sequence & seq,
string b_tag, string i_tag) {
if (human_model == 1) {
if (seq[i].label == atoi(b_tag.c_str())) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1].label != atoi(i_tag.c_str())) {
return 1;
} else {
return 0;
}
}
} else if (seq[i].label == atoi(i_tag.c_str())) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1].label != atoi(i_tag.c_str())) {
return 1;
} else {
return 0;
}
}
} else {
return 0;
}
} else if (human_model == 2) {
if (seq[i].model_label == atoi(b_tag.c_str())) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1].model_label != atoi(i_tag.c_str())) {
return 1;
} else {
return 0;
}
}
} else if (seq[i].model_label == atoi(i_tag.c_str())) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1].model_label != atoi(i_tag.c_str())) {
return 1;
} else {
return 0;
}
}
} else {
return 0;
}
} else {
return 0;
}
}
示例3: is_end_of_chunk_iob1
// is end of a chunk (IOB1)?
int is_end_of_chunk_iob1(int human_model, int i, sequence & seq,
string b_tag, string i_tag) {
if (human_model == 1) {
if (seq[i][seq[i].size() - 2] == b_tag) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1][seq[i + 1].size() - 2] != i_tag) {
return 1;
} else {
return 0;
}
}
} else if (seq[i][seq[i].size() - 2] == i_tag) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1][seq[i + 1].size() - 2] != i_tag) {
return 1;
} else {
return 0;
}
}
} else {
return 0;
}
} else if (human_model == 2) {
if (seq[i][seq[i].size() - 1] == b_tag) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1][seq[i + 1].size() - 1] != i_tag) {
return 1;
} else {
return 0;
}
}
} else if (seq[i][seq[i].size() - 1] == i_tag) {
if (i >= seq.size() - 1) {
return 1;
} else {
if (seq[i + 1][seq[i + 1].size() - 1] != i_tag) {
return 1;
} else {
return 0;
}
}
} else {
return 0;
}
} else {
return 0;
}
}
示例4: conv
sequence<R> operator*( const sequence<T1> &X, const sequence<T2> &Y )
{
if( X.size()==0 || Y.size()==0 )
return sequence<R>();
vec<R> vec = conv( X.buffer(), Y.buffer() );
int t1 = X.t1() + Y.t1();
return sequence<R>( vec, t1 );
}
示例5: generate_vietoris_sequence
void generate_vietoris_sequence(sequence& a) {
if (a.empty())
return;
a[0] = rdm(0, MAX_VAL);
if (a.size() < 2)
return;
a[1] = rdm(0, a[0]);
for (int k = 2; k < a.size(); k++) {
a[k] = rdm(0, (1.0 * k - 1) / k) * a[k - 1];
}
}
示例6: cast
/*
* Helper for element and docuemnt constructors to insert sequence
* of atomic values. Returns true if node was actually inserted.
* In this case left pointer is changed to the last inserted indirection.
* In any case at_vals sequence is cleared.
*/
static inline bool
process_atomic_values(xptr& left, const xptr& parent, sequence& at_vals) {
if (at_vals.size() > 0)
{
executor_globals::tmp_op_str_buf.clear();
tuple_cell tcc;
sequence::iterator it = at_vals.begin();
do {
tcc = tuple_cell::make_sure_light_atomic((*it).cells[0]);
tcc = cast(tcc, xs_string);
executor_globals::tmp_op_str_buf.append(tcc);
it++;
}
while (it != at_vals.end());
at_vals.clear();
if(executor_globals::tmp_op_str_buf.get_size() > 0) {
insert_text(indirectionDereferenceCP(left),
XNULL,
indirectionDereferenceCP(parent),
text_source_strbuf(&(executor_globals::tmp_op_str_buf)));
left = get_last_mo_inderection();
return true;
}
}
return false;
}
示例7:
void crf::tagger::tag(sequence& seq)
{
auto trellis = scorer_.viterbi(seq);
auto lbls = util::range(label_id{0},
label_id(static_cast<uint32_t>(num_labels_ - 1)));
auto last_lbl = functional::argmax(
lbls.begin(), lbls.end(), [&](label_id lbl)
{
return trellis.probability(seq.size() - 1, lbl);
});
seq[seq.size() - 1].label(*last_lbl);
for (uint64_t t = seq.size() - 1; t > 0; t--)
seq[t - 1].label(trellis.previous_tag(t, seq[t].label()));
}
示例8: orthonomial
orthonomial(const sequence &a, const sequence &b, const sequence &c) : n(c.size() - 1), a(a), b(b), c(c) {
/* Ze względów bezpieczeństwa. */
this->a.push_back(0);
this->b.push_back(0);
this->c.push_back(0);
this->c.push_back(0);
}
示例9: while
// is matching chunk (IOE2)?
int evaluation::is_matching_chunk_ioe2(int i, sequence & seq, string i_tag, string e_tag) {
if (!is_start_of_chunk_ioe2(1, i, seq, i_tag, e_tag) ||
!is_start_of_chunk_ioe2(2, i, seq, i_tag, e_tag)) {
return 0;
}
int len = seq.size();
int j = i, k = i;
while (j < len) {
if (is_end_of_chunk_ioe2(1, j, seq, i_tag, e_tag)) {
break;
} else {
j++;
}
}
while (k < len) {
if (is_end_of_chunk_ioe2(2, k, seq, i_tag, e_tag)) {
break;
} else {
k++;
}
}
return (j == k);
}
示例10: tag
void perceptron::tag(sequence& seq) const
{
for (uint64_t t = 0; t < seq.size(); ++t)
{
analyzer_.analyze(seq, t);
seq[t].label(model_.best_class(seq[t].features()));
seq[t].tag(analyzer_.tag(seq[t].label()));
}
}
示例11: objkey
RObject
AORB::object_key_to_object(sequence<octet>& object_key)
{
RString str = new String((const char*)object_key.data(), object_key.size(), NormalSST | CCAscii);
ObjectKey objkey(str);
if (objkey.isLocal() == true)
return objkey.getLocalObject();
// return Skelleton here
return Nil;
}
示例12: inner_prod
complex inner_prod(const sequence<T> &X, const sequence<T> &Y )
{
// If any vector is empty
if( X.size() == 0 || Y.size() == 0 )
return 0;
// Overlapping interval
int ta = max(X.t1(),Y.t1());
int tb = min(X.t2(),Y.t2());
// If they do not overlap
if( ta > tb )
return 0;
// They do overlap
complex r = 0;
for( int t = ta; t <= tb; t++ )
r += inner_prod( X(t), Y(t) );
return r;
}
示例13: compare_error
// compares the given two instances of ss
double cm_assembly_ssq3::compare(ss const &__first, ss const &__second) const {
sequence<cchb_dssp> const seq1(__first.get_sequence()), seq2(__second.get_sequence());
if(seq1.size() != seq2.size()) {
throw math::compare_error(get_identifier() + ": Sequence length differ, sequence1.length=" +
std::to_string(seq1.size()) + ", sequence2.length=" + std::to_string(seq2.size()));
} // if
size_t c_correct(0), h_correct(0), e_correct(0); // initialize
for(size_t pos(0); pos < seq1.size(); ++pos) { // works for both sequences b/c of same length
char const sequence1_ss(seq1[pos].get_identifier_char());
char const sequence2_ss(seq2[pos].get_identifier_char());
if(sequence1_ss == sequence2_ss) { // actually it's only important that they are the same, not which one
if(sequence1_ss == 'C') {
++c_correct;
} // if
else if(sequence1_ss == 'H') {
++h_correct;
} // else if
else if(sequence1_ss == 'E') {
++e_correct;
} // else if
} // if
} // for
DEBUG << get_identifier() << ": c_correct=" << c_correct << " h_correct=" << h_correct
<< " e_correct=" << e_correct << " seq_len=" << seq1.size();
return ((double)c_correct + h_correct + e_correct) / seq1.size();
} // compare()
示例14: count_matching_chunks_ioe2
// counting matching chunks (IOE2)
int count_matching_chunks_ioe2(sequence & seq, string i_tag, string e_tag) {
int count = 0;
for (int i = 0; i < seq.size(); i++) {
if (is_start_of_chunk_ioe2(1, i, seq, i_tag, e_tag)) {
if (is_matching_chunk_ioe2(i, seq, i_tag, e_tag)) {
count++;
}
}
}
return count;
}
示例15: decltype
sequence<decltype(T()*S())> element_prod( const sequence<T>& X, const sequence<S>& Y )
{
typedef decltype(T()*S()) R;
// If any vector is empty
if( X.size() == 0 || Y.size() == 0 )
return sequence<R>();
// Overlapping interval
int ta = max(X.t1(),Y.t1());
int tb = min(X.t2(),Y.t2());
// If they do not overlap
if( ta > tb )
return sequence<R>();
// They do overlap
vec<R> v = element_prod(
X.buffer()( range( ta-X.t1(), tb-X.t1()+1 ) ),
Y.buffer()( range( ta-Y.t1(), tb-Y.t1()+1 ) ) );
return sequence<R>( v, ta );
}