Julius 4.2
関数
libjulius/src/factoring_sub.c

言語スコアのfactoring計算(第1パス) [詳細]

#include <julius/julius.h>

ソースコードを見る。

関数

void make_successor_list (WCHMM_INFO *wchmm)
 木構造化辞書上の全ノードに successor list を構築するメイン関数
void adjust_sc_index (WCHMM_INFO *wchmm)
 構築された factoring 情報を multipath 用に調整する.
void max_successor_cache_init (WCHMM_INFO *wchmm)
 木構造化辞書用の factoring キャッシュをメモリ割り付けして初期化する.
static void max_successor_prob_iw_free (WCHMM_INFO *wchmm)
 単語間の factoring cache のメモリ領域を解放する.
void max_successor_cache_free (WCHMM_INFO *wchmm)
 factoring 用 cache のメモリ領域を全て解放する.
static LOGPROB calc_successor_prob (WCHMM_INFO *wchmm, WORD_ID lastword, int node)
 木構造化辞書上のあるノードについて,与えられた単語履歴に対する2-gram スコアを計算する.
LOGPROB max_successor_prob (WCHMM_INFO *wchmm, WORD_ID lastword, int node)
 単語内のあるノードについて factoring 値を計算する.
LOGPROBmax_successor_prob_iw (WCHMM_INFO *wchmm, WORD_ID lastword)
 単語間の factoring 値のリストを返す.
boolean can_succeed (WCHMM_INFO *wchmm, WORD_ID lastword, int node)
 文法による単語内決定的 factoring

説明

言語スコアのfactoring計算(第1パス)

このファイルには,第1パスにおいて言語スコアの factoring を行うための 関数が含まれています. 木構造化辞書上でのサブツリー内の単語リスト (successor list) の構築,および認識中の言語スコア計算ルーチンが 含まれます.

successor list は,木構造化辞書の各ノードに割り付けられる, そのノードを共有する単語のリストです. 木構造化辞書において, 枝部分の次のノードがこのリストを保持します. 実際にはリストが変化する 場所,すなわち木構造化辞書の枝の分岐点に割り付けられます. 例えば,以下のような木構造化辞書の場合,数字の書いてあるノードに successor list が割り付けられます.

        2-o-o - o-o-o - o-o-o          word "A" 
       /
  1-o-o
       \       4-o-o                   word "B"
        \     /   
         3-o-o - 5-o-o - 7-o-o         word "C"
              \        \ 
               \        8-o-o          word "D"
                6-o-o                  word "E"
 

各 successor list はそのサブツリーに含まれる単語のリストです. この例では以下のようになります.

   node  | successor list (wchmm->state[node].sc)
   =======================
     1   | A B C D E
     2   | A
     3   |   B C D E
     4   |   B
     5   |     C D
     6   |         E
     7   |     C
     8   |       D
 

ある successor list に含まれる単語が1つになったとき,その時点で 単語が確定する. 上記の場合,単語 "A" はノード 2 の位置ですでに その後続単語として "A" 以外無いので,そこで確定する. すなわち,単語 A の正確な言語スコアは,単語終端を待たずノード 2 で決まる.

第1パスにおける factoring の計算は,実際には beam.c で行なわれる. 2-gram factoringの場合,次ノードに successor list が存在すれば, その successor list の単語の 2-gram の最大値を求め, 伝搬してきている factoring 値を更新する. successor list に単語が1つのノードでは, 正しい2-gramが自動的に割り当てられる. 1-gram factoringの場合,次ノードに successor list が存在する場合, その successor list の単語の 1-gram の最大値を求め,伝搬してきている factoring 値を更新する. successor list に単語が1つのノードで,はじめて 2-gram を計算する.

実際では 1-gram factoring では各 successor list における factoring 値 は単語履歴に非依存なので,successor list 構築時に全てあらかじめ計算して おく. すなわち,エンジン起動時に木構造化辞書を構築後,successor list を構築したら,単語を2個以上含む successor list についてはその 1-gram の 最大値を計算して,それをそのノードの fscore メンバに格納しておき,その successor list は free してしまえばよい. 単語が1つのみの successor list についてはその単語IDを残しておき,探索時にパスがそこに到達したら 正確な2-gramを計算すれば良い.

DFA文法使用時は,デフォルトでは言語制約(カテゴリ対制約)を カテゴリ単位で木を構築することで静的に表現する. このため, これらの factoring 機構は用いられない. ただし, CATEGORY_TREE が undefined であれば,決定的 factoring を用いた言語制約 適用を行うことも可能である. すなわち,次ノードに successor list が存在すれば, その successor list 内の各単語と直前単語の単語対制約を調べ, そのうち一つでも接続可能な単語があれば,その遷移を許し,一つも なければ遷移させない. この機能は技術参考のために残されているのみである.

This file contains functions to do language score factoring on the 1st pass. They build a successor lists which holds the successive words in each sub tree on the tree lexicon, and also provide a factored LM probability on each nodes on the tree lexicon.

The "successor list" will be assigned for each lexicon tree node to represent a list of words that exist in the sub-tree and share the node. Actually they will be assigned to the branch node. Below is the example of successor lists on a tree lexicon, in which the lists is assigned to the numbered nodes.

         2-o-o - o-o-o - o-o-o          word "A" 
        /
   1-o-o
        \       4-o-o                   word "B"
         \     /   
          3-o-o - 5-o-o - 7-o-o         word "C"
           \            \ 
            \            8-o-o          word "D"
             6-o-o                      word "E"
 

The contents of the successor lists are the following:

  node  | successor list (wchmm->state[node].sc)
  =======================
    1   | A B C D E
    2   | A
    3   |   B C D E
    4   |   B
    5   |     C D
    6   |         E
    7   |     C
    8   |       D
 

When the 1st pass proceeds, if the next going node has a successor list, all the word 2-gram scores in the successor list on the next node will be computed, and the propagating LM value in the token on the current node will be replaced by the maximum value of the scores when copied to the next node. Appearently, if the successor list has only one word, it means that the word can be determined on that point, and the precise 2-gram value will be assigned as is.

When using 1-gram factoring, the computation will be slightly different. Since the factoring value (maximum value of 1-gram scores on each successor list) is independent of the word context, they can be computed statically before the search. Thus, for all the successor lists that have more than two words, the maximum 1-gram value is computed and stored to "fscore" member in tree lexicon, and the successor lists will be freed. The successor lists with only one word should still remain in the tree lexicon, to compute the precise 2-gram scores for the words.

When using DFA grammar, Julian builds separated lexicon trees for every word categories, to statically express the catergory-pair constraint. Thus these factoring scheme is not used by default. However you can still force Julian to use the grammar-based deterministic factoring scheme by undefining CATEGORY_TREE. If CATEGORY_TREE is undefined, the word connection constraint will be performed based on the successor list at the middle of tree lexicon. This enables single tree search on Julian. This function is left only for technical reference.

作者:
Akinobu LEE
日付:
Mon Mar 7 23:20:26 2005
Revision:
1.5

factoring_sub.c で定義されています。


関数

void make_successor_list ( WCHMM_INFO wchmm)

木構造化辞書上の全ノードに successor list を構築するメイン関数

引数:
wchmm[i/o] 木構造化辞書

factoring_sub.c187 行で定義されています。

参照元 build_wchmm(), と build_wchmm2().

関数の呼び出しグラフ:

呼出しグラフ:

void adjust_sc_index ( WCHMM_INFO wchmm)

構築された factoring 情報を multipath 用に調整する.

factoring 情報を, モデル全体をスキップする遷移がある場合はその先の音素へコピーする. また,(出力を持たない)文頭文法ノードに単語先頭ノードからコピーする.

引数:
wchmm[in] 木構造化辞書

factoring_sub.c493 行で定義されています。

参照元 build_wchmm(), と build_wchmm2().

関数の呼び出しグラフ:

呼出しグラフ:

void max_successor_cache_init ( WCHMM_INFO wchmm)

木構造化辞書用の factoring キャッシュをメモリ割り付けして初期化する.

この関数はプログラム開始時に一度だけ呼ばれる.

引数:
wchmm[i/o] 木構造化辞書

factoring_sub.c587 行で定義されています。

参照元 j_launch_recognition_instance().

関数の呼び出しグラフ:

呼出しグラフ:

static void max_successor_prob_iw_free ( WCHMM_INFO wchmm) [static]

単語間の factoring cache のメモリ領域を解放する.

引数:
wchmm[i/o] 木構造化辞書

factoring_sub.c638 行で定義されています。

参照元 max_successor_cache_free(), と max_successor_prob_iw().

void max_successor_cache_free ( WCHMM_INFO wchmm)

factoring 用 cache のメモリ領域を全て解放する.

引数:
wchmm[i/o] 木構造化辞書

factoring_sub.c666 行で定義されています。

参照元 j_recogprocess_free().

関数の呼び出しグラフ:

呼出しグラフ:

static LOGPROB calc_successor_prob ( WCHMM_INFO wchmm,
WORD_ID  lastword,
int  node 
) [static]

木構造化辞書上のあるノードについて,与えられた単語履歴に対する2-gram スコアを計算する.

引数:
wchmm[in] 木構造化辞書
lastword[in] 直前単語
node[in] wchmm 上のノード番号
戻り値:
2-gram 確率.

factoring_sub.c864 行で定義されています。

参照元 max_successor_prob(), と max_successor_prob_iw().

LOGPROB max_successor_prob ( WCHMM_INFO wchmm,
WORD_ID  lastword,
int  node 
)

単語内のあるノードについて factoring 値を計算する.

1-gram factoring で固定factoring値がある場合はその値が即座に返される. 他の場合は,そのノードのサブツリー内の単語の 2-gram確率(の最大値)が 計算される.

単語内 factoring キャッシュが考慮される. すなわち各ノードについて 直前単語が前回アクセスされたときと同じであれば, 前回の値が返され,そうでなければ値を計算し,キャッシュが更新される.

引数:
wchmm[in] 木構造化辞書
lastword[in] 直前単語のID
node[in] ノード番号
戻り値:
言語モデルスコア

factoring_sub.c943 行で定義されています。

参照元 beam_intra_word_core(), と init_nodescore().

関数の呼び出しグラフ:

呼出しグラフ:

LOGPROB* max_successor_prob_iw ( WCHMM_INFO wchmm,
WORD_ID  lastword 
)

単語間の factoring 値のリストを返す.

与えられた直前単語に対して,factoring値を計算すべき全ての単語先頭への factoring 値を計算し,そのリストを返す. このfactoring値は 直前単語ごとにリスト単位でキャッシュされる. すなわち,その直前単語が それまでに一度でも直前単語として出現していた場合,そのリストをそのまま 返す.

引数:
wchmm[in] 木構造化辞書
lastword[in] 直前単語
戻り値:
全単語先頭ノードへの factoring スコアのリスト

factoring_sub.c1050 行で定義されています。

参照元 beam_inter_word().

関数の呼び出しグラフ:

呼出しグラフ:

boolean can_succeed ( WCHMM_INFO wchmm,
WORD_ID  lastword,
int  node 
)

文法による単語内決定的 factoring

Julian において CATEGORY_TREE が定義されているとき(デフォルト), 木構造化辞書はカテゴリ単位(すなわち構文制約の記述単位)で構築されるため, 第1パスでの言語モデルであるカテゴリ対制約は単語の始終端で適用できる.

この CATEGORY_TREE が定義されていない場合,木構造化辞書は 辞書全体で単一の木が作られるため,カテゴリ対制約は N-gram (Julius) と 同様に単語内で factoring と同様の機構で適用される必要がある.

この関数は CATEGORY_TREE が定義されていないときに,上記の factoring (決定的 factoring と呼ばれる)を行なうために提供されている.

引数:
wchmm[in] 木構造化辞書
lastword[in] 直前単語
node[in] ノード番号
戻り値:
カテゴリ制約上その枝への遷移が許されれば TRUE, 不可能であれば FALSE

factoring_sub.c1196 行で定義されています。

参照元 beam_inter_word(), と beam_intra_word_core().

関数の呼び出しグラフ:

呼出しグラフ: