私はViterbiParserとChartParserを使って "Birds fly"という文を解析しようとしています。プロセスを追跡すると、正常に動作するはずですが、常に返されます。None
ViterbiParserとChartParserがNLTKのPCFGにNoneを返す
ここにトレースがあります。 (ビタビ):
Inserting tokens into the most likely constituents table...
Insert: |=.| Birds
Insert: |.=| fly
Finding the most likely constituents spanning 1 text elements...
Insert: |=.| NNS -> 'Birds' [1.0]
Insert: |=.| NP -> NNS [0.206897]
Insert: |.=| VB -> 'fly' [1.0]
Insert: |.=| VP -> VB [0.21875]
Finding the most likely constituents spanning 2 text elements...
Insert: |==| S -> NP VP [1.0]
チャートパーサ:
|. Birds . fly .|
Leaf Init Rule:
|[---------------] .| [0:1] 'Birds'
|. [---------------]| [1:2] 'fly'
Bottom Up Predict Combine Rule:
|[---------------] .| [0:1] NNS -> 'Birds' *
Bottom Up Predict Combine Rule:
|[---------------] .| [0:1] NP -> NNS *
Bottom Up Predict Combine Rule:
|[---------------> .| [0:1] NP -> NP * NP
|[---------------> .| [0:1] S -> NP * VP
Bottom Up Predict Combine Rule:
|. [---------------]| [1:2] VB -> 'fly' *
Bottom Up Predict Combine Rule:
|. [---------------]| [1:2] VP -> VB *
|. [--------------->| [1:2] VP -> VB * VP
|. [--------------->| [1:2] VP -> VB * ADJP
|. [--------------->| [1:2] VP -> VB * PP
Bottom Up Predict Combine Rule:
|. [--------------->| [1:2] VP -> VP * PP
|. [--------------->| [1:2] VP -> VP * NP
|. [--------------->| [1:2] VP -> VP * VP
Single Edge Fundamental Rule:
|[===============================]| [0:2] S -> NP VP *
どちらのパーサーが正しく文を構築するが、それでもNoneを返すように見えます。どうしたの?
ライブラリコードにバグがありますか、またはNLTKを使用するコードにエラーがあると思われますか?後者が当てはまる場合、どのようなコードも提供せずに、私たちがあなたを助けることをどのように期待していますか? – lenz
これを何時間も作業した後、私は実際に問題を発見しました。私はPCFG文法を使っています。文法にロードされる最初のルールは、文法の開始状態として左辺を設定する必要があります。それを無効にする明確な方法はありません。私は文法の規則の順序を変更しました。現在は機能しています。 – user1209675
よろしくお願いします!あなた自身の質問に答えることを検討してください。それは将来の読者を助けるかもしれない。 – lenz