
resources.jape.clean.jape Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of linguistic-simplifier Show documentation
Show all versions of linguistic-simplifier Show documentation
Linguistic based techniques for text simplification
The newest version!
/*
* clean.jape
*
* Copyright (c) 2004-2013, The University of Sheffield.
*
* This file is part of GATE (see http://gate.ac.uk/), and is free software,
* Licensed under the GNU Library General Public License, Version 3, June 2007
* (in the distribution as file licence.html, and also available at
* http://gate.ac.uk/gate/licence.html).
*
* Original version developed by Mark A. Greenwood as part of his PhD thesis.
*/
Phase: Clean
Input: Redundant
Options: control = appelt
Rule:Clean1
(
{Redundant}
):replace
-->
{
Annotation replace = bindings.get("replace").iterator().next();
// get the start and end of this section
Node start = replace.getStartNode();
Node end = replace.getEndNode();
AnnotationSet set = inputAS.get("Redundant",start.getOffset(),end.getOffset());
if (set == null) return;
long length = end.getOffset().longValue() - start.getOffset().longValue();
inputAS.remove(replace);
Iterator it = set.iterator();
while (it.hasNext())
{
gate.Annotation a = (gate.Annotation)it.next();
long nl = a.getEndNode().getOffset().longValue() - a.getStartNode().getOffset().longValue();
if (nl > length)
{
inputAS.remove(replace);
replace = a;
length = nl;
}
else
{
inputAS.remove(a);
}
}
outputAS.add(replace);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy