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

Docassemble autoterms误识别整段单选选项文本问题求助

问题:Autoterms 误将整个单选选项标记为术语,需仅高亮指定词汇

当前配置

单选选项列表代码

generic object: DADict
question: |
  (!!!) What is your desired outcome for your property?
fields:
  - "Destroy current property": x.assets['destroy_current_property']
    datatype: radio
    code: property_choices
    help: (!!!) To do
    default: x.assets.destroy_current_property
  - "Donate future property": x.assets['donate_future_property']
    datatype: radio
    code: property_choices
    help: (!!!) To do
    default: x.assets.donate_future_property

Autoterms 配置

auto terms:
  ...
  - property: |
      prŏp′ər-tē
      <br><br>
      /ˈaset/
      <br><br>
      noun
      <br><br>
      plural noun: properties
      <br><br>
      1. Something owned; a possession.
      <br><br>
      2. A piece of real estate.
      <br><br>
      3. Something tangible or intangible to which its owner has legal title.

问题现象

当前autoterms将整个单选选项文本(如"Destroy current property")包裹进带daterm类的<a>标签,生成的HTML如下:

<a tabindex="0" class="daterm" data-container="body" data-toggle="popover" data-placement="bottom" data-content="(!!!) To do" data-original-title="" title="">
Destroy current property
...
</a>

预期仅"property"一词被标记,正确的HTML结构应为:

<a tabindex="0" data-container="body" data-toggle="popover" data-placement="bottom" data-content="(!!!) To do" data-original-title="" title="">
Destroy current <span class="daterm">property</span>
...
</a>

解决方案

方案1:手动标记术语并禁用字段自动识别

修改单选选项的文本内容,直接插入术语标记,同时给字段添加disable_autoterms: true参数(如果框架支持该配置),避免自动识别覆盖手动设置:

fields:
  - "Destroy current <span class='daterm'>property</span>": x.assets['destroy_current_property']
    datatype: radio
    code: property_choices
    help: (!!!) To do
    default: x.assets.destroy_current_property
    disable_autoterms: true
  - "Donate future <span class='daterm'>property</span>": x.assets['donate_future_property']
    datatype: radio
    code: property_choices
    help: (!!!) To do
    default: x.assets.donate_future_property
    disable_autoterms: true

方案2:调整Autoterms的匹配规则

确保autoterms仅匹配独立的"property"单词,而非包含该词的整个字符串。修改autoterms配置,使用带单词边界的正则表达式作为术语触发条件:

auto terms:
  ...
  - \bproperty\b: |
      prŏp′ər-tē
      <br><br>
      /ˈaset/
      <br><br>
      noun
      <br><br>
      plural noun: properties
      <br><br>
      1. Something owned; a possession.
      <br><br>
      2. A piece of real estate.
      <br><br>
      3. Something tangible or intangible to which its owner has legal title.

注:部分框架可能要求明确指定匹配类型为正则,需根据实际框架文档补充对应配置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 20:46:04