/* * reltime.jape * * Copyright (c) 1998-2001, 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,v 1.1 2004/09/10 13:33:24 akshay Exp $ */ // this file must follow time.jape // handles relative time sequences Phase: Name Input: Token Lookup TempDate TempYear Options: control = appelt Rule: GazDateWords Priority: 10 // yesterday evening ( ({Lookup.majorType == time_modifier})? ({Lookup.majorType == date_key}| {Lookup.minorType == day}) ( {Lookup.majorType == time_unit} )? ) :date --> :date.TempDate = {rule = "GazDateWords"} Rule: TimeAgo Priority:30 // 2 hours ago ( ({Token.kind == number}| {Token.category == DT}) ({Lookup.majorType == time_unit}) {Token.string == "ago"} ) :date --> :date.TempDate = {rule = "TimeAgo"} Rule: DateAgo Priority:30 // 2 weeks ago ( ({Token.kind == number}| {Token.category == DT}) ({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("rule1", dateAnn.getFeatures().get("rule")); features.put("rule2", "EarlyDate"); annotations.add(date.firstNode(), date.lastNode(), "TempDate", features); annotations.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}| {TempYear} ) )? ) :date --> :date.TempDate = {rule = FiscalDate} Rule: YearStart ( ({Token.string == "start"}| {Token.string == "end"}| {Token.string == "beginning"}) {Token.string == "of"} ({Token.category == DT}| {Token.category == "PRP$"} ) ({Lookup.majorType == time_modifier})? ({Lookup.majorType == date_unit}| {TempYear} ) ) :date --> :date.TempDate = {rule = YearStart} Rule: TheYearTo //[the] quarter to [date] ({Token.category == DT}| {Token.category == "PRP$"} ) ( {Lookup.majorType == date_unit} ({Token.string == "to"}| {Token.string == "ended"} ) {Lookup.majorType == date} ) :date --> :date.TempDate = {rule = TheYearTo}