Author: rwesten
Date: Fri Nov 23 13:14:22 2012
New Revision: 1412873

URL: http://svn.apache.org/viewvc?rev=1412873&view=rev
Log:
STANBOL-733 - minor

Modified:
    
stanbol/site/trunk/content/docs/trunk/components/enhancer/nlp/analyzedtext.mdtext

Modified: 
stanbol/site/trunk/content/docs/trunk/components/enhancer/nlp/analyzedtext.mdtext
URL: 
http://svn.apache.org/viewvc/stanbol/site/trunk/content/docs/trunk/components/enhancer/nlp/analyzedtext.mdtext?rev=1412873&r1=1412872&r2=1412873&view=diff
==============================================================================
--- 
stanbol/site/trunk/content/docs/trunk/components/enhancer/nlp/analyzedtext.mdtext
 (original)
+++ 
stanbol/site/trunk/content/docs/trunk/components/enhancer/nlp/analyzedtext.mdtext
 Fri Nov 23 13:14:22 2012
@@ -130,34 +130,32 @@ The following example shows the intended
                 "stanbol.enhancer.nlp.pos", PosTag.class);
             ...
         }
-
 2. Defined _Annotation_ are used to add information to an _Annotated_ instance 
(like a Span). For adding annotations the use of _Annotation_s is required to 
ensure type safety. The following code snippet shows how to add an PosTag with 
the probability 0.95.
 
-    :::java
-    PosTag tag = new PosTag("N"); //a simple POS tag
-    Token token; //The Token we want to add the tag
-    token.addAnnotations(POS_ANNOTATION,Value.value(tag),0.95);
-
+        :::java
+        PosTag tag = new PosTag("N"); //a simple POS tag
+        Token token; //The Token we want to add the tag
+        token.addAnnotations(POS_ANNOTATION,Value.value(tag),0.95);
 3. For consuming annotations there are two options. First the possibility to 
use the _Annotation_ object and second by directly using the key. While the 2nd 
option is not as nicely to use (as it does not provide type safety) it allows 
consuming annotations without the need to have the used _Annotation_ in the 
classpath. The following examples show both options
 
-    :::java
-    Iterator<Token> tokens = sentence.getTokens();
-    while(tokens.hasNext){
-        Token token = tokens.next();
-        //use the POS_ANNOTATION to get the PosTag
-        PosTag tag = token.getAnnotation(POS_ANNOTATION);
-        if(tag != null){
-            log.info("{} has PosTag {}",token,tag.value());
-        } else {
-            log.infor("{} has no PosTag",token);
-        }
-        //(2) use the key to retrieve values
-        String key = "urn:test-dummy";
-        Value<?> value = token.getValue(key);
-        //the programmer needs to know the type!
-        if(v.probability() > 0.5){
-            log.info("{}={}",key,value.value());
+        :::java
+        Iterator<Token> tokens = sentence.getTokens();
+        while(tokens.hasNext){
+            Token token = tokens.next();
+            //use the POS_ANNOTATION to get the PosTag
+            PosTag tag = token.getAnnotation(POS_ANNOTATION);
+            if(tag != null){
+                log.info("{} has PosTag {}",token,tag.value());
+            } else {
+                log.infor("{} has no PosTag",token);
+            }
+            //(2) use the key to retrieve values
+            String key = "urn:test-dummy";
+            Value<?> value = token.getValue(key);
+            //the programmer needs to know the type!
+            if(v.probability() > 0.5){
+                log.info("{}={}",key,value.value());
+            }
         }
-    }
     
 The _Annotated_ interface supports multi valued annotations. For that it 
defines methods for adding/setting and getting multiple values. Values are 
sorted first by the probability (unknown probability last) and secondly by the 
insert order (first in first out). So calling the single value getAnnotation() 
method on a multi valued field will return the first item (highest probability 
and first added in case of multiple items with the same/no probabilities)
\ No newline at end of file


Reply via email to