001 /** 002 * Sentence.java 003 * jCOLIBRI2 framework. 004 * @author Juan A. Recio-García. 005 * GAIA - Group for Artificial Intelligence Applications 006 * http://gaia.fdi.ucm.es 007 * 15/06/2007 008 */ 009 package jcolibri.extensions.textual.IE.representation; 010 011 import java.util.ArrayList; 012 import java.util.List; 013 014 /** 015 * Represents a sentence of the text. A sentence is composed by Tokens. 016 * @author Juan A. Recio-Garcia 017 * @version 1.0 018 * @see jcolibri.extensions.textual.IE.representation.Sentence 019 */ 020 public class Sentence { 021 022 protected List<Token> tokens; 023 024 protected String text; 025 026 /** 027 * Creates a sentence object that representes the text of the parameter. 028 */ 029 public Sentence(String text) 030 { 031 this.text = text; 032 tokens = new ArrayList<Token>(); 033 } 034 035 /** 036 * Returns the original text of the sentence 037 */ 038 public String getRawContent() 039 { 040 return text; 041 } 042 043 044 /** 045 * Returns the tokens 046 */ 047 public List<Token> getTokens() { 048 return tokens; 049 } 050 051 /** 052 * Adds tokens 053 */ 054 public void addTokens(List<Token> tokens){ 055 this.tokens.addAll(tokens); 056 } 057 058 /** 059 * Adds a token 060 */ 061 public void addToken(Token token){ 062 this.tokens.add(token); 063 } 064 065 /** 066 * Prints the content and annotations. 067 */ 068 public String toString() 069 { 070 StringBuffer sb = new StringBuffer(); 071 sb.append(" SENTENCE begin\n"); 072 for(Token tok : tokens) 073 sb.append(tok.toString()); 074 sb.append(" SENTENCE end\n"); 075 return sb.toString(); 076 } 077 078 079 }