public int buildFeatures() { if (word_num <= 0) { return(Utils.ERROR_INVALIDATED_PARAMETER); } using (var v = _buildersPool.GetOrCreate()) { var builder = v.Item; var id = 0; var feature_cache_row_size = 0; var feature_cache_size = 0; for (var cur = 0; cur < word_num; cur++) { feature_cache_row_size = 0; for (int index = 0; index < featureIndex.unigram_templs_.Count; index++) { var templ = featureIndex.unigram_templs_[index]; var res = featureIndex.apply_rule(templ, cur, builder, this); if (res == null) { return(Utils.ERROR_EMPTY_FEATURE); } id = featureIndex.get_id(res.ToString()); if (id != -1) { feature_cache_[feature_cache_size][feature_cache_row_size] = id; feature_cache_row_size++; } } feature_cache_[feature_cache_size][feature_cache_row_size] = -1; feature_cache_size++; } for (var cur = 0; cur < word_num; cur++) { feature_cache_row_size = 0; for (int index = 0; index < featureIndex.bigram_templs_.Count; index++) { var templ = featureIndex.bigram_templs_[index]; var strFeature = featureIndex.apply_rule(templ, cur, builder, this); if (strFeature == null) { return(Utils.ERROR_EMPTY_FEATURE); } id = featureIndex.get_id(strFeature.ToString()); if (id != -1) { feature_cache_[feature_cache_size][feature_cache_row_size] = id; feature_cache_row_size++; } } feature_cache_[feature_cache_size][feature_cache_row_size] = -1; feature_cache_size++; } return(Utils.ERROR_SUCCESS); } }
public int buildFeatures() { if (word_num <= 0) { return(Utils.ERROR_INVALIDATED_PARAMETER); } var id = 0; var feature_cache_row_size = 0; var feature_cache_size = 0; for (var cur = 0; cur < word_num; cur++) { feature_cache_row_size = 0; for (int index = 0; index < featureIndex.unigram_templs_.Count; index++) { var templ = featureIndex.unigram_templs_[index]; var strFeature = featureIndex.apply_rule(templ, cur, this); if (strFeature == "") { return(Utils.ERROR_EMPTY_FEATURE); } id = featureIndex.get_id(strFeature); if (id != -1) { feature_cache_[feature_cache_size][feature_cache_row_size] = id; feature_cache_row_size++; } } feature_cache_[feature_cache_size][feature_cache_row_size] = -1; feature_cache_size++; } for (var cur = 0; cur < word_num; cur++) { feature_cache_row_size = 0; for (int index = 0; index < featureIndex.bigram_templs_.Count; index++) { var templ = featureIndex.bigram_templs_[index]; var strFeature = featureIndex.apply_rule(templ, cur, this); if (strFeature == "") { return(Utils.ERROR_EMPTY_FEATURE); } id = featureIndex.get_id(strFeature); if (id != -1) { feature_cache_[feature_cache_size][feature_cache_row_size] = id; feature_cache_row_size++; } } feature_cache_[feature_cache_size][feature_cache_row_size] = -1; feature_cache_size++; } return(Utils.ERROR_SUCCESS); }
public int buildFeatures() { if (word_num <= 0) { return(Utils.ERROR_INVALIDATED_PARAMETER); } int id = 0; int feature_cache_row_size = 0; int feature_cache_size = 0; for (int cur = 0; cur < word_num; cur++) { feature_cache_row_size = 0; foreach (string templ in featureIndex.unigram_templs_) { string strFeature = featureIndex.apply_rule(templ, cur, this); if (strFeature == "") { return(Utils.ERROR_EMPTY_FEATURE); } id = featureIndex.get_id(strFeature); if (id != -1) { feature_cache_[feature_cache_size][feature_cache_row_size] = id; feature_cache_row_size++; } } feature_cache_[feature_cache_size][feature_cache_row_size] = -1; feature_cache_size++; } for (int cur = 0; cur < word_num; cur++) { feature_cache_row_size = 0; foreach (string templ in featureIndex.bigram_templs_) { string strFeature = featureIndex.apply_rule(templ, cur, this); if (strFeature == "") { return(Utils.ERROR_EMPTY_FEATURE); } id = featureIndex.get_id(strFeature); if (id != -1) { feature_cache_[feature_cache_size][feature_cache_row_size] = id; feature_cache_row_size++; } } feature_cache_[feature_cache_size][feature_cache_row_size] = -1; feature_cache_size++; } return(Utils.ERROR_SUCCESS); }