You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/10/15 10:41:01 UTC

svn commit: r1532246 - in /stanbol/trunk/enhancer/generic: nlp-json/ nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/ nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/ nlp-json/src/main/java/org/apache/stanbol/enhancer/...

Author: rwesten
Date: Tue Oct 15 08:41:00 2013
New Revision: 1532246

URL: http://svn.apache.org/r1532246
Log:
STANBOL-1132: Applied the patch provided by Cristian Petroaca with minor modifications (adding Apache headers, adding some TODOs). See the 3rd comment on the issue for more details.

Added:
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/CorefTagSupport.java
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/DependencyFeaturesSupport.java
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/coref/
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/coref/CorefTag.java
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyFeatures.java
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelation.java
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationCategory.java
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationTag.java
Modified:
    stanbol/trunk/enhancer/generic/nlp-json/pom.xml
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/AnalyzedTextParser.java
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/ValueTypeParser.java
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/MorphoFeaturesSupport.java
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/NerTagSupport.java
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PhraseTagSupport.java
    stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PosTagSupport.java
    stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser
    stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer
    stanbol/trunk/enhancer/generic/nlp/pom.xml
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java

Modified: stanbol/trunk/enhancer/generic/nlp-json/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/pom.xml?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/pom.xml (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/pom.xml Tue Oct 15 08:41:00 2013
@@ -92,7 +92,7 @@
     <dependency>
       <groupId>org.apache.stanbol</groupId>
       <artifactId>org.apache.stanbol.enhancer.nlp</artifactId>
-      <version>0.10.0</version>
+      <version>0.11.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>javax.ws.rs</groupId>

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/AnalyzedTextParser.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/AnalyzedTextParser.java?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/AnalyzedTextParser.java (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/AnalyzedTextParser.java Tue Oct 15 08:41:00 2013
@@ -24,12 +24,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map.Entry;
 
-import javax.swing.JPanel;
-
-import org.apache.commons.io.IOUtils;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.felix.scr.annotations.Reference;
@@ -41,8 +37,6 @@ import org.apache.stanbol.enhancer.nlp.m
 import org.apache.stanbol.enhancer.nlp.model.Span;
 import org.apache.stanbol.enhancer.nlp.model.Span.SpanTypeEnum;
 import org.apache.stanbol.enhancer.nlp.model.annotation.Value;
-import org.apache.stanbol.enhancer.servicesapi.Blob;
-import org.codehaus.jackson.JsonFactory;
 import org.codehaus.jackson.JsonNode;
 import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.JsonParser;
@@ -302,7 +296,7 @@ public class AnalyzedTextParser {
         ValueTypeParser<?> parser = this.valueTypeParserRegistry.getParser(clazz);
         Object value;
         if(parser != null){
-            value = parser.parse(jValue);
+            value = parser.parse(jValue, span.getContext());
         } else {
             JsonNode valueNode = jValue.path("value");
             if(valueNode.isMissingNode()){

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/ValueTypeParser.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/ValueTypeParser.java?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/ValueTypeParser.java (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/ValueTypeParser.java Tue Oct 15 08:41:00 2013
@@ -16,6 +16,7 @@
 */
 package org.apache.stanbol.enhancer.nlp.json.valuetype;
 
+import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
 import org.codehaus.jackson.node.ObjectNode;
 /**
  * Interface allowing to extend how Classes used as generic type for
@@ -34,6 +35,6 @@ public interface ValueTypeParser<T> {
 
     Class<T> getType();
     
-    T parse(ObjectNode jAnnotation);
+    T parse(ObjectNode jAnnotation, AnalysedText at);
     
 }

Added: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/CorefTagSupport.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/CorefTagSupport.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/CorefTagSupport.java (added)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/CorefTagSupport.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */package org.apache.stanbol.enhancer.nlp.json.valuetype.impl;
+
+import java.util.Set;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.enhancer.nlp.coref.CorefTag;
+import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser;
+import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer;
+import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
+import org.apache.stanbol.enhancer.nlp.model.Span;
+import org.apache.stanbol.enhancer.nlp.model.Span.SpanTypeEnum;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.node.ArrayNode;
+import org.codehaus.jackson.node.ObjectNode;
+
+@Component(immediate=true,policy=ConfigurationPolicy.IGNORE)
+@Service(value={ValueTypeParser.class,ValueTypeSerializer.class})
+@Property(name=ValueTypeParser.PROPERTY_TYPE, value=CorefTagSupport.TYPE_VALUE)
+public class CorefTagSupport implements ValueTypeParser<CorefTag>, ValueTypeSerializer<CorefTag> {
+	
+	public static final String TYPE_VALUE = "org.apache.stanbol.enhancer.nlp.coref.CorefTag";
+	
+	private static final String IS_REPRESENTATIVE_TAG = "isRepresentative";
+	private static final String MENTIONS_TAG = "mentions";
+	private static final String MENTION_TYPE_TAG = "type";
+	private static final String MENTION_START_TAG = "start";
+	private static final String MENTION_END_TAG = "end";
+	
+	@Override
+	public ObjectNode serialize(ObjectMapper mapper, CorefTag coref) {
+		ObjectNode jCoref = mapper.createObjectNode();
+		
+		jCoref.put(IS_REPRESENTATIVE_TAG, coref.isRepresentative());
+		
+        Set<Span> mentions = coref.getMentions();
+        
+        if(!mentions.isEmpty()) {
+            ArrayNode jMentions = mapper.createArrayNode();
+            
+            for(Span mention : mentions) {
+                ObjectNode jMention = mapper.createObjectNode();
+                
+                jMention.put(MENTION_TYPE_TAG, mention.getType().toString());
+                jMention.put(MENTION_START_TAG, mention.getStart());
+                jMention.put(MENTION_END_TAG, mention.getEnd());
+                
+                jMentions.add(jMention);
+            }
+            
+            jCoref.put(MENTIONS_TAG, jMentions);
+        }
+        
+		return jCoref;
+	}
+
+	@Override
+	public Class<CorefTag> getType() {
+		return CorefTag.class;
+	}
+
+	@Override
+	public CorefTag parse(ObjectNode jCoref, AnalysedText at) {
+		JsonNode jIsRepresentative = jCoref.path(IS_REPRESENTATIVE_TAG);
+		
+		if (!jIsRepresentative.isBoolean()) {
+			throw new IllegalStateException("Field 'isRepresentative' must have a true/false format");
+		}
+		
+		CorefTag corefTag = new CorefTag(jIsRepresentative.asBoolean());
+		
+		JsonNode node = jCoref.path(MENTIONS_TAG);
+        
+		if(node.isArray()) {
+            ArrayNode jMentions = (ArrayNode)node;
+            
+            for(int i=0;i<jMentions.size();i++) {
+                JsonNode member = jMentions.get(i);
+                
+                if(member.isObject()) {
+                    ObjectNode jMention = (ObjectNode)member;
+                    SpanTypeEnum spanType = SpanTypeEnum.valueOf(jMention.path(MENTION_TYPE_TAG).getTextValue());
+                    int spanStart = jMention.path(MENTION_START_TAG).asInt();
+                    int spanEnd = jMention.path(MENTION_END_TAG).asInt();
+                    Span mentionedSpan = null;
+                    
+                    switch (spanType) {
+						case Chunk:
+							mentionedSpan = at.addChunk(spanStart, spanEnd);
+							break;
+						case Sentence:
+						case Text:
+						case TextSection:
+							break;
+						case Token:
+							mentionedSpan = at.addToken(spanStart, spanEnd);
+							break;
+                    
+                    }
+                    
+                    corefTag.addMention(mentionedSpan);
+                }
+            }
+		}    
+                
+		return corefTag;
+	}	
+}
\ No newline at end of file

Added: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/DependencyFeaturesSupport.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/DependencyFeaturesSupport.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/DependencyFeaturesSupport.java (added)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/DependencyFeaturesSupport.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */package org.apache.stanbol.enhancer.nlp.json.valuetype.impl;
+
+import java.util.Set;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.enhancer.nlp.dependency.DependencyFeatures;
+import org.apache.stanbol.enhancer.nlp.dependency.DependencyRelation;
+import org.apache.stanbol.enhancer.nlp.dependency.GrammaticalRelation;
+import org.apache.stanbol.enhancer.nlp.dependency.GrammaticalRelationTag;
+import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser;
+import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer;
+import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
+import org.apache.stanbol.enhancer.nlp.model.Span;
+import org.apache.stanbol.enhancer.nlp.model.Span.SpanTypeEnum;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.node.ArrayNode;
+import org.codehaus.jackson.node.ObjectNode;
+
+@Component(immediate=true,policy=ConfigurationPolicy.IGNORE)
+@Service(value={ValueTypeParser.class,ValueTypeSerializer.class})
+@Property(name=ValueTypeParser.PROPERTY_TYPE, value=DependencyFeaturesSupport.TYPE_VALUE)
+public class DependencyFeaturesSupport implements ValueTypeParser<DependencyFeatures>, ValueTypeSerializer<DependencyFeatures> {
+
+	public static final String TYPE_VALUE = "org.apache.stanbol.enhancer.nlp.dependency.DependencyFeatures";
+	
+	private static final String RELATION_TYPE_TAG = "tag";
+	private static final String RELATION_STANBOL_TYPE_TAG = "relationType";
+	private static final String RELATION_IS_DEPENDEE_TAG = "isDependent";
+	private static final String RELATION_PARTNER_TYPE_TAG = "type";
+	private static final String RELATION_PARTNER_START_TAG = "start";
+	private static final String RELATION_PARTNER_END_TAG = "end";
+	private static final String RELATIONS_TAG = "relations";
+	private static final String ROOT_TAG = "ROOT";
+	
+	@Override
+	public ObjectNode serialize(ObjectMapper mapper, DependencyFeatures value) {
+		ObjectNode jDependencyFeature = mapper.createObjectNode();
+		
+        Set<DependencyRelation> relations = value.getRelations();
+        
+        if(!relations.isEmpty()) {
+            ArrayNode jRelations = mapper.createArrayNode();
+            
+            for(DependencyRelation relation : relations) {
+                ObjectNode jRelation = mapper.createObjectNode();
+                
+                GrammaticalRelationTag gramRelTag = relation.getGrammaticalRelationTag();
+                jRelation.put(RELATION_TYPE_TAG, gramRelTag.getTag());
+                jRelation.put(RELATION_STANBOL_TYPE_TAG, gramRelTag.getGrammaticalRelation().ordinal());
+                jRelation.put(RELATION_IS_DEPENDEE_TAG, (relation.isDependent() ? "true" : "false"));
+                
+                Span partner = relation.getPartner();
+                if (partner != null) {
+	                jRelation.put(RELATION_PARTNER_TYPE_TAG, partner.getType().toString());
+	                jRelation.put(RELATION_PARTNER_START_TAG, partner.getStart());
+	                jRelation.put(RELATION_PARTNER_END_TAG, partner.getEnd());
+                } else {
+                	jRelation.put(RELATION_PARTNER_TYPE_TAG, "ROOT");
+	                jRelation.put(RELATION_PARTNER_START_TAG, 0);
+	                jRelation.put(RELATION_PARTNER_END_TAG, 0);
+                }
+                
+                jRelations.add(jRelation);
+            }
+            
+            jDependencyFeature.put(RELATIONS_TAG, jRelations);
+        }
+        
+		return jDependencyFeature;
+	}
+
+	@Override
+	public Class<DependencyFeatures> getType() {
+		return DependencyFeatures.class;
+	}
+
+	@Override
+	public DependencyFeatures parse(ObjectNode jDependencyFeature, AnalysedText at) {
+		DependencyFeatures dependencyFeature = new DependencyFeatures();
+		
+		JsonNode node = jDependencyFeature.path(RELATIONS_TAG);
+        
+		if(node.isArray()) {
+            ArrayNode jRelations = (ArrayNode)node;
+            
+            for(int i=0;i<jRelations.size();i++) {
+                JsonNode member = jRelations.get(i);
+                
+                if(member.isObject()) {
+                    ObjectNode jRelation = (ObjectNode)member;
+                    
+                    JsonNode tag = jRelation.path(RELATION_TYPE_TAG);
+                    
+                    if(!tag.isTextual()){
+                        throw new IllegalStateException("Unable to parse GrammaticalRelationTag. The value of the "
+                                +"'tag' field MUST have a textual value (json: " + jDependencyFeature + ")");
+                    }
+                    
+                    GrammaticalRelation grammaticalRelation = GrammaticalRelation.class.getEnumConstants()[jRelation.path(RELATION_STANBOL_TYPE_TAG).asInt()];
+                    GrammaticalRelationTag gramRelTag = new GrammaticalRelationTag(tag.getTextValue(), grammaticalRelation);
+                    
+                    JsonNode isDependent = jRelation.path(RELATION_IS_DEPENDEE_TAG);
+                    
+                    if (!isDependent.isBoolean()) {
+                    	throw new IllegalStateException("Field 'isDependent' must have a true/false format");
+                    }
+                    
+                    Span partnerSpan = null;
+                    String typeString = jRelation.path(RELATION_PARTNER_TYPE_TAG).getTextValue();
+                    
+                    if (!typeString.equals(ROOT_TAG)) {
+	                    SpanTypeEnum spanType = SpanTypeEnum.valueOf(jRelation.path(RELATION_PARTNER_TYPE_TAG).getTextValue());
+	                    int spanStart = jRelation.path(RELATION_PARTNER_START_TAG).asInt();
+	                    int spanEnd = jRelation.path(RELATION_PARTNER_END_TAG).asInt();
+	                    
+	                    
+	                    switch (spanType) {
+							case Chunk:
+								partnerSpan = at.addChunk(spanStart, spanEnd);
+								break;
+							case Sentence:
+							case Text:
+							case TextSection:
+								break;
+							case Token:
+								partnerSpan = at.addToken(spanStart, spanEnd);
+								break;
+	                    }
+                    }    
+                    
+                    DependencyRelation relation = new DependencyRelation(gramRelTag, isDependent.asBoolean(), partnerSpan);
+                    dependencyFeature.addRelation(relation);
+                }
+            }
+		}    
+                
+		return dependencyFeature;
+	}
+}

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/MorphoFeaturesSupport.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/MorphoFeaturesSupport.java?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/MorphoFeaturesSupport.java (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/MorphoFeaturesSupport.java Tue Oct 15 08:41:00 2013
@@ -29,6 +29,7 @@ import org.apache.stanbol.enhancer.nlp.j
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParserRegistry;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializerRegistry;
+import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
 import org.apache.stanbol.enhancer.nlp.morpho.Case;
 import org.apache.stanbol.enhancer.nlp.morpho.CaseTag;
 import org.apache.stanbol.enhancer.nlp.morpho.Definitness;
@@ -190,7 +191,7 @@ public class MorphoFeaturesSupport imple
 
 
     @Override
-    public MorphoFeatures parse(ObjectNode jMorpho) {
+    public MorphoFeatures parse(ObjectNode jMorpho, AnalysedText at) {
         JsonNode jLemma = jMorpho.path("lemma");
         if(!jLemma.isTextual()){
             throw new IllegalStateException("Field 'lemma' MUST provide a String value (parsed JSON: "
@@ -298,7 +299,7 @@ public class MorphoFeaturesSupport imple
                 JsonNode member = jPosTags.get(i);
                 if(member.isObject()){
                     ObjectNode jPosTag = (ObjectNode)member;
-                    morpho.addPos(getPosTagParser().parse(jPosTag));
+                    morpho.addPos(getPosTagParser().parse(jPosTag, at));
                 } else {
                     log.warn("Unable to parse PosTag from "+member.toString());
                 }

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/NerTagSupport.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/NerTagSupport.java?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/NerTagSupport.java (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/NerTagSupport.java Tue Oct 15 08:41:00 2013
@@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer;
+import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
 import org.apache.stanbol.enhancer.nlp.ner.NerTag;
 import org.apache.stanbol.enhancer.nlp.pos.PosTag;
 import org.codehaus.jackson.JsonNode;
@@ -41,7 +42,7 @@ public class NerTagSupport implements Va
         return NerTag.class;
     }
     @Override
-    public NerTag parse(ObjectNode jValue) {
+    public NerTag parse(ObjectNode jValue, AnalysedText at) {
         JsonNode tag = jValue.path("tag");
         if(!tag.isTextual()){
             throw new IllegalStateException("Unable to parse NerTag. The value of the "

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PhraseTagSupport.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PhraseTagSupport.java?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PhraseTagSupport.java (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PhraseTagSupport.java Tue Oct 15 08:41:00 2013
@@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer;
+import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
 import org.apache.stanbol.enhancer.nlp.phrase.PhraseTag;
 import org.apache.stanbol.enhancer.nlp.pos.LexicalCategory;
 import org.codehaus.jackson.JsonNode;
@@ -57,7 +58,7 @@ public class PhraseTagSupport implements
 
 
     @Override
-    public PhraseTag parse(ObjectNode jValue) {
+    public PhraseTag parse(ObjectNode jValue, AnalysedText at) {
         JsonNode tag = jValue.path("tag");
         if(!tag.isTextual()){
             throw new IllegalStateException("Unable to parse PhraseTag. The value of the "

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PosTagSupport.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PosTagSupport.java?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PosTagSupport.java (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PosTagSupport.java Tue Oct 15 08:41:00 2013
@@ -28,6 +28,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.stanbol.enhancer.nlp.json.JsonUtils;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser;
 import org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer;
+import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
 import org.apache.stanbol.enhancer.nlp.pos.LexicalCategory;
 import org.apache.stanbol.enhancer.nlp.pos.Pos;
 import org.apache.stanbol.enhancer.nlp.pos.PosTag;
@@ -58,7 +59,7 @@ public class PosTagSupport implements Va
         return PosTag.class;
     }
     @Override
-    public PosTag parse(ObjectNode jValue) {
+    public PosTag parse(ObjectNode jValue, AnalysedText at) {
         PosTagInfo tagInfo = new PosTagInfo();
         JsonNode tag = jValue.path("tag");
         if(!tag.isTextual()){

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeParser Tue Oct 15 08:41:00 2013
@@ -1,4 +1,5 @@
 org.apache.stanbol.enhancer.nlp.json.valuetype.impl.PosTagSupport
 org.apache.stanbol.enhancer.nlp.json.valuetype.impl.NerTagSupport
 org.apache.stanbol.enhancer.nlp.json.valuetype.impl.MorphoFeaturesSupport
-org.apache.stanbol.enhancer.nlp.json.valuetype.impl.PhraseTagSupport
\ No newline at end of file
+org.apache.stanbol.enhancer.nlp.json.valuetype.impl.PhraseTagSupport
+org.apache.stanbol.enhancer.nlp.json.valuetype.impl.DependencyFeaturesSupport
\ No newline at end of file

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/main/resources/META-INF/services/org.apache.stanbol.enhancer.nlp.json.valuetype.ValueTypeSerializer Tue Oct 15 08:41:00 2013
@@ -1,4 +1,5 @@
 org.apache.stanbol.enhancer.nlp.json.valuetype.impl.PosTagSupport
 org.apache.stanbol.enhancer.nlp.json.valuetype.impl.NerTagSupport
 org.apache.stanbol.enhancer.nlp.json.valuetype.impl.MorphoFeaturesSupport
-org.apache.stanbol.enhancer.nlp.json.valuetype.impl.PhraseTagSupport
\ No newline at end of file
+org.apache.stanbol.enhancer.nlp.json.valuetype.impl.PhraseTagSupport
+org.apache.stanbol.enhancer.nlp.json.valuetype.impl.DependencyFeaturesSupport
\ No newline at end of file

Modified: stanbol/trunk/enhancer/generic/nlp/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/pom.xml?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/pom.xml (original)
+++ stanbol/trunk/enhancer/generic/nlp/pom.xml Tue Oct 15 08:41:00 2013
@@ -68,6 +68,8 @@
               org.apache.stanbol.enhancer.nlp.phrase;version=${project.version},
               org.apache.stanbol.enhancer.nlp.morpho;version=${project.version},
               org.apache.stanbol.enhancer.nlp.sentiment;version=${project.version},
+			  org.apache.stanbol.enhancer.nlp.coref;version=${project.version},
+			  org.apache.stanbol.enhancer.nlp.dependency;version=${project.version},
               org.apache.stanbol.enhancer.nlp.utils;version=${project.version}
             </Export-Package>
             <Import-Package>
@@ -83,6 +85,8 @@
               org.apache.stanbol.enhancer.nlp.phrase,
               org.apache.stanbol.enhancer.nlp.morpho,
               org.apache.stanbol.enhancer.nlp.sentiment,
+			  org.apache.stanbol.enhancer.nlp.coref,
+			  org.apache.stanbol.enhancer.nlp.dependency,
               org.apache.stanbol.enhancer.nlp.utils,
               *
             </Import-Package>

Modified: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java?rev=1532246&r1=1532245&r2=1532246&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java (original)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java Tue Oct 15 08:41:00 2013
@@ -1,21 +1,23 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.enhancer.nlp;
 
+import org.apache.stanbol.enhancer.nlp.coref.CorefTag;
+import org.apache.stanbol.enhancer.nlp.dependency.DependencyFeatures;
 import org.apache.stanbol.enhancer.nlp.model.AnalysedText;
 import org.apache.stanbol.enhancer.nlp.model.Chunk;
 import org.apache.stanbol.enhancer.nlp.model.Token;
@@ -29,64 +31,83 @@ import org.apache.stanbol.enhancer.nlp.p
  * Defines the {@link Annotation} constants typically used by NLP components
  */
 public interface NlpAnnotations {
-    
-    /**
-     * The POS {@link Annotation} added by POS taggers to {@link Token}s of
-     * an {@link AnalysedText}.
-     */
-    Annotation<PosTag> POS_ANNOTATION = new Annotation<PosTag>(
-            "stanbol.enhancer.nlp.pos", PosTag.class);
-    /**
+
+	/**
+	 * The POS {@link Annotation} added by POS taggers to {@link Token}s of an
+	 * {@link AnalysedText}.
+	 */
+	Annotation<PosTag> POS_ANNOTATION = new Annotation<PosTag>(
+			"stanbol.enhancer.nlp.pos", PosTag.class);
+	/**
      * 
      */
-    Annotation<NerTag> NER_ANNOTATION = new Annotation<NerTag>(
-            "stanbol.enhancer.nlp.ner", NerTag.class);
-    
-    /**
-     * The Phrase {@link Annotation} added by chunker to a group of
-     * [1..*] {@link Token}s.<p>
-     * This annotation is typically found on {@link Chunk}s.
-     */
-    Annotation<PhraseTag> PHRASE_ANNOTATION = new Annotation<PhraseTag>(
-            "stanbol.enhancer.nlp.phrase", PhraseTag.class);
-    
-    /**
-     * The Sentiment {@link Annotation} added by a sentiment tagger typically
-     * to single {@link Token}s that do carry a positive or negative sentiment.
-     */
-    Annotation<Double> SENTIMENT_ANNOTATION = new Annotation<Double>(
-            "stanbol.enhancer.nlp.sentiment", Double.class);
-    /**
-     * {@link Annotation} representing the Morphological analysis of a word. 
-     * Typically used on {@link Token}s.<p>
-     * The {@link MorphoFeatures} defines at least the Lemma and [1..*] POS tags.
-     * NOTE that the POS tag information does not assign a Tag to the {@link Token},
-     * but rather specifies that if the Token is classified by a {@link #POS_ANNOTATION}
-     * to be of one of the Tags the definitions of this {@link MorphoFeatures} can
-     * be applied.
-     */
-    Annotation<MorphoFeatures> MORPHO_ANNOTATION = new Annotation<MorphoFeatures>(
-            "stanbol.enhancer.nlp.morpho",MorphoFeatures.class);
+	Annotation<NerTag> NER_ANNOTATION = new Annotation<NerTag>(
+			"stanbol.enhancer.nlp.ner", NerTag.class);
 
-    /* 
-     * Currently only used as part of MorphoFeatures
-     */
-//    Annotation<CaseTag> CASE_ANNOTATION = new Annotation<CaseTag>(
-//            "stanbol.enhancer.nlp.morpho.case",CaseTag.class);
-//
-//    Annotation<GenderTag> GENDER_ANNOTATION = new Annotation<GenderTag>(
-//            "stanbol.enhancer.nlp.morpho.gender",GenderTag.class);
-//
-//    Annotation<NumberTag> NUMBER_ANNOTATION = new Annotation<NumberTag>(
-//            "stanbol.enhancer.nlp.morpho.number",NumberTag.class);
-//    
-//    Annotation<PersonTag> PERSON_ANNOTATION = new Annotation<PersonTag>(
-//            "stanbol.enhancer.nlp.morpho.person",PersonTag.class);
-//
-//    Annotation<TenseTag> TENSE_ANNOTATION = new Annotation<TenseTag>(
-//            "stanbol.enhancer.nlp.morpho.tense",TenseTag.class);
-//
-//    Annotation<VerbMoodTag> VERB_MOOD_ANNOTATION = new Annotation<VerbMoodTag>(
-//            "stanbol.enhancer.nlp.morpho.verb-mood",VerbMoodTag.class);
+	/**
+	 * The Phrase {@link Annotation} added by chunker to a group of [1..*]
+	 * {@link Token}s.
+	 * <p>
+	 * This annotation is typically found on {@link Chunk}s.
+	 */
+	Annotation<PhraseTag> PHRASE_ANNOTATION = new Annotation<PhraseTag>(
+			"stanbol.enhancer.nlp.phrase", PhraseTag.class);
+
+	/**
+	 * The Sentiment {@link Annotation} added by a sentiment tagger typically to
+	 * single {@link Token}s that do carry a positive or negative sentiment.
+	 */
+	Annotation<Double> SENTIMENT_ANNOTATION = new Annotation<Double>(
+			"stanbol.enhancer.nlp.sentiment", Double.class);
+	/**
+	 * {@link Annotation} representing the Morphological analysis of a word.
+	 * Typically used on {@link Token}s.
+	 * <p>
+	 * The {@link MorphoFeatures} defines at least the Lemma and [1..*] POS
+	 * tags. NOTE that the POS tag information does not assign a Tag to the
+	 * {@link Token}, but rather specifies that if the Token is classified by a
+	 * {@link #POS_ANNOTATION} to be of one of the Tags the definitions of this
+	 * {@link MorphoFeatures} can be applied.
+	 */
+	Annotation<MorphoFeatures> MORPHO_ANNOTATION = new Annotation<MorphoFeatures>(
+			"stanbol.enhancer.nlp.morpho", MorphoFeatures.class);
+
+	/**
+	 * {@link Annotation} representing the grammatical relations a word has with
+	 * other words in the sentence. Typically used on {@link Token}s.
+	 * <p>
+	 */
+	Annotation<DependencyFeatures> DEPENDENCY_ANNOTATION = new Annotation<DependencyFeatures>(
+			"stanbol.enhancer.nlp.dependency", DependencyFeatures.class);
+
+	/**
+	 * {@link Annotation} representing all the words which are a
+	 * mention/reference of a given word. Typically used on {@link Token}s.
+	 * <p>
+	 */
+	Annotation<CorefTag> COREF_ANNOTATION = new Annotation<CorefTag>(
+			"stanbol.enhancer.nlp.coref", CorefTag.class);
+
+	/*
+	 * Currently only used as part of MorphoFeatures
+	 */
+	// Annotation<CaseTag> CASE_ANNOTATION = new Annotation<CaseTag>(
+	// "stanbol.enhancer.nlp.morpho.case",CaseTag.class);
+	//
+	// Annotation<GenderTag> GENDER_ANNOTATION = new Annotation<GenderTag>(
+	// "stanbol.enhancer.nlp.morpho.gender",GenderTag.class);
+	//
+	// Annotation<NumberTag> NUMBER_ANNOTATION = new Annotation<NumberTag>(
+	// "stanbol.enhancer.nlp.morpho.number",NumberTag.class);
+	//
+	// Annotation<PersonTag> PERSON_ANNOTATION = new Annotation<PersonTag>(
+	// "stanbol.enhancer.nlp.morpho.person",PersonTag.class);
+	//
+	// Annotation<TenseTag> TENSE_ANNOTATION = new Annotation<TenseTag>(
+	// "stanbol.enhancer.nlp.morpho.tense",TenseTag.class);
+	//
+	// Annotation<VerbMoodTag> VERB_MOOD_ANNOTATION = new
+	// Annotation<VerbMoodTag>(
+	// "stanbol.enhancer.nlp.morpho.verb-mood",VerbMoodTag.class);
 
 }

Added: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/coref/CorefTag.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/coref/CorefTag.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/coref/CorefTag.java (added)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/coref/CorefTag.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.enhancer.nlp.coref;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.stanbol.enhancer.nlp.model.Span;
+import org.apache.stanbol.enhancer.nlp.model.tag.Tag;
+
+/**
+ * Represents a coreference resolution tag attached to a {@link Token}. It
+ * contains information about other {@link Token}s which refer to the
+ * aforementioned {@link Token}.
+ * 
+ * @author Cristian Petroaca
+ * 
+ */
+public class CorefTag extends Tag<CorefTag> {
+
+	/**
+	 * Shows whether the {@link Token} to which this tag is attached is the
+	 * representative metion in the chain.
+	 */
+	private boolean isRepresentative;
+
+	/**
+	 * A set of {@link Token}s representing metions of the {@link Token} to
+	 * which this tag is attached.
+	 */
+	private Set<Span> mentions;
+
+	
+	public CorefTag() {
+	    //TODO: if mentions can be modified you can not use Collections.emptySet
+	    //      because this would cause exceptions in #addMention or if users
+	    //      to #getMentions().remove(...)
+	    //IMHO mentions should be made immutable by using a
+	    //Collections.unmodifiableSet(..) for the field and removing the
+	    //#addMentions(..) method.
+		this(null, false, Collections.<Span> emptySet());
+	}
+
+	public CorefTag(boolean isRepresentative) {
+		this(null, isRepresentative, Collections.<Span> emptySet());
+	}
+
+	public CorefTag(String tag, boolean isRepresentative, Set<Span> mentions) {
+		super(tag);
+
+		this.isRepresentative = isRepresentative;
+		this.mentions = mentions;
+	}
+	/**
+	 * Getter whether the {@link Token} to which this tag is attached is the
+     * representative metion in the chain.
+	 * @return the representative state
+	 */
+	public boolean isRepresentative() {
+		return this.isRepresentative;
+	}
+	/**
+	 * Getter for the set of {@link Token}s representing mentions
+	 * of the {@link Token} to which this tag is attached.
+	 * @return
+	 */
+	public Set<Span> getMentions() {
+		return this.mentions;
+	}
+
+	public void addMention(Span mention) {
+		this.mentions.add(mention);
+	}
+}

Added: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyFeatures.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyFeatures.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyFeatures.java (added)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyFeatures.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.enhancer.nlp.dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.stanbol.enhancer.nlp.model.Token;
+
+/**
+ * Represents the list of dependency(grammatical) relations that a {@link Token}
+ * has with other {@link Token}s from the same {@link Sentence}.
+ * 
+ * It is attached to a {@link Token} via {@link DEPENDENCY_ANNOTATION}.
+ * 
+ * @author Cristian Petroaca
+ * 
+ */
+public class DependencyFeatures {
+
+	/**
+	 * The set of grammatical relations
+	 */
+	private Set<DependencyRelation> relations;
+
+	public DependencyFeatures() {
+		this.relations = new HashSet<DependencyRelation>();
+	}
+
+	public DependencyFeatures(Set<DependencyRelation> relations) {
+		this.relations = relations;
+	}
+
+	public Set<DependencyRelation> getRelations() {
+		return relations;
+	}
+	//TODO: IMO annotations 
+	public void addRelation(DependencyRelation relation) {
+		this.relations.add(relation);
+	}
+
+	public int hashCode() {
+		return ((relations != null) ? relations.hashCode() : 0);
+	}
+
+	public boolean equals(Object obj) {
+		return super.equals(obj)
+				&& (obj instanceof DependencyFeatures)
+				&& (this.relations.equals(((DependencyFeatures) obj)
+						.getRelations()));
+	}
+}

Added: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java (added)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,87 @@
+package org.apache.stanbol.enhancer.nlp.dependency;
+
+import org.apache.stanbol.enhancer.nlp.model.Span;
+
+/**
+ * Represents the grammatical relation that a {@link Token} can have with
+ * another {@link Token} from the same {@link Sentence}
+ * 
+ * @author Cristian Petroaca
+ * 
+ */
+public class DependencyRelation {
+
+	/**
+	 * The actual grammatical relation tag
+	 */
+	private GrammaticalRelationTag grammaticalRelationTag;
+
+	/**
+	 * Denotes whether the {@link Token} which has this relation is dependent in
+	 * the relation
+	 */
+	private boolean isDependent;
+
+	/**
+	 * The {@link Token} with which the relation is made.
+	 */
+	private Span partner;
+
+	public DependencyRelation() {
+	}
+
+	public DependencyRelation(GrammaticalRelationTag grammaticalRelationTag) {
+		this.grammaticalRelationTag = grammaticalRelationTag;
+	}
+
+	public DependencyRelation(GrammaticalRelationTag grammaticalRelationTag,
+			boolean isDependent, Span partner) {
+		this(grammaticalRelationTag);
+
+		this.isDependent = isDependent;
+		this.partner = partner;
+	}
+
+	public GrammaticalRelationTag getGrammaticalRelationTag() {
+		return grammaticalRelationTag;
+	}
+
+	public void setGrammaticalRelationTag(
+			GrammaticalRelationTag grammaticalRelationTag) {
+		this.grammaticalRelationTag = grammaticalRelationTag;
+	}
+
+	public boolean isDependent() {
+		return isDependent;
+	}
+
+	public void setDependent(boolean isDependent) {
+		this.isDependent = isDependent;
+	}
+
+	public Span getPartner() {
+		return this.partner;
+	}
+
+	public void setPartner(Span partner) {
+		this.partner = partner;
+	}
+
+	public int hashCode() {
+		return grammaticalRelationTag.hashCode()
+				+ ((partner != null) ? partner.hashCode() : 0)
+				+ +(isDependent ? 1 : 0);
+	}
+
+	public boolean equals(Object obj) {
+		return super.equals(obj)
+				&& (obj instanceof DependencyRelation)
+				&& (this.grammaticalRelationTag
+						.equals(((DependencyRelation) obj)
+								.getGrammaticalRelationTag()))
+				&& (this.isDependent == ((DependencyRelation) obj)
+						.isDependent())
+				&& (this.partner
+						.equals(((DependencyRelation) obj).getPartner()));
+	}
+}

Added: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelation.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelation.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelation.java (added)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelation.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,530 @@
+package org.apache.stanbol.enhancer.nlp.dependency;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Enumeration over all grammatical relation categories as defined by the class
+ * hierarchy og the <a heref="http://olia.nlp2rdf.org/">Olia</a> Ontology.
+ * <p>
+ * The top-level categories are not defined by this enum, but link to the
+ * {@link GrammaticalRelationCategory} enumeration. The multi-sub-class
+ * hierarchy of the relation categories is also reflected by this enumeration
+ * and accessible via the
+ * <ul>
+ * <li> {@link #getParents()}: the direct parent classes
+ * <li> {@link #getCategory()}: the {@link GrammaticalRelationCategory
+ * GrammaticalRelationCategory}
+ * </ul>
+ * 
+ * @author Cristian Petroaca
+ * 
+ */
+public enum GrammaticalRelation {
+
+	Complement(GrammaticalRelationCategory.Argument),
+
+	/**
+	 * A dependency is labeled as dep when the system is unable to determine a
+	 * more precise dependency relation between two words. This may be because
+	 * of a weird grammatical construction, a limitation in the Stanford
+	 * Dependency conversion software, a parser error, or because of an
+	 * unresolved long distance dependency. Example : Then, as if to show that
+	 * he could, . . . Result : dep(show, if)
+	 */
+	Dependent(GrammaticalRelationCategory.DependencyLabel),
+
+	Modifier(Dependent),
+
+	Object(Complement),
+
+	/**
+	 * An abbreviation modifier of an NP is a parenthesized NP that serves to
+	 * abbreviate the NP (or to define an abbreviation). Example : The
+	 * Australian Broadcasting Corporation (ABC) Result : abbrev(Corporation,
+	 * ABC)
+	 */
+	AbbreviationModifier(Modifier),
+
+	/**
+	 * An adjectival complement of a verb is an adjectival phrase which
+	 * functions as the complement (like an object of the verb). Example : She
+	 * looks very beautiful Result : acomp(looks, beautiful)
+	 */
+	AdjectivalComplement(Complement),
+
+	/**
+	 * An adjectival modifier of an NP is any adjectival phrase that serves to
+	 * modify the meaning of the NP. Example : Sam eats red meat. Result :
+	 * amod(meat, red)
+	 */
+	AdjectivalModifier(Modifier),
+
+	/**
+	 * An adverbial clause modifier of a VP or S is a clause modifying the verb
+	 * (temporal clause, consequence, conditional clause, etc.). Example : The
+	 * accident happened as the night was falling. Result : advcl(happened,
+	 * falling)
+	 */
+	AdverbialClauseModifier(Modifier),
+
+	/**
+	 * An adverbial modifier of a word is a (non-clausal) adverb or adverbial
+	 * phrase (ADVP) that serves to modify the meaning of the word. Example :
+	 * Genetically modified food Result : advmod(modified, genetically)
+	 */
+	AdverbialModifier(Modifier),
+
+	/**
+	 * An agent is the complement of a passive verb which is introduced by the
+	 * preposition &quot;by&quot; and does the action. Example : The man has
+	 * been killed by the police. Result : agent(killed, police)
+	 */
+	Agent(GrammaticalRelationCategory.Argument),
+
+	/**
+	 * An appositional modifier of an NP is an NP immediately to the right of
+	 * the first NP that serves to define or modify that NP. It includes
+	 * parenthesized examples. Example : Sam, my brother Result : appos(Sam,
+	 * brother)
+	 */
+	AppositionalModifier(Modifier),
+
+	/**
+	 * An attributive is a WHNP complement of a copular verb such as &quot;to
+	 * be&quot;, &quot;to seem&quot;, &quot;to appear&quot;. Example : What is
+	 * that? Result : attr (is, What)
+	 */
+	Attributive(Complement),
+
+	/**
+	 * An auxiliary of a clause is a non-main verb of the clause, e.g. modal
+	 * auxiliary, &quot;be&quot; and &quot;have&quot; in a composed tense.
+	 * Example : Reagan has died Result : aux(died, has)
+	 */
+	Auxiliary(Dependent),
+
+	/**
+	 * An open clausal complement (xcomp) of a VP or an ADJP is a clausal
+	 * complement without its own subject, whose reference is determined by an
+	 * external subject. These complements are always non-finite. The name xcomp
+	 * is borrowed from Lexical-Functional Grammar. Example : He says that you
+	 * like to swim Result : xcomp(like, swim)
+	 */
+	ClausalComplementWithExternalSubject(Complement),
+
+	/**
+	 * A clausal complement of a verb or adjective is a dependent clause with an
+	 * internal subject which functions like an object of the verb, or
+	 * adjective. Clausal complements for nouns are limited to complement
+	 * clauses with a subset of nouns like &quot;fact&quot; or
+	 * &quot;report&quot;. We analyze them the same (parallel to the analysis of
+	 * this class as &quot;content clauses&quot; in Huddleston and Pullum 2002).
+	 * Such clausal complements are usually finite (though there are occasional
+	 * remnant English subjunctives). Example : He says that you like to swim
+	 * Result :ccomp(says, like)
+	 */
+	ClausalComplementWithInternalSubject(Complement),
+
+	Subject(GrammaticalRelationCategory.Argument),
+
+	/**
+	 * A clausal subject is a clausal syntactic subject of a clause, i.e., the
+	 * subject is itself a clause. The governor of this relation might not
+	 * always be a verb: when the verb is a copular verb, the root of the clause
+	 * is the complement of the copular verb. In the two following examples,
+	 * &quot;what she said&quot; is the subject. Example : What she said makes
+	 * sense Result : csubj (makes, said)
+	 */
+	ClausalSubject(Subject),
+
+	/**
+	 * A complementizer of a clausal complement (ccomp) is the word introducing
+	 * it. It will be the subordinating conjunction &quot;that&quot; or
+	 * &quot;whether&quot;. Example : He says that you like to swim Result :
+	 * complm(like, that)
+	 */
+	Complementizer(Complement),
+
+	/**
+	 * An element of compound number is a part of a number phrase or currency
+	 * amount. Example : I lost $ 3.2 billion Result : number($, billion)
+	 */
+	CompountNumberElement(Modifier),
+
+	/**
+	 * A conjunct is the relation between two elements connected by a
+	 * coordinating conjunction, such as &quot;and&quot;, &quot;or&quot;, etc.
+	 * We treat conjunctions asymmetrically: The head of the relation is the
+	 * first conjunct and other conjunctions depend on it via the conj relation.
+	 * Example : Bill is big and honest&quot; Result : conj (big, honest)
+	 */
+	Conjunct(Dependent),
+
+	/**
+	 * A controlling subject is the relation between the head of a open clausal
+	 * complement (xcomp) and the external subject of that clause. Example : Tom
+	 * likes to eat fish Result : xsubj (eat, Tom)
+	 */
+	ControllingSubject(GrammaticalRelationCategory.SemanticDependent),
+
+	/**
+	 * A coordination is the relation between an element of a conjunct and the
+	 * coordinating conjunction word of the conjunct. (Note: different
+	 * dependency grammars have different treatments of coordination. We take
+	 * one conjunct of a conjunction (normally the first) as the head of the
+	 * conjunction.) Example : Bill is big and honest Result : cc(big, and)
+	 */
+	Coordination(Dependent),
+
+	/**
+	 * A copula is the relation between the complement of a copular verb and the
+	 * copular verb. (We normally take a copula as a dependent of its
+	 * complement.) Example : Bill is big Result : cop(big, is)
+	 */
+	Copula(GrammaticalRelationCategory.Auxiliary),
+
+	/**
+	 * A determiner is the relation between the head of an NP and its
+	 * determiner. Example : The man is here Result : det(man, the)
+	 */
+	Determiner(Modifier),
+
+	/**
+	 * The direct object of a VP is the noun phrase which is the (accusative)
+	 * object of the verb. Example : She gave me a raise Result : dobj (gave,
+	 * raise)
+	 */
+	DirectObject(Object),
+
+	/**
+	 * This relation captures an existential &quot;there&quot;. The main verb of
+	 * the clause is the governor. Example : There is a ghost in the room Result
+	 * : expl(is, There)
+	 */
+	Expletive(Dependent),
+
+	/**
+	 * The indirect object of a VP is the noun phrase which is the (dative)
+	 * object of the verb. Examle : She gave me a raise Result : iobj (gave, me)
+	 */
+	IndirectObject(Object),
+
+	/**
+	 * An infinitival modifier of an NP is an infinitive that serves to modify
+	 * the meaning of the NP. Example : Points to establish are . . . Result ;
+	 * infmod(points, establish)
+	 */
+	InfinitivalModifier(Modifier),
+
+	/**
+	 * A marker of an adverbial clausal complement (advcl) is the word
+	 * introducing it. It will be a subordinating conjunction different from
+	 * &quot;that&quot; or &quot;whether&quot;: e.g. &quot;because&quot;,
+	 * &quot;when&quot;, &quot;although&quot;, etc. Example : Forces engaged in
+	 * fighting after insurgents attacked Result : mark(attacked, after)
+	 */
+	Marker(Complement),
+
+	MeasurePhraseModifier(Modifier),
+
+	/**
+	 * The multi-word expression (modifier) relation is used for certain
+	 * multi-word idioms that behave like a single function word. It is used for
+	 * a closed set of dependencies between words in common multi-word
+	 * expressions for which it seems difficult or unclear to assign any other
+	 * relationships. At present, this relation is used inside the following
+	 * expressions: rather than, as well as, instead of, such as, because of,
+	 * instead of, in addition to, all but, such as, because of, instead of, due
+	 * to. The boundaries of this class are unclear; it could grow or shrink a
+	 * little over time. Example : I like dogs as well as cats&quot; Result :
+	 * mwe(well, as)
+	 */
+	MultiWordExpression(Modifier),
+
+	/**
+	 * The negation modifier is the relation between a negation word and the
+	 * word it modifies. Example : Bill is not a scientist Result :
+	 * neg(scientist, not)
+	 */
+	NegationModifier(AdverbialModifier),
+
+	/**
+	 * A nominal subject is a noun phrase which is the syntactic subject of a
+	 * clause. The governor of this relation might not always be a verb: when
+	 * the verb is a copular verb, the root of the clause is the complement of
+	 * the copular verb, which can be an adjective or noun. Example : Clinton
+	 * defeated Dole Result : nsubj (defeated, Clinton)
+	 */
+	NominalSubject(Subject),
+
+	/**
+	 * A noun compound modifier of an NP is any noun that serves to modify the
+	 * head noun. (Note that in the current system for dependency extraction,
+	 * all nouns modify the rightmost noun of the NP -- there is no intelligent
+	 * noun compound analysis. This is likely to be fixed once the Penn Treebank
+	 * represents the branching structure of NPs.) Example : Oil price futures
+	 * Result : nn(futures, oil) Result : nn(futures, price)
+	 */
+	NounCompoundModifier(Modifier),
+
+	/**
+	 * This relation captures various places where something syntactically a
+	 * noun phrase (NP) is used as an adverbial modifier in a sentence. These
+	 * usages include: (i) a measure phrase, which is the relation between the
+	 * head of an ADJP/ADVP/PP and the head of a measure phrase modifying the
+	 * ADJP/ADVP; (ii) noun phrases giving an extent inside a VP which are not
+	 * objects; (iii) financial constructions involving an adverbial or PP-like
+	 * NP, notably the following construction $5 a share, where the second NP
+	 * means &quot;per share&quot;; (iv) floating reflexives; and (v) certain
+	 * other absolutive NP constructions. A temporal modifier (tmod) is a
+	 * subclass of npadvmod which is distinguished as a separate relation.
+	 * Example : The director is 65 years old Result : npadvmod(old, years)
+	 */
+	NounPhraseAsAdverbialModifier(Modifier),
+
+	/**
+	 * A numeric modifier of a noun is any number phrase that serves to modify
+	 * the meaning of the noun. Example : Sam eats 3 sheep Result : num(sheep,
+	 * 3)
+	 */
+	NumericModifier(Modifier),
+
+	/**
+	 * The object of a preposition is the head of a noun phrase following the
+	 * preposition, or the adverbs &quot;here&quot; and &quot;there&quot;. (The
+	 * preposition in turn may be modifying a noun, verb, etc.) Unlike the Penn
+	 * Treebank, we here define cases of VBG quasi-prepositions like
+	 * &quot;including&quot;, &quot;concerning&quot;, etc. as instances of pobj.
+	 * (The preposition can be called a FW for &quot;pace&quot;,
+	 * &quot;versus&quot;, etc. It can also be called a CC -- but we don&#39;t
+	 * currently handle that and would need to distinguish from conjoined
+	 * prepositions.) In the case of preposition stranding, the object can
+	 * precede the preposition (e.g., &quot;What does CPR stand for?&quot;).
+	 * Example : I sat on the chair Result : pobj (on, chair)
+	 */
+	ObjectOfPreposition(Object),
+
+	/**
+	 * The parataxis relation (from Greek for &quot;place side by side&quot;) is
+	 * a relation between the main verb of a clause and other sentential
+	 * elements, such as a sentential parenthetical, or a clause after a
+	 * &quot;:&quot; or a &quot;;&quot;. Example : The guy, John said, left
+	 * early in the morning Result : parataxis(left, said)
+	 */
+	Parataxis(Dependent),
+
+	/**
+	 * A participial modifier of an NP or VP or sentence is a participial verb
+	 * form that serves to modify the meaning of a noun phrase or sentence.
+	 * Example : Truffles picked during the spring are tasty Result :
+	 * partmod(truffles, picked)
+	 */
+	ParticipalModifier(Modifier),
+
+	/**
+	 * A passive auxiliary of a clause is a non-main verb of the clause which
+	 * contains the passive information. Example : Kennedy has been killed
+	 * Result : auxpass(killed, been) Result : aux(killed,has)
+	 */
+	PassiveAuxiliary(GrammaticalRelationCategory.Auxiliary),
+
+	/**
+	 * A clausal passive subject is a clausal syntactic subject of a passive
+	 * clause. In the example below, &quot;that she lied&quot; is the subject.
+	 * Example : That she lied was suspected by everyone Result :
+	 * csubjpass(suspected, lied)
+	 */
+	PassiveClausalSubject(ClausalSubject),
+
+	/**
+	 * A passive nominal subject is a noun phrase which is the syntactic subject
+	 * of a passive clause. Example : Dole was defeated by Clinton Result :
+	 * nsubjpass(defeated, Dole)
+	 */
+	PassiveNominalSubject(NominalSubject),
+
+	/**
+	 * The phrasal verb particle relation identifies a phrasal verb, and holds
+	 * between the verb and its particle. Example : They shut down the station
+	 * Result : prt(shut, down)
+	 */
+	PhrasalVerbParticle(Modifier),
+
+	/**
+	 * The possession modifier relation holds between the head of an NP and its
+	 * possessive determiner, or a genitive &#39;s complement. Example : their
+	 * offices Result : poss(offices, their)
+	 */
+	PossessionModifier(Modifier),
+
+	/**
+	 * The possessive modifier relation appears between the head of an NP and
+	 * the genitive 's. Example : Bill's clothes Result : possessive(John, 's)
+	 */
+	PossessiveModifier(Modifier),
+
+	/**
+	 * A preconjunct is the relation between the head of an NP and a word that
+	 * appears at the beginning bracketing a conjunction (and puts emphasis on
+	 * it), such as &quot;either&quot;, &quot;both&quot;, &quot;neither&quot;).
+	 * Example : Both the boys and the girls are here Result : preconj (boys,
+	 * both)
+	 */
+	Preconjunct(Modifier),
+
+	/**
+	 * A predeterminer is the relation between the head of an NP and a word that
+	 * precedes and modifies the meaning of the NP determiner. Example : All the
+	 * boys are here Result : predet(boys, all)
+	 */
+	Predeterminer(Modifier),
+
+	/**
+	 * A prepositional modifier of a verb, adjective, or noun is any
+	 * prepositional phrase that serves to modify the meaning of the verb,
+	 * adjective, noun, or even another prepositon. In the collapsed
+	 * representation, this is used only for prepositions with NP complements.
+	 * Example : I saw a cat in a hat Result : prep(cat, in)
+	 */
+	PrepositionalModifier(Modifier),
+
+	/**
+	 * In the collapsed representation, a prepositional clausal modifier of a
+	 * verb, adjective, or noun is a clause introduced by a preposition which
+	 * serves to modify the meaning of the verb, adjective, or noun. Example :
+	 * He purchased it without paying a premium Result :
+	 * prepc_without(purchased, paying)
+	 */
+	PrepositionalClausalModifier(PrepositionalModifier),
+
+	/**
+	 * This is used when the complement of a preposition is a clause or
+	 * prepositional phrase (or occasionally, an adverbial phrase). The
+	 * prepositional complement of a preposition is the head of a clause
+	 * following the preposition, or the preposition head of the following PP.
+	 * Example : We have no information on whether users are at risk Result :
+	 * pcomp(on, are)
+	 */
+	PrepositionalComplement(Complement),
+
+	/**
+	 * This is used for any piece of punctuation in a clause, if punctuation is
+	 * being retained in the typed dependencies. By default, punctuation is not
+	 * retained in the output. Example : Go home! Result : punct(Go, !)
+	 */
+	Punctuation(Dependent),
+
+	/**
+	 * A purpose clause modifier of a VP is a clause headed by &quot;(in order)
+	 * to&quot; specifying a purpose. At present the system only recognizes ones
+	 * that have &quot;in order to&quot; as otherwise the system is unable to
+	 * distinguish from the surface representations between these and open
+	 * clausal complements (xcomp). It can also recognize fronted &quot;to&quot;
+	 * purpose clauses in sentences. Example : He talked to him in order to
+	 * secure the account Result : purpcl(talked, secure)
+	 */
+	PurposeClauseModifier(Modifier),
+
+	/**
+	 * A quantifier modifier is an element modifying the head of a QP
+	 * constituent. (These are modifiers in complex numeric quantifiers, not
+	 * other types of &quot;quantification&quot;. Quantifiers like
+	 * &quot;all&quot; become det.) Example : About 200 people came to the party
+	 * Result : quantmod(200, About)
+	 */
+	QuantifierModifier(Modifier),
+
+	/**
+	 * A referent of the head of an NP is the relative word introducing the
+	 * relative clause modifying the NP. Example : I saw the book which you
+	 * bought Result : ref (book, which)
+	 */
+	Referent(Dependent),
+
+	/**
+	 * A relative of a relative clause is the head word of the WH-phrase
+	 * introducing it. This analysis is used only for relative words which are
+	 * not the subject of the relative clause. Relative words which act as the
+	 * subject of a relative clause are analyzed as a nsubj. I saw the man whose
+	 * wife you love. Result : rel (love, wife)
+	 */
+	Relative(Complement),
+
+	/**
+	 * A relative clause modifier of an NP is a relative clause modifying the
+	 * NP. The relation points from the head noun of the NP to the head of the
+	 * relative clause, normally a verb. Example : I saw the man you love Result
+	 * : rcmod(man, love)
+	 */
+	RelativeClauseModifier(Modifier),
+
+	/**
+	 * The root grammatical relation points to the root of the sentence. A fake
+	 * node &quot;ROOT&quot; is used as the governor. The ROOT node is indexed
+	 * with &quot;0&quot;, since the indexation of real words in the sentence
+	 * starts at 1. Example : I love French fries. Result : root(ROOT, love)
+	 */
+	Root(GrammaticalRelationCategory.DependencyLabel),
+
+	/**
+	 * A temporal modifier (of a VP, NP, or an ADJP is a bare noun phrase
+	 * constituent that serves to modify the meaning of the constituent by
+	 * specifying a time. (Other temporal modifiers are prepositional phrases
+	 * and are introduced as prep.) Example : Last night, I swam in the pool
+	 * Result : tmod(swam, night)
+	 */
+	TemporalModifier(NounPhraseAsAdverbialModifier);
+
+	/**
+	 * The top level category which this grammatical relation belongs to.
+	 */
+	private GrammaticalRelationCategory category;
+
+	/**
+	 * The parents of this grammatical relation.
+	 */
+	private Set<GrammaticalRelation> parents;
+
+	GrammaticalRelation(GrammaticalRelationCategory category) {
+		this(category, null);
+	}
+
+	GrammaticalRelation(GrammaticalRelation parent) {
+		this(null, parent);
+	}
+
+	GrammaticalRelation(GrammaticalRelationCategory category,
+			GrammaticalRelation parent) {
+		if (parent != null) {
+			this.parents = new HashSet<GrammaticalRelation>();
+			addParents(parent);
+		}
+
+		if (category != null) {
+			this.category = category;
+		}
+	}
+
+	public GrammaticalRelationCategory getCategory() {
+		return this.category;
+	}
+
+	public Collection<GrammaticalRelation> getParents() {
+		return this.parents;
+	}
+
+	private void addParents(GrammaticalRelation parent) {
+		this.parents.add(parent);
+
+		Collection<GrammaticalRelation> grandParents = parent.getParents();
+		if (grandParents == null) {
+			this.category = parent.getCategory();
+		} else {
+			for (GrammaticalRelation grandParent : grandParents) {
+				addParents(grandParent);
+			}
+		}
+	}
+}

Added: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationCategory.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationCategory.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationCategory.java (added)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationCategory.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,17 @@
+package org.apache.stanbol.enhancer.nlp.dependency;
+
+/**
+ * The top level category that a grammatical relation belongs to.
+ * 
+ * @author Cristian Petroaca
+ * 
+ */
+public enum GrammaticalRelationCategory {
+	Argument,
+
+	Auxiliary,
+
+	DependencyLabel,
+
+	SemanticDependent;
+}

Added: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationTag.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationTag.java?rev=1532246&view=auto
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationTag.java (added)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/GrammaticalRelationTag.java Tue Oct 15 08:41:00 2013
@@ -0,0 +1,36 @@
+package org.apache.stanbol.enhancer.nlp.dependency;
+
+import org.apache.stanbol.enhancer.nlp.model.tag.Tag;
+
+/**
+ * Represents a grammatical relation tag between two {@link Token}s
+ * 
+ * @author Cristian Petroaca
+ * 
+ */
+public class GrammaticalRelationTag extends Tag<GrammaticalRelationTag> {
+
+	/**
+	 * The actual grammatical relation object
+	 */
+	private GrammaticalRelation grammaticalRelation;
+
+	public GrammaticalRelationTag(String tag) {
+		super(tag);
+	}
+
+	public GrammaticalRelationTag(String tag,
+			GrammaticalRelation grammaticalRelation) {
+		this(tag);
+
+		this.setGrammaticalRelation(grammaticalRelation);
+	}
+
+	public GrammaticalRelation getGrammaticalRelation() {
+		return grammaticalRelation;
+	}
+
+	public void setGrammaticalRelation(GrammaticalRelation grammaticalRelation) {
+		this.grammaticalRelation = grammaticalRelation;
+	}
+}