0

私は、Apache UIMAフレームワークを使用してドキュメントに注釈を付けるプロジェクトに取り組んでいます。すべてのドキュメントを 1 回渡して 1 回の for-lopp で処理する必要があるため、現在のドキュメントの現在の CAS オブジェクトを一時的に保存 (コピー) して、次の FS とヒープ値によってめちゃくちゃにならないようにする必要があります。

従うように、CasCopier を使用して、最初に現在の CAS をコピーし、次のドキュメントを処理する前にそれを表示しました。

 1.  public class DocumentAnalysis {
 2.    public DocumentAnalysis(CAS cas) {
 3.        this.cas = cas;
 4.    }
 5.     
 6.    public processDocuments(Document documents) {
 7.        for(Document document: documents) {
 8.            // process each document, after this method, the cas has all values
 9.            processSingleDoc(document);
10.
11.            // create a new CAS as the destination of copy
12.            CAS localCas = CASFactory.createCas().getCas();
13. 
14.            // copy the current CAS to the new CAS
15.            CASCopier.copyCas(this.cas, localCas, true);  
16.        }
17.    }
18.
19.    public processSingleDoc(Document document) {
20.        // the logic for processing
21.        // implement UIMA process() method
22.        ......
23.    }
24.
25.    CAS cas;
26.  }

ただし、問題は 12 行目で NullPointerException をスローしたことであり、getCAS() メソッドには indexRepository 変数が必要であり、作成した localCas にはその値がないことがわかりました。これは、新しい CAS の作成が正しくない可能性があることを意味します。

オンラインで検索しましたが、まだ解決策が見つかりません。現在のCASを新しく作成したCASにコピーする方法を知っている人はいますか?

前もって感謝します!!!

4

0 に答える 0