【问题标题】:UIMA RUTA - Sofa mapping -in Aggregate PipelineUIMA RUTA - 沙发映射 - 聚合管道
【发布时间】:2014-04-11 03:07:25
【问题描述】:

这是关于问题的。

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

我正在尝试按照建议设置沙发映射。我有一个包含多个 AE 的聚合 AE,并尝试在此管道中合并 2 个 RUTA AE/脚本。两个 RUTA AE(和相关脚本)都负责使用修饰符进行 REGEXP 查找和替换。第二个 AE 取决于第一个 AE 的输出。我必须配置修改器的第二个 AE 的输出视图,否则我会收到“沙发数据已设置”异常。

本质上,我无法将一个 AE 的输出编织成另一个 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 AE(step1、step2、normalizer)都使用 RUTA Modifier
  • 上述设置抛出异常“No sofaFS with name norm_2_out 找到。” - 这发生在第 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

谢谢

【问题讨论】:

  • 您能否提供您的聚合分析引擎的实际/完整的沙发映射(代码)?
  • 我已经用完整的 AggregateAE 代码更新了问题
  • 对此有什么想法吗?我对 SOFA 映射做错了吗?
  • 还没来得及看,这周晚些时候我会试试的。
  • 那太好了!谢谢

标签: uima ruta


【解决方案1】:

我在您的示例中注意到的第一件事是您必须在 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

请注意,我删除了 ruta 描述符中的绝对路径并调整了导入脚本的命名空间。它们现在由类路径加载以进行测试,而不是使用绝对路径。

测试调用聚合分析引擎AAE.xml,导入并映射5个分析引擎:

  • CWEngine.xml:替换大写单词的简单 Ruta 脚本。 CW{-&gt;REPLACE("CW")};CW.ruta
  • ModiferCW.xml:普通修饰符
  • SWEngine.xml:简单的 Ruta 脚本,用于替换小字。 SW{-&gt;REPLACE("SW")};SW.ruta
  • ModiferSW.xml:普通修饰符
  • SimpleEngine.xml:简单的 Ruta 脚本,它定义了一个新类型并匹配“CW”后跟“SW”。 DECLARE CwSw; ("CW" "SW"){-&gt; CwSw};Simple.ruta

聚合分析引擎定义了三个视图:global1(输入)、global2(输出)和 global3(输出)。组件的沙发映射如下:

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

给定视图 global1 中的文本 Peter is tired.,聚合分析引擎创建两个新视图,视图 global3 包含文本 CW SW SW. 和一个类型为 Simple.CwSw 的注释。

【讨论】:

  • 如答案中所述,目前不可能。至少我看不到如何做到这一点。不过,我会处理它,如果您仍然感兴趣,我会用解决方案写一个新的答案。
  • 感谢您的回答。我曾经使用过修改器 AE 描述符,但暂停了这个想法,但会再次研究它。话虽如此,如果您能想到任何其他想法来解决将 RUTA 作为预处理管道的一部分的问题,那就太好了。
  • 问题会得到解决,但如果不改变实现可能是不可能的。因此,您需要使用 ruta 2.2.1-SNAPSHOT。
  • 迁移到 2.2.1-SNAPSHOT 应该不是问题。期待解决方案。另外,请写关于指定输入和输出沙发映射的评论,即使我计划将一个 AE 的输出映射为另一个 AE 的输入,Eclipse desc 编辑器不允许为输入和输出指定相同的沙发名称。也许我需要做更多的阅读,但任何指针都会有所帮助。再次感谢。
  • 这是因为脚本的描述符对内联修饰符一无所知,因此没有沙发功能。问题解决后,我会发布一个运行示例。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-05
  • 2021-09-13
  • 2018-08-27
相关资源
最近更新 更多