Search code examples
uimaruta

setting feature value to zero for some instance in uima ruta


I'm able to set the feature value for the DZC_FigureCitation annotation

Currently I'm able to match and set feature value (chapter and section) Figure 1.1.I also need to match and set feature value (chapter=0 and section) for Figure 1.

Sample Input:

 Figure 1.1
 Figure 1.2
 Figure 1
 Figure 2.3
 Figure 2 

Script:

 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)}; 


}

Expected Output:

 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  

Received Output:

 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 

Solution

  • 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)}; 
    
    
    }