文脈の情報も取り入れつつ特徴ベクトルを構築する、の続き

自分用メモ。整理しないとわけが分からなくなってきた。

  • 特待のパターン以外のものを削除
    • find . -type f -not -name '*.txt' | xargs rm
  • 今のところ必要な情報は
    • 二つ前の形態素解析された単語(prev2context)
    • 一つ前の形態素解析された単語(prev_context)
    • 現在見ている単語の先頭の単語(heads)
    • 現在見ている単語の最後の単語(tails)
    • 現在見ている単語に登場している単名詞(words)
    • 一つ後の形態素解析された単語(next_context)
    • 二つ後の形態素解析された単語(next2context)
  • といった具合

こんな構造体のインスタンス*1を上のやつら分作ってあげる。

struct map_for_feature_vector {
  map<string, int> str2id; 
  // &#12098;字列から素性番号への連想配列 
  vector<string> id2str; 
  // 素性番号から&#12098;字列への逆引き 
  int getID(const string& str){ 
	map<string, int>::const_iterator it = str2id.find(str); 
	if (it != str2id.end()){ 
	  return it->second;   // 登録済みのIDを返す 
	} else {               // 登録されてない 
	  const int newID= str2id.size() + 1; 
	  str2id[str] = newID; // 登録 
	  id2str.push_back(str); 
	  return newID;        // 新しいiDを返す 
	} 
  }
  int size () {
	return str2id.size();
  }
};

*1:構造体の場合もインスタンスでいいのか…?