gate.plugins.ANNIE.resources.NE.reldate.jape Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gate-extraction Show documentation
Show all versions of gate-extraction Show documentation
Gate based component, that can process the Text units to extract informations using Gate's tools (such as grammars, gazetteers, tokenizer or POS Taggers).
This project contains two versions, a simple component and webservice one.
/*
* reltime.jape
*
* Copyright (c) 1998-2004, The University of Sheffield.
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
* software, licenced under the GNU Library General Public License,
* Version 2, June 1991 (in the distribution as file licence.html,
* and also available at http://gate.ac.uk/gate/licence.html).
*
* Diana Maynard, 10 Sep 2001
*
* $Id: reldate.jape 11879 2009-11-03 13:24:55Z markagreenwood $
*/
// this file must follow time.jape
// handles relative time sequences
Phase: Name
Input: Token Lookup TempDate
Options: control = appelt
Rule: GazDateWords
Priority: 10
// yesterday evening
(
{Lookup.majorType == date_key}
(
{Lookup.majorType == time_unit}
)?
)
:date -->
:date.TempDate = {rule = "GazDateWords"}
Rule: TimeAgo
Priority:30
// 2 hours ago
(
{Token.kind == number}
({Lookup.majorType == time_unit})
{Token.string == "ago"}
)
:date -->
:date.TempDate = {rule = "TimeAgo"}
Rule: DateAgo
Priority:30
// 2 weeks ago
(
{Token.kind == number}
({Lookup.majorType == date_unit})
{Token.string == "ago"}
)
:date -->
:date.TempDate = {rule = "TimeAgo"}
Rule: ModifierDate
Priority: 30
// last year
// next 10 years
(
{Lookup.majorType == time_modifier}
(
({Lookup.majorType == number}|
{Token.kind == number}
)
)?
{Lookup.majorType == date_unit}
)
:date -->
:date.TempDate = {rule = "ModifierDate"}
Rule: EarlyDate
// early in 2002
// in early 2002
(
({Token.string == early}|
{Token.string == late}
)
({Token.string == "in"}
)?
({TempDate}|
(
{Lookup.majorType == time_modifier}
{Lookup.majorType == date_unit}
)
)
)
:date
-->
{
//removes TempDate annotation, gets the rule feature and adds a new TempDate annotation
gate.AnnotationSet date = (gate.AnnotationSet)bindings.get("date");
gate.Annotation dateAnn = (gate.Annotation)date.iterator().next();
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule", dateAnn.getFeatures().get("rule"));
features.put("rule2", "EarlyDate");
outputAS.add(date.firstNode(), date.lastNode(), "TempDate",
features);
outputAS.removeAll(date);
}
Rule:FiscalDate
// first half of next year
// first nine months of the financial year
(
{Lookup.minorType == ordinal}
(
({Lookup.majorType == number}|
{Token.kind == number}
)
)?
{Lookup.majorType == date_unit}
({Token.string == "of"}
)?
((
{Token.category == DT}|
{Token.category == "PRP$"}
)
)?
({Lookup.majorType == time_modifier}
)?
{Lookup.majorType == date_unit}
)
:date -->
:date.TempDate = {rule = FiscalDate}
//[the] quarter to [date]
© 2015 - 2024 Weber Informatics LLC | Privacy Policy