All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gate.plugins.Lang_French.grammar.org_context.jape Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 2.0
Show newest version
/*
*  org_context.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: org_context.jape 11883 2009-11-03 16:27:32Z markagreenwood $
*/


Phase:	Org_Context
Input: Token Lookup Organization Unknown Location Person
Options: control = appelt



Rule:OrgContext1
Priority: 1
// company X
// company called X

(
 {Token.string == "company"}
 (({Token.string == "called"}|
   {Token.string == "dubbed"}|
   {Token.string == "named"}
  )
 )?
)
(
 {Unknown.kind == PN}
)
:org
-->
{
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgContext1");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}

Rule: OrgContext2
Priority: 5

// Telstar laboratory
// Medici offices
(
 {Unknown.kind == PN}
): org
(
 ({Token.string == "offices"} |
 {Token.string == "Offices"} |
 {Token.string == "laboratory"} | 
 {Token.string == "Laboratory"} |
 {Token.string == "laboratories"} |
 {Token.string == "Laboratories"})
)
-->
{
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgContext2");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}

Rule:OrgContext3
Priority: 5
// X shares

(
 {Unknown.kind == PN}
):org
( 
 {Token.string == "shares"}
)
-->
{
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgContext3");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}

Rule:OrgContext4
Priority: 10
// shares in X

( 
 {Token.string == "shares"}
 {Token.string == "in"}
)
(
 {Unknown.kind == PN}
):org
-->
{
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgContext4");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}


Rule: OrgContext5
Priority: 10
// officials at X

(
 ({Token.string == "officials"}|
  {Token.string == "Officials"})
 {Token.string == "at"}
)
(
 {Unknown.kind == PN}
):org
-->
 {
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgContext5");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}


Rule:JoinOrg
Priority: 50
// Smith joined Energis
// later we should use the morph PR to prevent having to list morphological variants

(
 ({Token.string == "joined"}|
  {Token.string == "joining"}|
  {Token.string == "joins"}|
  {Token.string == "join"}
 )

)
( 
 {Unknown.kind ==PN}
)
:org
-->
 {
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "JoinOrg");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}


Rule:OrgPerson
Priority: 20
// Nokia Vice-President William Plummer

(
 {Unknown.kind == PN}
):org 
(
 ({Token.string == "'"}
  ({Token.string == "s"})?
 )?
 
 {Person.rule1 == PersonTitle}
)
--> 
 {
//get the matched annotation(s)
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");

//create the new annotation
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgPerson");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);

//delete the old annotation(s)
outputAS.removeAll(org);
}


Rule: OrgConjOrg1 
Priority: 10

(
{Unknown.kind == PN}
):org
(

{Token.category == CC}

{Organization}
)
-->
{
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgConjOrg1");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}


Rule: OrgConjOrg2
Priority: 10

(
 {Organization}
 
 {Token.category == CC}
 
)
(
 {Unknown.kind == PN}
):org
-->
 {
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgConjOrg2");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}



Rule: OrgJobtitle
Priority: 30
(
 {Unknown.kind == PN}
):org
( 
 
 {Lookup.majorType == jobtitle}
)
-->
  {
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule ", "OrgJobTitle");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}



Rule:LocOrg
Priority: 20
// guess that Unknown preceded by Loc is an Org

(
 {Location}
 {Unknown.kind == PN}
):org
-->
{
//removes Unknown annotation, adds a new Org annotation
gate.AnnotationSet org = (gate.AnnotationSet) bindings.get("org");
gate.FeatureMap features = Factory.newFeatureMap();
features.put("rule", "LocOrg");
outputAS.add(org.firstNode(), org.lastNode(), "Organization",
features);
outputAS.removeAll(org);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy