Commit bdfa81e3 authored by Nicolas Sannier's avatar Nicolas Sannier
Browse files

Pushing ARMLET for legislative text conversion

parent 8cbef046
Phase: DoMarkArticleHead
Input: Article Token SpaceToken num
Options: control = appelt
Rule: DoMarkArticleHead
{SpaceToken.kind=="control"}(({Token.string=="Art"}{Token.string=="."}{SpaceToken.kind=="space"}({Token.kind=="numberPrime"}|{Token.kind=="number"}):id{Token.string=="."}):num({SpaceToken.kind=="control"}({Token.string=="("}({Token}|{SpaceToken.kind=="space"})+{Token.string==")"}):block)?):header
-->
{
AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header");
Node headerStart = headerAnnotation.firstNode();
Node headerEnd = headerAnnotation.lastNode();
//create property id
String id = "";
AnnotationSet idAnnotation = (AnnotationSet) bindings.get("id");
if (idAnnotation != null)
{
Node idStart = idAnnotation.firstNode();
Node idEnd = idAnnotation.lastNode();
id = doc.getContent().toString().substring(idStart.getOffset().intValue(), idEnd.getOffset().intValue());
}
//create property title
String title = "";
AnnotationSet titleAnnotation = (AnnotationSet) bindings.get("title");
if (titleAnnotation != null)
{
Node titleStart = titleAnnotation.firstNode();
Node titleEnd = titleAnnotation.lastNode();
title = doc.getContent().toString().substring(titleStart.getOffset().intValue(), titleEnd.getOffset().intValue());
}
//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 block
String block = "";
AnnotationSet blockAnnotation = (AnnotationSet) bindings.get("block");
if (blockAnnotation != null)
{
Node blockStart = blockAnnotation.firstNode();
Node blockEnd = blockAnnotation.lastNode();
block = doc.getContent().toString().substring(blockStart.getOffset().intValue(), blockEnd.getOffset().intValue());
}
//create the new token
FeatureMap features = Factory.newFeatureMap();
features.put("id", id);
features.put("title", title);
features.put("num", num);
features.put("block", block);
outputAS.add(headerStart, headerEnd, "Article_Head", features);
}
Phase: DoMarkSectionHead
Input: Section Token SpaceToken num
Options: control = appelt
Rule: DoMarkSectionHead
{SpaceToken.kind=="control"}(({Token.string=="Section"}{SpaceToken.kind=="space"}({Token.kind=="numberPrime"}|{Token.kind=="number"}):id):num (({Token.string=="."}({SpaceToken.kind=="space"})?({Token.subkind=="dashpunct"}|{Token.string=="-"}))?({Token,!Token.string=="("}|{SpaceToken.kind=="space"})+({Token.string=="."})?):title):header{SpaceToken.kind=="control"}
-->
{
AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header");
Node headerStart = headerAnnotation.firstNode();
Node headerEnd = headerAnnotation.lastNode();
//create property id
String id = "";
AnnotationSet idAnnotation = (AnnotationSet) bindings.get("id");
if (idAnnotation != null)
{
Node idStart = idAnnotation.firstNode();
Node idEnd = idAnnotation.lastNode();
id = doc.getContent().toString().substring(idStart.getOffset().intValue(), idEnd.getOffset().intValue());
}
//create property title
String title = "";
AnnotationSet titleAnnotation = (AnnotationSet) bindings.get("title");
if (titleAnnotation != null)
{
Node titleStart = titleAnnotation.firstNode();
Node titleEnd = titleAnnotation.lastNode();
title = doc.getContent().toString().substring(titleStart.getOffset().intValue(), titleEnd.getOffset().intValue());
}
//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 block
String block = "";
AnnotationSet blockAnnotation = (AnnotationSet) bindings.get("block");
if (blockAnnotation != null)
{
Node blockStart = blockAnnotation.firstNode();
Node blockEnd = blockAnnotation.lastNode();
block = doc.getContent().toString().substring(blockStart.getOffset().intValue(), blockEnd.getOffset().intValue());
}
//create the new token
FeatureMap features = Factory.newFeatureMap();
features.put("id", id);
features.put("title", title);
features.put("num", num);
features.put("block", block);
outputAS.add(headerStart, headerEnd, "Section_Head", features);
}
Phase: DoMarkSubsectionHead
Input: Subsection Token SpaceToken num
Options: control = appelt
Rule: DoMarkSubsectionHead
{SpaceToken.kind=="control"}(({Token.string=="§"}{SpaceToken.kind=="space"}({Token.kind=="numberPrime"}|{Token.kind=="number"}):id):num (({Token.string=="."}({SpaceToken.kind=="space"})?({Token.subkind=="dashpunct"}|{Token.string=="-"}))?({Token,!Token.string=="("}|{SpaceToken.kind=="space"})+({Token.string=="."})?):title):header{SpaceToken.kind=="control"}
-->
{
AnnotationSet headerAnnotation = (AnnotationSet) bindings.get("header");
Node headerStart = headerAnnotation.firstNode();
Node headerEnd = headerAnnotation.lastNode();
//create property id
String id = "";
AnnotationSet idAnnotation = (AnnotationSet) bindings.get("id");
if (idAnnotation != null)
{
Node idStart = idAnnotation.firstNode();
Node idEnd = idAnnotation.lastNode();
id = doc.getContent().toString().substring(idStart.getOffset().intValue(), idEnd.getOffset().intValue());
}
//create property title
String title = "";
AnnotationSet titleAnnotation = (AnnotationSet) bindings.get("title");
if (titleAnnotation != null)
{
Node titleStart = titleAnnotation.firstNode();
Node titleEnd = titleAnnotation.lastNode();
title = doc.getContent().toString().substring(titleStart.getOffset().intValue(), titleEnd.getOffset().intValue());
}
//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 block
String block = "";
AnnotationSet blockAnnotation = (AnnotationSet) bindings.get("block");
if (blockAnnotation != null)
{
Node blockStart = blockAnnotation.firstNode();
Node blockEnd = blockAnnotation.lastNode();
block = doc.getContent().toString().substring(blockStart.getOffset().intValue(), blockEnd.getOffset().intValue());
}
//create the new token
FeatureMap features = Factory.newFeatureMap();
features.put("id", id);
features.put("title", title);
features.put("num", num);
features.put("block", block);
outputAS.add(headerStart, headerEnd, "Subsection_Head", features);
}
Phase: DoMarkActSegment
Input: Act_Head EOD
Options: control = all
Rule: DoMarkActSegment
(
({Act_Head}):left
({Act_Head} | {EOD}):right
):reference
-->
{
Node actStart = ((AnnotationSet) bindings.get("left")).firstNode();
Node actEnd = ((AnnotationSet) bindings.get("right")).firstNode();
FeatureMap features = Factory.newFeatureMap();
outputAS.add(actStart, actEnd, "Act_Segment", features);
Annotation actHeadAnnotation = bindings.get("left").iterator().next();
AnnotationSet span = (AnnotationSet) bindings.get("reference");
//================Get all the contained Section_Segment annotations ==============
Iterator<Annotation> sectionSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Section_Segment").iterator();
while (sectionSegmentIterator.hasNext())
{
Annotation sectionSegment = sectionSegmentIterator.next();
FeatureMap sectionSegmentFeatures = sectionSegment.getFeatures();
sectionSegmentFeatures.put("Act_id", actHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained Subsection_Segment annotations ==============
Iterator<Annotation> subsectionSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Subsection_Segment").iterator();
while (subsectionSegmentIterator.hasNext())
{
Annotation subsectionSegment = subsectionSegmentIterator.next();
FeatureMap subsectionSegmentFeatures = subsectionSegment.getFeatures();
subsectionSegmentFeatures.put("Act_id", actHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained Article_Segment annotations ==============
Iterator<Annotation> articleSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Article_Segment").iterator();
while (articleSegmentIterator.hasNext())
{
Annotation articleSegment = articleSegmentIterator.next();
FeatureMap articleSegmentFeatures = articleSegment.getFeatures();
articleSegmentFeatures.put("Act_id", actHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained Alinea_Segment annotations ==============
Iterator<Annotation> alineaSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Alinea_Segment").iterator();
while (alineaSegmentIterator.hasNext())
{
Annotation alineaSegment = alineaSegmentIterator.next();
FeatureMap alineaSegmentFeatures = alineaSegment.getFeatures();
alineaSegmentFeatures.put("Act_id", actHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained CrossReference_ref annotations ==============
Iterator<Annotation> crossRefIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("CrossReference_ref").iterator();
while (crossRefIterator.hasNext())
{
Annotation crossRef = crossRefIterator.next();
FeatureMap crossRefFeatures = crossRef.getFeatures();
crossRefFeatures.put("Act_id", actHeadAnnotation.getFeatures().get("id"));
}
}
Phase: DoMarkAlineaSegment
Input: Act_Head Section_Head Subsection_Head Article_Head Alinea_Head EOD
Options: control = all
Rule: DoMarkAlineaSegment
(
({Alinea_Head}):left
({Act_Head} | {Section_Head} | {Subsection_Head} | {Article_Head} | {Alinea_Head} | {EOD}):right
):reference
-->
{
Node alineaStart = ((AnnotationSet) bindings.get("left")).firstNode();
Node alineaEnd = ((AnnotationSet) bindings.get("right")).firstNode();
FeatureMap features = Factory.newFeatureMap();
outputAS.add(alineaStart, alineaEnd, "Alinea_Segment", features);
Annotation alineaHeadAnnotation = bindings.get("left").iterator().next();
AnnotationSet span = (AnnotationSet) bindings.get("reference");
//================Get all the contained CrossReference_ref annotations ==============
Iterator<Annotation> crossRefIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("CrossReference_ref").iterator();
while (crossRefIterator.hasNext())
{
Annotation crossRef = crossRefIterator.next();
FeatureMap crossRefFeatures = crossRef.getFeatures();
crossRefFeatures.put("Alinea_id", alineaHeadAnnotation.getFeatures().get("id"));
}
}
Phase: DoMarkArticleSegment
Input: Act_Head Section_Head Subsection_Head Article_Head EOD
Options: control = all
Rule: DoMarkArticleSegment
(
({Article_Head}):left
({Act_Head} | {Section_Head} | {Subsection_Head} | {Article_Head} | {EOD}):right
):reference
-->
{
Node articleStart = ((AnnotationSet) bindings.get("left")).firstNode();
Node articleEnd = ((AnnotationSet) bindings.get("right")).firstNode();
FeatureMap features = Factory.newFeatureMap();
outputAS.add(articleStart, articleEnd, "Article_Segment", features);
Annotation articleHeadAnnotation = bindings.get("left").iterator().next();
AnnotationSet span = (AnnotationSet) bindings.get("reference");
//================Get all the contained Alinea_Segment annotations ==============
Iterator<Annotation> alineaSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Alinea_Segment").iterator();
while (alineaSegmentIterator.hasNext())
{
Annotation alineaSegment = alineaSegmentIterator.next();
FeatureMap alineaSegmentFeatures = alineaSegment.getFeatures();
alineaSegmentFeatures.put("Article_id", articleHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained CrossReference_ref annotations ==============
Iterator<Annotation> crossRefIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("CrossReference_ref").iterator();
while (crossRefIterator.hasNext())
{
Annotation crossRef = crossRefIterator.next();
FeatureMap crossRefFeatures = crossRef.getFeatures();
crossRefFeatures.put("Article_id", articleHeadAnnotation.getFeatures().get("id"));
}
}
Phase: DoMarkSectionSegment
Input: Act_Head Section_Head EOD
Options: control = all
Rule: DoMarkSectionSegment
(
({Section_Head}):left
({Act_Head} | {Section_Head} | {EOD}):right
):reference
-->
{
Node sectionStart = ((AnnotationSet) bindings.get("left")).firstNode();
Node sectionEnd = ((AnnotationSet) bindings.get("right")).firstNode();
FeatureMap features = Factory.newFeatureMap();
outputAS.add(sectionStart, sectionEnd, "Section_Segment", features);
Annotation sectionHeadAnnotation = bindings.get("left").iterator().next();
AnnotationSet span = (AnnotationSet) bindings.get("reference");
//================Get all the contained Subsection_Segment annotations ==============
Iterator<Annotation> subsectionSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Subsection_Segment").iterator();
while (subsectionSegmentIterator.hasNext())
{
Annotation subsectionSegment = subsectionSegmentIterator.next();
FeatureMap subsectionSegmentFeatures = subsectionSegment.getFeatures();
subsectionSegmentFeatures.put("Section_id", sectionHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained Article_Segment annotations ==============
Iterator<Annotation> articleSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Article_Segment").iterator();
while (articleSegmentIterator.hasNext())
{
Annotation articleSegment = articleSegmentIterator.next();
FeatureMap articleSegmentFeatures = articleSegment.getFeatures();
articleSegmentFeatures.put("Section_id", sectionHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained Alinea_Segment annotations ==============
Iterator<Annotation> alineaSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Alinea_Segment").iterator();
while (alineaSegmentIterator.hasNext())
{
Annotation alineaSegment = alineaSegmentIterator.next();
FeatureMap alineaSegmentFeatures = alineaSegment.getFeatures();
alineaSegmentFeatures.put("Section_id", sectionHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained CrossReference_ref annotations ==============
Iterator<Annotation> crossRefIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("CrossReference_ref").iterator();
while (crossRefIterator.hasNext())
{
Annotation crossRef = crossRefIterator.next();
FeatureMap crossRefFeatures = crossRef.getFeatures();
crossRefFeatures.put("Section_id", sectionHeadAnnotation.getFeatures().get("id"));
}
}
Phase: DoMarkSubsectionSegment
Input: Act_Head Section_Head Subsection_Head EOD
Options: control = all
Rule: DoMarkSubsectionSegment
(
({Subsection_Head}):left
({Act_Head} | {Section_Head} | {Subsection_Head} | {EOD}):right
):reference
-->
{
Node subsectionStart = ((AnnotationSet) bindings.get("left")).firstNode();
Node subsectionEnd = ((AnnotationSet) bindings.get("right")).firstNode();
FeatureMap features = Factory.newFeatureMap();
outputAS.add(subsectionStart, subsectionEnd, "Subsection_Segment", features);
Annotation subsectionHeadAnnotation = bindings.get("left").iterator().next();
AnnotationSet span = (AnnotationSet) bindings.get("reference");
//================Get all the contained Article_Segment annotations ==============
Iterator<Annotation> articleSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Article_Segment").iterator();
while (articleSegmentIterator.hasNext())
{
Annotation articleSegment = articleSegmentIterator.next();
FeatureMap articleSegmentFeatures = articleSegment.getFeatures();
articleSegmentFeatures.put("Subsection_id", subsectionHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained Alinea_Segment annotations ==============
Iterator<Annotation> alineaSegmentIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("Alinea_Segment").iterator();
while (alineaSegmentIterator.hasNext())
{
Annotation alineaSegment = alineaSegmentIterator.next();
FeatureMap alineaSegmentFeatures = alineaSegment.getFeatures();
alineaSegmentFeatures.put("Subsection_id", subsectionHeadAnnotation.getFeatures().get("id"));
}
//================Get all the contained CrossReference_ref annotations ==============
Iterator<Annotation> crossRefIterator = inputAS.getContained(span.firstNode().getOffset(), span.lastNode().getOffset()).get("CrossReference_ref").iterator();
while (crossRefIterator.hasNext())
{
Annotation crossRef = crossRefIterator.next();
FeatureMap crossRefFeatures = crossRef.getFeatures();
crossRefFeatures.put("Subsection_id", subsectionHeadAnnotation.getFeatures().get("id"));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment