Author: rwesten
Date: Thu Sep 20 07:22:42 2012
New Revision: 1387892

URL: http://svn.apache.org/viewvc?rev=1387892&view=rev
Log:
STANBOL-734: renamed static members in NlpAnnotations to use UPPER_CASE syntax

Modified:
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/nlp2rdf/src/main/java/org/apache/stanbol/enhancer/engines/nlp2rdf/engine/Nlp2RdfMetadataEngine.java
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-chunker/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/chunker/services/ChunkingEngine.java
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-pos/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/pos/services/POSTaggingEngine.java
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/sentiment-wordclassifier/src/main/java/org/apache/stanbol/enhancer/engines/sentiment/services/SentimentEngine.java
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/pos/PosTag.java
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NIFHelper.java
    
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NlpEngineHelper.java

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/nlp2rdf/src/main/java/org/apache/stanbol/enhancer/engines/nlp2rdf/engine/Nlp2RdfMetadataEngine.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/nlp2rdf/src/main/java/org/apache/stanbol/enhancer/engines/nlp2rdf/engine/Nlp2RdfMetadataEngine.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/nlp2rdf/src/main/java/org/apache/stanbol/enhancer/engines/nlp2rdf/engine/Nlp2RdfMetadataEngine.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/nlp2rdf/src/main/java/org/apache/stanbol/enhancer/engines/nlp2rdf/engine/Nlp2RdfMetadataEngine.java
 Thu Sep 20 07:22:42 2012
@@ -162,7 +162,7 @@ public class Nlp2RdfMetadataEngine exten
                 writePhrase(metadata, span, current);
                 //OlIA does not include Sentiments
                 
-                Value<SentimentTag> sentiment = 
span.getAnnotation(NlpAnnotations.sentimentAnnotation);
+                Value<SentimentTag> sentiment = 
span.getAnnotation(NlpAnnotations.SENTIMENT_ANNOTATION);
                 if(sentiment != null){
                     double sentimentVal = sentiment.probability();
                     if(sentiment.value().isNegative()) {

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-chunker/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/chunker/services/ChunkingEngine.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-chunker/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/chunker/services/ChunkingEngine.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-chunker/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/chunker/services/ChunkingEngine.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-chunker/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/chunker/services/ChunkingEngine.java
 Thu Sep 20 07:22:42 2012
@@ -16,8 +16,8 @@
 
 package org.apache.stanbol.enhancer.engines.opennlp.chunker.services;
 
-import static org.apache.stanbol.enhancer.nlp.NlpAnnotations.POSAnnotation;
-import static org.apache.stanbol.enhancer.nlp.NlpAnnotations.phraseAnnotation;
+import static org.apache.stanbol.enhancer.nlp.NlpAnnotations.POS_ANNOTATION;
+import static org.apache.stanbol.enhancer.nlp.NlpAnnotations.PHRASE_ANNOTATION;
 import static 
org.apache.stanbol.enhancer.nlp.utils.NlpEngineHelper.getAnalysedText;
 import static 
org.apache.stanbol.enhancer.nlp.utils.NlpEngineHelper.getLanguage;
 
@@ -212,7 +212,7 @@ public class ChunkingEngine extends Abst
                     Token token = tokens.next();
                     tokenList.add(token);
                     tokenTextList.add(token.getSpan());
-                    Value<PosTag> posValue = 
token.getAnnotation(POSAnnotation);
+                    Value<PosTag> posValue = 
token.getAnnotation(POS_ANNOTATION);
                     if(posValue == null){
                         throw new EngineException("Missing POS value for Token 
'"
                             + token.getSpan()+" of ContentItem "+ci.getUri()
@@ -258,7 +258,7 @@ public class ChunkingEngine extends Abst
                         Chunk chunk = at.addChunk( 
                             tokenList.get(i-chunkTokenCount).getStart(), 
                             tokenList.get(i-1).getEnd());
-                        chunk.addAnnotation(phraseAnnotation, 
+                        chunk.addAnnotation(PHRASE_ANNOTATION, 
                             new Value<PhraseTag>(tag,
                                     chunkProps/(double)chunkTokenCount));
                         //reset the state
@@ -280,7 +280,7 @@ public class ChunkingEngine extends Abst
                     Chunk chunk = at.addChunk( 
                         tokenList.get(i-chunkTokenCount).getStart(), 
                         tokenList.get(i-1).getEnd());
-                    chunk.addAnnotation(phraseAnnotation, 
+                    chunk.addAnnotation(PHRASE_ANNOTATION, 
                         new Value<PhraseTag>(tag,
                                 chunkProps/(double)chunkTokenCount));
                     
@@ -304,7 +304,7 @@ public class ChunkingEngine extends Abst
             } else {
                 log.info(" > {}",span);
             }
-            for(Value<PhraseTag> value : 
span.getAnnotations(phraseAnnotation)){
+            for(Value<PhraseTag> value : 
span.getAnnotations(PHRASE_ANNOTATION)){
                 log.info("   - {}",value);
             }
         }

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-pos/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/pos/services/POSTaggingEngine.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-pos/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/pos/services/POSTaggingEngine.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-pos/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/pos/services/POSTaggingEngine.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/opennlp-pos/src/main/java/org/apache/stanbol/enhancer/engines/opennlp/pos/services/POSTaggingEngine.java
 Thu Sep 20 07:22:42 2012
@@ -17,7 +17,7 @@
 package org.apache.stanbol.enhancer.engines.opennlp.pos.services;
 
 import static java.util.Collections.singleton;
-import static org.apache.stanbol.enhancer.nlp.NlpAnnotations.POSAnnotation;
+import static org.apache.stanbol.enhancer.nlp.NlpAnnotations.POS_ANNOTATION;
 import static 
org.apache.stanbol.enhancer.nlp.utils.NlpEngineHelper.getLanguage;
 import static 
org.apache.stanbol.enhancer.nlp.utils.NlpEngineHelper.initAnalysedText;
 
@@ -264,7 +264,7 @@ public class POSTaggingEngine extends Ab
         while(it.hasNext()){
             Span span = it.next();
             log.info(" > {}",span);
-            for(Value<PosTag> value : span.getAnnotations(POSAnnotation)){
+            for(Value<PosTag> value : span.getAnnotations(POS_ANNOTATION)){
                 log.info("   - {}",value);
             }
         }
@@ -309,7 +309,7 @@ public class POSTaggingEngine extends Ab
                 }
             }
             //create the POS values
-            token.addAnnotations(POSAnnotation, Value.values(actPos, 
actProp,j));
+            token.addAnnotations(POS_ANNOTATION, Value.values(actPos, 
actProp,j));
         }
 
     }

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/sentiment-wordclassifier/src/main/java/org/apache/stanbol/enhancer/engines/sentiment/services/SentimentEngine.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/sentiment-wordclassifier/src/main/java/org/apache/stanbol/enhancer/engines/sentiment/services/SentimentEngine.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/sentiment-wordclassifier/src/main/java/org/apache/stanbol/enhancer/engines/sentiment/services/SentimentEngine.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/engines/sentiment-wordclassifier/src/main/java/org/apache/stanbol/enhancer/engines/sentiment/services/SentimentEngine.java
 Thu Sep 20 07:22:42 2012
@@ -16,7 +16,7 @@
 
 package org.apache.stanbol.enhancer.engines.sentiment.services;
 
-import static 
org.apache.stanbol.enhancer.nlp.NlpAnnotations.sentimentAnnotation;
+import static 
org.apache.stanbol.enhancer.nlp.NlpAnnotations.SENTIMENT_ANNOTATION;
 import static 
org.apache.stanbol.enhancer.nlp.utils.NlpEngineHelper.getAnalysedText;
 import static 
org.apache.stanbol.enhancer.nlp.utils.NlpEngineHelper.getLanguage;
 
@@ -190,13 +190,13 @@ public class SentimentEngine  extends Ab
     /**
      * The minimum {@link PosTag} value {@link Value#probability() 
confidence}.<p>
      * This means that if the {@link Value#probability() confidence} of a
-     * {@link NlpAnnotations#POSAnnotation}s (returned by
+     * {@link NlpAnnotations#POS_ANNOTATION}s (returned by
      * {@link Token#getAnnotations(Annotation)}) is greater than 
      * {@link #minPOSConfidence} that the result of 
      * {@link SentimentClassifier#isAdjective(PosTag)} (and 
      * {@link SentimentClassifier#isNoun(PosTag)}  - if #CONFIG_ADJECTIVES is 
      * deactivated) is used to decide if a Token needs to be processed or not.
-     * Otherwise further {@link NlpAnnotations#POSAnnotation}s are analysed for
+     * Otherwise further {@link NlpAnnotations#POS_ANNOTATION}s are analysed 
for
      * processable POS tags. Processable POS tags are accepted until
      * <code>{@link #minPOSConfidence}/2</code>.  
      */
@@ -267,7 +267,7 @@ public class SentimentEngine  extends Ab
             Token token = tokens.next();
             boolean process = !adjectivesOnly;
             if(!process){ //check POS types
-                Iterator<Value<PosTag>> posTags = 
token.getAnnotations(NlpAnnotations.POSAnnotation).iterator();
+                Iterator<Value<PosTag>> posTags = 
token.getAnnotations(NlpAnnotations.POS_ANNOTATION).iterator();
                 boolean ignore = false;
                 while(!ignore && !process && posTags.hasNext()) {
                     Value<PosTag> value = posTags.next();
@@ -280,7 +280,7 @@ public class SentimentEngine  extends Ab
             if(process){
                 double sentiment = classifier.classifyWord(token.getSpan());
                 if(sentiment != 0.0){
-                    token.addAnnotation(sentimentAnnotation, 
+                    token.addAnnotation(SENTIMENT_ANNOTATION, 
                         new Value<SentimentTag>(sentiment > 0 ? 
                                 SentimentTag.POSITIVE : SentimentTag.NEGATIVE,
                                 Math.abs(sentiment)));

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/NlpAnnotations.java
 Thu Sep 20 07:22:42 2012
@@ -17,7 +17,7 @@ public interface NlpAnnotations {
      * The POS {@link Annotation} added by POS taggers to {@link Token}s of
      * an {@link AnalysedText}.
      */
-    Annotation<String,PosTag> POSAnnotation = new Annotation<String,PosTag>(
+    Annotation<String,PosTag> POS_ANNOTATION = new Annotation<String,PosTag>(
             "stanbol.enhancer.nlp.pos", PosTag.class);
     
     
@@ -26,13 +26,21 @@ public interface NlpAnnotations {
      * [1..*] {@link Token}s.<p>
      * This annotation is typically found on {@link Chunk}s.
      */
-    Annotation<String,PhraseTag> phraseAnnotation = new 
Annotation<String,PhraseTag>(
+    Annotation<String,PhraseTag> PHRASE_ANNOTATION = new 
Annotation<String,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<String,SentimentTag> sentimentAnnotation = new 
Annotation<String,SentimentTag>(
+    Annotation<String,SentimentTag> SENTIMENT_ANNOTATION = new 
Annotation<String,SentimentTag>(
             "stanbol.enhancer.nlp.sentiment", SentimentTag.class);
+    /**
+     * The Lemma {@link Annotation} for a word. Typically used for
+     * {@link Token}s. The value is the {@link String} representing the
+     * Lemma of the Word
+     */
+    Annotation<String,String> LEMMA_ANNOTATION = new Annotation<String,String>(
+            "stanbol.enhancer.nlp.lemma",String.class);
+    
 }

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/pos/PosTag.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/pos/PosTag.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/pos/PosTag.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/pos/PosTag.java
 Thu Sep 20 07:22:42 2012
@@ -7,7 +7,7 @@ import org.apache.stanbol.enhancer.servi
 
 /**
  * An POS (part-of-speech) tag typically assigned by an POS-Tagger (an
- * NLP component) to a {@link Token} by using the {@link POS#POSAnnotation}<p>
+ * NLP component) to a {@link Token} by using the {@link POS#POS_ANNOTATION}<p>
  * The only required field is {@link #getTag()} - the string tag assigned by
  * the POS Tagger.<p>
  * PosTags can be mapped to a {@link LexicalCategory} and be part of an

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NIFHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NIFHelper.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NIFHelper.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NIFHelper.java
 Thu Sep 20 07:22:42 2012
@@ -215,7 +215,7 @@ public final class NIFHelper {
     }
     
     /**
-     * Writes the {@link NlpAnnotations#POSAnnotation} as NIF 1.0 to the parsed
+     * Writes the {@link NlpAnnotations#POS_ANNOTATION} as NIF 1.0 to the 
parsed
      * RDF graph by using the parsed segmentUri as subject
      * @param graph the graph
      * @param annotated the annotated element (e.g. a {@link Token})
@@ -223,7 +223,7 @@ public final class NIFHelper {
      * annotated element in the graph
      */
     public static void writePos(MGraph graph, Annotated annotated, UriRef 
segmentUri) {
-        Value<PosTag> posTag = 
annotated.getAnnotation(NlpAnnotations.POSAnnotation);
+        Value<PosTag> posTag = 
annotated.getAnnotation(NlpAnnotations.POS_ANNOTATION);
         if(posTag != null){
             if(posTag.value().getCategory() != null){
                 graph.add(new TripleImpl(segmentUri, 
SsoOntology.oliaLink.getUri(), 
@@ -237,7 +237,7 @@ public final class NIFHelper {
     }    
     
     /**
-     * Writes a {@link NlpAnnotations#phraseAnnotation} as NIF 1.0 to the
+     * Writes a {@link NlpAnnotations#PHRASE_ANNOTATION} as NIF 1.0 to the
      * parsed RDF graph by using the segmentUri as subject
      * @param graph the graph
      * @param annotated the annotated element (e.g. a {@link Chunk})
@@ -245,7 +245,7 @@ public final class NIFHelper {
      * annotated element in the graph
      */
     public static void writePhrase(MGraph graph, Annotated annotated, UriRef 
segmentUri) {
-        Value<PhraseTag> phraseTag = 
annotated.getAnnotation(NlpAnnotations.phraseAnnotation);
+        Value<PhraseTag> phraseTag = 
annotated.getAnnotation(NlpAnnotations.PHRASE_ANNOTATION);
         if(phraseTag != null){
             UriRef phraseTypeUri = 
LEXICAL_TYPE_TO_PHRASE_TYPE.get(phraseTag.value().getCategory());
             if(phraseTypeUri != null){ //add the oliaLink for the Phrase

Modified: 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NlpEngineHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NlpEngineHelper.java?rev=1387892&r1=1387891&r2=1387892&view=diff
==============================================================================
--- 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NlpEngineHelper.java
 (original)
+++ 
incubator/stanbol/branches/stanbol-nlp-processing/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/utils/NlpEngineHelper.java
 Thu Sep 20 07:22:42 2012
@@ -121,16 +121,20 @@ public final class NlpEngineHelper {
      * @throws EngineException on any exception while accessing the 
      * '<code>text/plain</code>' Blob
      * @throws IllegalStateException if no '<code>text/plain</code>' Blob is
-     * present as content part of the parsed {@link ContentItem}. NOTE that if
-     * the {@link AnalysedText} content part is already present no Exception 
will
-     * be thrown even if no plain text {@link Blob} is present in the parsed
-     * {@link ContentItem}
+     * present as content part of the parsed {@link ContentItem} or the parsed
+     * {@link AnalysedTextFactory} is <code>null</code>. <i>NOTE</i> that 
+     * {@link IllegalStateException} are only thrown if the {@link 
AnalysedText}
+     * ContentPart is not yet present in the parsed {@link ContentItem}
      */
     public static AnalysedText initAnalysedText(EnhancementEngine engine, 
                                                 AnalysedTextFactory 
analysedTextFactory,
                                                 ContentItem ci) throws 
EngineException {
         AnalysedText at = AnalysedTextUtils.getAnalysedText(ci);
         if(at == null){
+            if(analysedTextFactory == null){
+                throw new IllegalStateException("Unable to initialise 
AnalysedText"
+                    + "ContentPart because the parsed AnalysedTextFactory is 
NULL");
+            }
             Entry<UriRef,Blob> textBlob = getPlainText(engine, ci, true);
             log.debug(" ... create new AnalysedText instance for Engine {}", 
engine.getName());
             try {


Reply via email to