【发布时间】:2018-03-31 09:05:07
【问题描述】:
我需要设计一种基于如下定义强制执行约束的语言。下面的清单是brat 的实际注释配置。我的任务是为我们的内部工具设计一种用于类似目的的语言。我也打算用python写解析器。
[entities]
Drug
DrugClass
Procedure
Therapy
AE
SAE
Disease
[relations]
Equiv Arg1:<ENTITY>, Arg2:<ENTITY>, <REL-TYPE>:symmetric-transitive
BelongsTo Arg1:Drug , Arg2:DrugClass
BelongsTo Arg1:AE , Arg2:AE
BelongsTo Arg1:AE , Arg2:SAE
BelongsTo Arg1:SAE , Arg2:SAE
BelongsTo Arg1:SAE , Arg2:AE
BelongsTo Arg1:Disease , Arg2:Disease
BelongsTo Arg1:Drug , Arg2:Therapy
BelongsTo Arg1:Procedure , Arg2:Therapy
BelongsTo Arg1:Surgery , Arg2:Therapy
<CAUSE>=Drug|DrugClass|Therapy|Procedure
<EV>=AE|SAE
AssociatedWith Arg1:<CAUSE> , Arg2:<EV>
NotAssociatedWith Arg1:<CAUSE> , Arg2:<EV>
Causes Arg1:<CAUSE> , Arg2:<EV>
NotCauses Arg1:<CAUSE> , Arg2:<EV>
HasEffect Arg1:<CAUSE> , Arg2:Disease
HasNoEffect Arg1:<CAUSE> , Arg2:Disease
<OVERLAP> Arg1:<ANY>, Arg2:<ANY>, <OVL-TYPE>:<ANY>
我想到的是以下内容。
[entities]
# subtyping entities which is already present in brat
Entity
Trigger
Drug
DrugClass
Procedure
Therapy
Effect
AE
SAE
Disease
[relations]
# Any subtype of Trigger can be Associated with any subtype of Effect except Disease
AssociatedWith Arg1:Trigger , Arg2:Effect.except(Disease)
NotAssociatedWith Arg1:Trigger , Arg2:Effect.except(Disease)
Causes Arg1:Trigger , Arg2:Effect.except(Disease)
NotCauses Arg1:Trigger , Arg2:Effect.except(Disease)
HasEffect Arg1:Trigger , Arg2:Disease
HasNoEffect Arg1:Trigger , Arg2:Disease
# Equiv relation can exist between Drug and Drug,
# DrugClass and DrugClass and so on,
# but not between different subtypes Drug and AE
Equiv Arg1:Entity* , Arg2: Entity*
BelongsTo Arg1:Entity* , Arg2: Entity*
BelongsTo Arg1:Drug , Arg2:Therapy
BelongsTo Arg1:Procedure , Arg2:Therapy
BelongsTo Arg1:Surgery , Arg2:Therapy
<OVERLAP> Arg1:<ANY>, Arg2:<ANY>, <OVL-TYPE>:<ANY>
是否已经有一种语言可以做到这一点。我研究了 Prolog,这似乎是一种矫枉过正。我想我正在寻找一种可以处理对象分组和粒度寻址的语言,以便可以简洁地指定约束。谢谢
【问题讨论】:
标签: python-3.x configuration data-annotations constraint-programming