Phase: Bio_Relations2 Input: Lookup Token Space Options: control = appelt Rule: BioRel1 Priority: 25 ( ( { Lookup.majorType == IgnoreList } ( {SpaceToken.kind == space} )* ) ( ( {Token.category == JJ} | {Token.category == JJR} ) ( {SpaceToken.kind == space} )* )* ( {Token.category == NN} | {Token.category == NNS} | {Token.category == NNPS} | {Token.category == NNP} )* ( { Lookup.majorType == BiologicalEntity } ) ):ignore --> {} Rule: BioRel2 Priority: 24 ( ( { Lookup.majorType == IgnoreList } ( {SpaceToken.kind == space} )* ) ( { Lookup.majorType == BiologicalEntity } ) ):ignore --> {} Rule: BioRel3 Priority: 23 ( ( { Lookup.majorType == IgnoreList } ( {SpaceToken.kind == space} )* ) ( {Token.category == NN} | {Token.category == NNS} | {Token.category == NNPS} | {Token.category == NNP} )* ):ignore --> {} Rule: Bio_SubclassOfRelation1 Priority: 15 ( ( ( {Token.category == JJ} | {Token.category == JJR} ) ( {SpaceToken.kind == space} )* )* ( ( {Token.category == NN} | {Token.category == NNS} | {Token.category == NNPS} | {Token.category == NNP} ) ( {SpaceToken.kind == space} )* )* ( { Token.string == "cell" } | { Token.string == "cells" } | { Token.string == "neuron" } | { Token.string == "neurons" } |{Token.string == glia} | {Token.string == glium} ) ):bio --> { gate.AnnotationSet bio = (gate.AnnotationSet)bindings.get( "bio" ); List tokensList = new ArrayList( bio ); Collections.sort( tokensList, new gate.util.OffsetComparator() ); // remove space tokens for (int x = 0; x < tokensList.size() ; x++) { gate.Annotation cellsAnno = (gate.Annotation) tokensList.get(x); String type = (String) cellsAnno.getType(); if (type.equals("SpaceToken")) { tokensList.remove(x); } } String cell = ""; for (int i = tokensList.size()-1 ; i >0; i--) { gate.Annotation cellsAnno = (gate.Annotation) tokensList.get(i); String current = (String) cellsAnno.getFeatures().get("string"); // range is now cell gate.Annotation cellsAnnoNext = (gate.Annotation) tokensList.get(i - 1); if (i == (tokensList.size() -1)) { if (current.lastIndexOf("s") == current.length() - 1) { cell = current.substring(0, current.length()-1).toLowerCase(); } else { cell = current.toLowerCase(); } } else { cell = (current + " " + cell).toLowerCase(); } //System.err.println("range=" + cell + "."); String next = (String) cellsAnnoNext.getFeatures().get("string"); String domain = next.concat(" " + cell).toLowerCase(); //System.err.println("domain=" + domain + "."); //System.err.println(domain + "_is-a_" + cell + "."); if (!domain.equals(cell)) { try { outputAS.add( bio.firstNode().getOffset(), bio.lastNode().getOffset(), "SubclassOfRelation", Factory.newFeatureMap() ); gate.AnnotationSet rels = inputAS.get( bio.firstNode().getOffset() ).get( "SubclassOfRelation" ); ((gate.Annotation)rels.iterator().next()).getFeatures().put( "rule", "Bio_SubclassOfRelation1" ); outputAS.add( bio.firstNode().getOffset(), bio.lastNode().getOffset(), "Domain", Factory.newFeatureMap() ); gate.AnnotationSet domains = inputAS.get( bio.firstNode().getOffset() ).get( "Domain" ); ((gate.Annotation)domains.iterator().next()).getFeatures().put( "rule", "Bio_SubclassOfRelation1" ); ((gate.Annotation)domains.iterator().next()).getFeatures().put( "string", domain ); outputAS.add( bio.firstNode().getOffset(), bio.lastNode().getOffset(), "Range", Factory.newFeatureMap() ); gate.AnnotationSet ranges = inputAS.get( bio.firstNode().getOffset() ).get( "Range" ); ((gate.Annotation)ranges.iterator().next()).getFeatures().put( "rule", "Bio_SubclassOfRelation1" ); ((gate.Annotation)ranges.iterator().next()).getFeatures().put( "string", cell ); } catch( InvalidOffsetException e ){ e.printStackTrace(); } } } } rule: Bio_SubclassOfRelation2 Priority: 10 ( ({Token.category == NN} | {Token.category == NNS} | {Token.category == NNPS} | {Token.category == NNP}) ):noun --> { gate.AnnotationSet nouns = (gate.AnnotationSet)bindings.get( "noun" ); gate.AnnotationSet tokens = inputAS.get( nouns.firstNode().getOffset() ).get( "Token" ); List tokensList = new ArrayList( tokens ); Collections.sort( tokensList, new gate.util.OffsetComparator() ); Iterator tokensIter = tokensList.iterator(); gate.Annotation token = (gate.Annotation)tokensIter.next(); String sToken = (String)token.getFeatures().get( "string" ); if( sToken.endsWith( "cyte" ) || sToken.endsWith( "cytes" ) || sToken.endsWith( "blast" ) || sToken.endsWith ( "blasts" ) || sToken.endsWith("phage") || sToken.endsWith ( "phages" ) || sToken.endsWith( "clast" ) || sToken.endsWith( "clasts" ) || sToken.endsWith( "glium" ) || sToken.endsWith ( "glia" ) || sToken.endsWith( "gonia" ) || sToken.endsWith ( "gonium" ) || sToken.endsWith ( "phil" ) ) { try { outputAS.add( nouns.firstNode().getOffset(), nouns.lastNode().getOffset(), "SubclassOfRelation", Factory.newFeatureMap() ); gate.AnnotationSet rels = inputAS.get( nouns.firstNode().getOffset() ).get( "SubclassOfRelation" ); ((gate.Annotation)rels.iterator().next()).getFeatures().put( "rule", "Bio_SubclassOfRelation2" ); outputAS.add( nouns.firstNode().getOffset(), nouns.lastNode().getOffset(), "Domain", Factory.newFeatureMap() ); gate.AnnotationSet domains = inputAS.get( nouns.firstNode().getOffset() ).get( "Domain" ); ((gate.Annotation)domains.iterator().next()).getFeatures().put( "rule", "Bio_SubclassOfRelation2" ); outputAS.add( nouns.firstNode().getOffset(), nouns.lastNode().getOffset(), "Range", Factory.newFeatureMap() ); gate.AnnotationSet ranges = inputAS.get( nouns.firstNode().getOffset() ).get( "Range" ); ((gate.Annotation)ranges.iterator().next()).getFeatures().put( "rule", "Bio_SubclassOfRelation2" ); String range = "terminally differentiated cell"; if (sToken.endsWith( "blast" )) { range = "blast " + "cell"; ((gate.Annotation)ranges.iterator().next()).getFeatures().put( "string", range ); } else if (sToken.endsWith("glium") || sToken.endsWith("glia") ) { range = "glial " + "cell"; } ((gate.Annotation)ranges.iterator().next()).getFeatures().put( "string", range ); } catch( InvalidOffsetException e ){ e.printStackTrace(); } } }