2014-04-11 33 views
1

這是關於這個問題。UIMA RUTA - 沙發貼圖-in Aggregate Pipeline

UIMA RUTA - how to do find & replace using regular expression and groups

我試圖設置沙發映射的建議。我有一個AE AE和幾個AE,並試圖在這個管道中加入2個RUTA AE /腳本。兩個RUTA AE(以及相關的腳本)都負責REGEXP查找並使用修飾符進行替換。第二個AE取決於第一個AE的輸出。我不得不配置第二AE的修改器的outputView,否則我得到'沙發數據已設置'異常。

實質上,我無法編織一個輸出作爲另一個AE的輸入。

的設置我有類似於下面,

_initialview --Input> (Normalizer1 RUTA AE) --Output> norm_1_out 
norm_1_out --Input> (Normalizer2 RUTA AE) --Output> norm_2_out 
norm_2_out --Input> (Other AE) 

下面是總結AE代碼

<?xml version="1.0" encoding="UTF-8"?> 

<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier"> 
    <frameworkImplementation>org.apache.uima.java</frameworkImplementation> 
    <primitive>false</primitive> 
    <delegateAnalysisEngineSpecifiers> 
    <delegateAnalysisEngine key="NormalizerPrepStep1"> 
     <import location="../../../ruta-annotators/desc/NormalizeNumbersEngine.xml"/> 
    </delegateAnalysisEngine> 

    <delegateAnalysisEngine key="NormalizerPrepStep2"> 
     <import location="../../../ruta-annotators/desc/NormalizeRangesEngine.xml"/> 
    </delegateAnalysisEngine> 
    <delegateAnalysisEngine key="Normalizer"> 
     <import location="../../../ruta-annotators/desc/NormalizerEngine.xml"/> 
    </delegateAnalysisEngine>  
    <delegateAnalysisEngine key="SimpleAnnotator"> 
     <import location="../../../textanalyzer/desc/analysis_engine/SimpleAnnotator.xml"/> 
    </delegateAnalysisEngine> 
    </delegateAnalysisEngineSpecifiers> 
    <analysisEngineMetaData> 
    <name>RUTAAggregatePlaintextProcessor</name> 
    <description>Runs the complete pipeline for annotating documents in plain text format.</description> 
    <version/> 
    <vendor/> 
    <configurationParameters searchStrategy="language_fallback"> 
     <configurationParameter> 
     <name>SegmentID</name> 
     <description/> 
     <type>String</type> 
     <multiValued>false</multiValued> 
     <mandatory>false</mandatory> 
     <overrides> 
      <parameter>SimpleAnnotator/SegmentID</parameter> 
     </overrides> 
     </configurationParameter> 
    </configurationParameters> 
    <configurationParameterSettings/> 
    <flowConstraints> 
     <fixedFlow> 
     <node>NormalizerPrepStep1</node> 
     <node>NormalizerPrepStep2</node> 
     <node>Normalizer</node> 
     <node>SimpleAnnotator</node> 
     </fixedFlow> 
    </flowConstraints> 
    <typePriorities> 
     <name>Ordering</name> 
     <description>For subiterator</description> 
     <version>1.0</version> 
     <priorityList> 
     </priorityList> 
    </typePriorities> 
    <fsIndexCollection/> 
    <capabilities> 
     <capability> 
     <inputs/> 
     <outputs/> 
     <inputSofas> 
      <sofaName>norm_1_out</sofaName> 
     <sofaName>norm_2_out</sofaName> 
      <sofaName>normalized</sofaName> 
     </inputSofas> 
     <languagesSupported/> 
     </capability> 
    </capabilities> 
    <operationalProperties> 
     <modifiesCas>true</modifiesCas> 
     <multipleDeploymentAllowed>true</multipleDeploymentAllowed> 
     <outputsNewCASes>false</outputsNewCASes> 
    </operationalProperties> 
    </analysisEngineMetaData> 
    <resourceManagerConfiguration/> 
<sofaMappings> 
    <sofaMapping> 
     <componentKey>SimpleAnnotator</componentKey> 
     <aggregateSofaName>normalized</aggregateSofaName> 
    </sofaMapping> 
    <sofaMapping> 
     <componentKey>NormalizerPrepStep2</componentKey> 
     <aggregateSofaName>norm_1_out</aggregateSofaName> 
    </sofaMapping> 
    <sofaMapping> 
     <componentKey>Normalizer</componentKey> 
     <aggregateSofaName>norm_2_out</aggregateSofaName> 
    </sofaMapping> 
    </sofaMappings> 
</analysisEngineDescription> 

幾件事情要注意,

  • 所有三個RUTA AES(步驟1, step2,normalizer)使用RUTA修飾符
  • 上面的設置會引發一個錯誤n「沒有發現名爲norm_2_out 的sofaFS。」 - 這發生在步驟2之後。
  • 我試圖將'norm_2_out'切換爲'modified'作爲輸入沙發 標準化程序,這似乎將處理移至管道中的下一個步驟(標準化程序),但是會拋出沙發功能 setLocalSofaData()的數據已被設置爲例外「。在 org.apache.uima.ruta.engine.RutaModifier.process(RutaModifier.java:107)
  • 我試圖與RUTA 2.2.0(快照)具有相同的結果

正如我對於UIMA和RUTA來說都是比較新的,不知道我是否做錯了什麼,或者我遇到了什麼限制。

順便說一句,我使用的是RUTA 2.1.0

感謝

+0

您能否提供您的聚合分析引擎的實際/完整沙發映射(代碼)? –

+0

我已經用完整的AggregateAE代碼更新了這個問題 – user3449698

+0

對此有何想法?我在做SOFA映射時出錯了嗎? – user3449698

回答

0

,我在你的榜樣注意到的第一件事是,你必須在你的AAE指定輸出沙發。這些都是由AAE創建的沙發,例如它的一個組件。 然後有沙發映射丟失。您必須連接AE的輸出視圖和其他AE的輸入視圖。在你的例子中,我只能看到默認的輸入視圖。

我創建了一個單元測試,它可以作爲此任務的一個示例應用。

測試是在這裏:在測試中使用https://svn.apache.org/repos/asf/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/CascadedModifierTest.java

資源(描述)在這裏:https://svn.apache.org/repos/asf/uima/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/engine

記住,我刪除了魯塔描述符的絕對路徑和適應進口腳本的名稱空間。它們現在通過classpath加載進行測試,而不是使用絕對路徑。

該測試調用聚合分析引擎AAE。xml,它導入和映射五個分析引擎:

  • CWEngine.xml:簡單的Ruta腳本替換大寫的單詞。 CW{->REPLACE("CW")}; CW.ruta
  • ModiferCW.xml:普通修飾符
  • SWEngine.xml:簡單的Ruta腳本,用於替換小寫的單詞。 SW{->REPLACE("SW")}; SW.ruta
  • ModiferSW.xml:正常修飾符
  • SimpleEngine.xml:簡單的Ruta腳本,定義一個新類型並匹配「CW」後跟「SW」。 DECLARE CwSw; ("CW" "SW"){-> CwSw}; Simple.ruta

聚合分析引擎定義了三個視圖:global1(輸入),global2(輸出)和global3(輸出)。組分的沙發映射如下:

GLOBAL1 - > [CWEngine,ModiferCW] - > global2 - > [SWEngine,ModiferSW] - > global3-> [SimpleEngine]

鑑於文本Peter is tired.在查看global1,聚合分析引擎將創建兩個新視圖,其中包含文本CW SW SW.的視圖global3和類型Simple.CwSw的一個註釋。

+0

正如答案中所述,目前不可能。至少我沒有看到如何去做。儘管如此,我會照顧它,如果您仍然對此感興趣,我會用解決方案寫一個新答案。 –

+0

感謝您的回答。我曾經玩過Modifier AE描述符,但暫停了這個想法,但會再次研究它。話雖如此,如果您能想出任何其他想法來解決RUTA作爲預處理流程的一部分的問題,那就太好了。 – user3449698

+0

問題將得到解決,但如果不更改實施方案,則可能無法解決問題。因此,您需要使用ruta 2.2.1-SNAPSHOT。 –