Imports: { import gateStandAlone.* ;} Phase: MarkAlinea1Head Input: Alinea Token SpaceToken num HeaderLabel OpenQuote Options: control = appelt Rule: DoMarkAlinea1Head ({Token.string=="."}|{Token.string==")"})({SpaceToken.kind=="space"})?{SpaceToken.kind=="control"}({SpaceToken.kind=="control"})?{Token.string=="("}({Token.kind=="numberPrime"}|{Token.kind=="number"}|{Token.string=="Préliminaire"}|{Token.string=="Premier"}|{Token.string=="PREMIER"}){Token.string==")"}{SpaceToken.kind=="space"}(({Token.kind=="word", Token.orth=="upperInitial"}|{Token.string=="("})):header --> { AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header"); Node headerStart = headerAnnotation.firstNode(); Node headerEnd = headerAnnotation.lastNode(); //create property num String num = ""; AnnotationSet numAnnotation = (AnnotationSet) bindings.get("num"); if (numAnnotation != null) { Node numStart = numAnnotation.firstNode(); Node numEnd = numAnnotation.lastNode(); num = doc.getContent().toString().substring(numStart.getOffset().intValue(), numEnd.getOffset().intValue()); } //create property ruleName String ruleName = "Alinea1Head"; //create the new token FeatureMap features = Factory.newFeatureMap(); features.put("num", num); features.put("ruleName", ruleName); outputAS.add(headerStart, headerEnd, "Alinea_Head", features); } Phase: MarkAlinea2Head Input: Alinea Token SpaceToken num HeaderLabel OpenQuote Options: control = appelt Rule: DoMarkAlinea2Head {Token.string=="."}({SpaceToken.kind=="space"})?{SpaceToken.kind=="control"}({SpaceToken.kind=="control"})?(({Token.kind=="word", Token.orth=="upperInitial"}|{Token.string=="("})):header --> { AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header"); Node headerStart = headerAnnotation.firstNode(); Node headerEnd = headerAnnotation.lastNode(); //create property ruleName String ruleName = "Alinea2Head"; //create the new token FeatureMap features = Factory.newFeatureMap(); features.put("ruleName", ruleName); outputAS.add(headerStart, headerEnd, "Alinea_Head", features); } Phase: MarkAlinea3Head Input: Alinea Token SpaceToken num HeaderLabel OpenQuote Options: control = appelt Rule: DoMarkAlinea3Head {SpaceToken.kind=="control"}(({Token.string=="Art"}{Token.string=="."})|{Token.string=="Article"}){SpaceToken.kind=="space"}({Token.kind=="numberPrime"}|{Token.kind=="number"}|{Token.string=="Préliminaire"}|{Token.string=="Premier"}|{Token.string=="PREMIER"})({Token.string=="."})?{SpaceToken.kind=="space"}(({Token.kind=="word", Token.orth=="upperInitial"}|{Token.string=="("})):header --> { AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header"); Node headerStart = headerAnnotation.firstNode(); Node headerEnd = headerAnnotation.lastNode(); //create property num String num = ""; AnnotationSet numAnnotation = (AnnotationSet) bindings.get("num"); if (numAnnotation != null) { Node numStart = numAnnotation.firstNode(); Node numEnd = numAnnotation.lastNode(); num = doc.getContent().toString().substring(numStart.getOffset().intValue(), numEnd.getOffset().intValue()); } //create property ruleName String ruleName = "Alinea3Head"; //create the new token FeatureMap features = Factory.newFeatureMap(); features.put("num", num); features.put("ruleName", ruleName); outputAS.add(headerStart, headerEnd, "Alinea_Head", features); } Phase: MarkAlinea4Head Input: Alinea Token SpaceToken num HeaderLabel OpenQuote Options: control = appelt Rule: DoMarkAlinea4Head ({SpaceToken.kind=="space"}|{Token.kind=="punctuation"})(({Token.string=="Art"}{Token.string=="."})|{Token.string=="Article"}){SpaceToken.kind=="space"}({Token.string=="L"}{Token.string=="."}{SpaceToken.kind=="space"})?({Token.kind=="numberPrime"}|{Token.kind=="number"}|{Token.string=="Préliminaire"}|{Token.string=="Premier"}|{Token.string=="PREMIER"})({Token.string=="."})?{SpaceToken.kind=="space"}(({Token.kind=="word", Token.orth=="upperInitial"}|{Token.string=="("})):header --> { AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header"); Node headerStart = headerAnnotation.firstNode(); Node headerEnd = headerAnnotation.lastNode(); //create property num String num = ""; AnnotationSet numAnnotation = (AnnotationSet) bindings.get("num"); if (numAnnotation != null) { Node numStart = numAnnotation.firstNode(); Node numEnd = numAnnotation.lastNode(); num = doc.getContent().toString().substring(numStart.getOffset().intValue(), numEnd.getOffset().intValue()); } //create property ruleName String ruleName = "Alinea4Head"; //create the new token FeatureMap features = Factory.newFeatureMap(); features.put("num", num); features.put("ruleName", ruleName); outputAS.add(headerStart, headerEnd, "Alinea_Head", features); } Phase: MarkAlinea5Head Input: Alinea Token SpaceToken num HeaderLabel OpenQuote Options: control = appelt Rule: DoMarkAlinea5Head {Token.string==")"}{SpaceToken.kind=="control"}({SpaceToken.kind=="control"})?(({Token.kind=="word", Token.orth=="upperInitial"}|{Token.string=="("})):header --> { AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header"); Node headerStart = headerAnnotation.firstNode(); Node headerEnd = headerAnnotation.lastNode(); //create property ruleName String ruleName = "Alinea5Head"; //create the new token FeatureMap features = Factory.newFeatureMap(); features.put("ruleName", ruleName); outputAS.add(headerStart, headerEnd, "Alinea_Head", features); } Phase: MarkAlinea6Head Input: Alinea Token SpaceToken num HeaderLabel OpenQuote Options: control = appelt Rule: DoMarkAlinea6Head {Token.kind=="punctuation"}{Token.string=="("}({Token.kind=="numberPrime"}|{Token.kind=="number"}|{Token.string=="Préliminaire"}|{Token.string=="Premier"}|{Token.string=="PREMIER"}){Token.string==")"}({Token.kind=="punctuation"})?{SpaceToken.kind=="space"}(({Token.kind=="word", Token.orth=="upperInitial"}|{Token.string=="("})):header --> { AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header"); Node headerStart = headerAnnotation.firstNode(); Node headerEnd = headerAnnotation.lastNode(); //create property num String num = ""; AnnotationSet numAnnotation = (AnnotationSet) bindings.get("num"); if (numAnnotation != null) { Node numStart = numAnnotation.firstNode(); Node numEnd = numAnnotation.lastNode(); num = doc.getContent().toString().substring(numStart.getOffset().intValue(), numEnd.getOffset().intValue()); } //create property ruleName String ruleName = "Alinea6Head"; //create the new token FeatureMap features = Factory.newFeatureMap(); features.put("num", num); features.put("ruleName", ruleName); outputAS.add(headerStart, headerEnd, "Alinea_Head", features); } //Clean the Alinea_Head annotations (remove duplicates and the annotations within other) Phase: MarkCleanAlineaAnnotations Input: Act_Head Part_Head Book_Head Title_Head Chapter_Head Section_Head Subsection_Head Article_Head Paragraph_Head Alinea_Head Options: control = appelt Rule: DoMarkCleanAlinea ( ({Alinea_Head within Act_Head} | {Alinea_Head within Part_Head} | {Alinea_Head within Book_Head} | {Alinea_Head within Title_Head} | {Alinea_Head within Chapter_Head} | {Alinea_Head within Section_Head} | {Alinea_Head within Subsection_Head} | {Alinea_Head within Article_Head} | {Alinea_Head within Paragraph_Head}) ):reference --> { AnnotationSet toRemove = (gate.AnnotationSet) bindings.get("reference"); outputAS.removeAll(toRemove); inputAS.removeAll(toRemove); }