1

我可以为 DZC_FigureCitation 注释设置特征值

目前我能够匹配和设置特征值(章节和部分)图 1.1。我还需要匹配和设置图 1 的特征值(章节 = 0 和部分)。

样本输入:

 Figure 1.1
 Figure 1.2
 Figure 1
 Figure 2.3
 Figure 2 

脚本:

 MayBeFigure (COLON|PERIOD)? NUM? (SPECIAL|PERIOD)? NUM{-> MARK(ChapterNumber,3),MARK(FigureNumber,5), MARK(FigureCitation, 1, 5),MARK(FIGURE,1)};
 MayBeFigure{-PARTOF(FIGURE)} (COLON|PERIOD)? NUM{-PARTOF(ChapterNumber),-PARTOF(FigureCitation) -> MARK(FigureNumber,3),MARK(FigureCitation,1,3),MARK(FIGURE,1)};


BLOCK (foreach) FigureCitation {}
{

DECLARE DZC_FigureCitation(INT chapter,INT section);
ACTION FCC(INT chap,INT sect) = CREATE(DZC_FigureCitation, "chapter" = chap, "section" = sect); 

INT Figchap=0;
INT Figsec; 
(FIGURE (COLON|PERIOD)? ChapterNumber?{PARSE(Figchap)}(PERIOD|HYPHEN)? @FigureNumber{PARSE(Figsec)}){-PARTOF(DZC_FigureCitation),-PARTOF(DZC_SupplFigureCitation)-> FCC(Figchap,Figsec)}; 


}

预期输出:

 Figure 1.1 
       chapter:1
       section:1
 Figure 1.2
       chapter:1
       section:2
 Figure 1
       chapter:0
       section:1
 Figure 2.3
       chapter:2
       section:3
 Figure 2 
       chapter:0
       section:2  

接收输出:

 Figure 1.1 
       chapter:1
       section:1
 Figure 1.2
       chapter:1
       section:2
 Figure 1
       chapter:1
       section:1
 Figure 2.3
       chapter:2
       section:3
 Figure 2 
       chapter:2
       section:2 
4

2 回答 2

1

UIMA Ruta 中的变量是全局的。您需要在最后一条规则之前重置块循环中的值:

Document{-> ASSIGN(Figchap,0),ASSIGN(Figsec,0)};
(FIGURE (COLON|PERIOD)? ChapterNumber?{PARSE(Figchap)}(PERIOD|HYPHEN)? @FigureNumber{PARSE(Figsec)}){-PARTOF(DZC_FigureCitation),-PARTOF(DZC_SupplFigureCitation)-> FCC(Figchap,Figsec)}; 

免责声明:我是 UIMA Ruta 的开发人员

于 2016-10-13T14:27:37.467 回答
0
MayBeFigure (COLON|PERIOD)? NUM? (SPECIAL|PERIOD)? NUM{-> MARK(ChapterNumber,3),MARK(FigureNumber,5), MARK(FigureCitation, 1, 5),MARK(FIGURE,1)};
MayBeFigure{-PARTOF(FIGURE)} (COLON|PERIOD)? NUM{-PARTOF(ChapterNumber),-PARTOF(FigureCitation) -> MARK(FigureNumber,3),MARK(FigureCitation,1,3),MARK(FIGURE,1)};

DECLARE DZC_FigureCitation(INT chapter,INT section);
ACTION FCC(INT chap,INT sect) = CREATE(DZC_FigureCitation, "chapter" = chap, "section" = sect); 


BLOCK (foreach) FigureCitation {}
{
INT Figchap;
INT Figsec; 
Document{->ASSIGN(Figchap,0)};
Document{->ASSIGN(Figsec,0)};



(FIGURE (COLON|PERIOD)? ChapterNumber?{PARSE(Figchap)}(PERIOD|HYPHEN)? @FigureNumber{PARSE(Figsec)}){-PARTOF(DZC_FigureCitation)-> FCC(Figchap,Figsec)}; 


} 
于 2016-10-12T06:19:09.263 回答