You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UIMA Ruta中能否通过WORDTABLE实现文本部分匹配?

Using UIMA Ruta WORDTABLE for Suffix-Based Matching

Absolutely! You can pull off this suffix-based matching and feature assignment using UIMA Ruta's WORDTABLE functionality. Here's a step-by-step breakdown tailored to your specific case:

1. Prepare Your CSV Mapping File

First, confirm your CSV file (let’s name it suffix_mappings.csv) uses the correct semicolon separators as you provided:

book;b.
ship;sh.

Each row links a target suffix to its corresponding feature value.

2. Configure WORDTABLE for Suffix Matching

By default, WORDTABLE uses prefix matching, but Ruta lets you switch to suffix mode with simple parameters. Add this declaration to your Ruta script:

// Declare the WORDTABLE with suffix matching enabled
WORDTABLE suffixMap = "suffix_mappings.csv";
WORDTABLE(suffixMap, false, ";", 1, 2, SUFFIX);

// Enable case-insensitive matching by changing the second parameter to true:
// WORDTABLE(suffixMap, true, ";", 1, 2, SUFFIX);

Let’s break down those parameters:

  • false: Disables case-insensitive matching (flip to true if you need to match "Book" or "SHIP" variants)
  • ;: The delimiter used in your CSV file
  • 1: Column index (starting at 1) for suffix keys (book, ship)
  • 2: Column index for feature values (b., sh.)
  • SUFFIX: Tells Ruta to match the end of each word against the table’s keys

3. Apply the Matching & Feature Assignment Rule

First, make sure you’ve defined a custom feature in your type system (e.g., STRING suffixFeature; for the WORD type). Then use this rule to assign values:

// Match qualifying words and assign their mapped feature value
WORD{-> ASSIGN(suffixFeature, suffixMap.getValue())};

4. Expected Results for Your Input Text

For your input:

yearbook book databook worship friendship yearbook

The rule will assign:

  • b. to yearbook, book, databook (all end with book)
  • sh. to worship, friendship (all end with ship)

Quick Tips

  • Verify your CSV file path: if it’s not in the same directory as your script, use the full path or place it in your project’s resource folder.
  • If a word could match multiple suffixes (unlikely here), WORDTABLE prioritizes the longest matching suffix.
  • Ensure your type system includes the custom feature you’re assigning (define this in the Ruta descriptor or a separate type system XML file).

内容的提问来源于stack exchange,提问作者Sugunalakshmi Pagemajik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:19:18