gate.plugins.Lang_French.grammar.date_pre.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.
/*
* date_pre.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: date_pre.jape 11883 2009-11-03 16:27:32Z markagreenwood $
*/
Phase: DatePre
Options: control = appelt
///////
// Note: this muse come before the date phase, because it includes extra context
// to prevent dates being recognised erroneously in the middle of longer things
//////
Macro: ORDINAL
(
({Token.kind == number}
({Token.string == "th"}|
{Token.string == "rd"}|
{Token.string == "nd"}|
{Token.string == "st"})
|
{Lookup.minorType == ordinal})
(SPACE
{Token.string == "of"})?
)
/////////////////////////////////////////////////
Rule: GazDate
(SPACE | {Token.kind == punctuation})
(
({Lookup.minorType == day}) |
({Lookup.minorType == month}) |
({Lookup.minorType == festival})
)
:date
(SPACE | {Token.kind == punctuation})
-->
:date.TempDate = {rule = "GazDate"}
Rule: PersonDateAmbig
Priority: 100
(
(ORDINAL)
)
:date
(SPACE)
(
{TempPerson.kind == personName, TempPerson.rule == PersonFull}
):person
-->
:date.Date = {kind = date, rule = "PersonDateAmbig"},
{
//removes TempPerson annotation, gets the rule feature and adds a new Person annotation
gate.AnnotationSet person = (gate.AnnotationSet)bindings.get("person");
gate.Annotation personAnn = (gate.Annotation)person.iterator().next();
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule1", personAnn.getFeatures().get("rule"));
features.put("rule2", "PersonDateAmbig");
outputAS.add(person.firstNode(), person.lastNode(), "Person",
features);
outputAS.removeAll(person);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy