001    /***************************************************************************/
002    /*  Copyright (C) 2010-2011, Sebastian Hellmann                            */
003    /*  Note: If you need parts of NLP2RDF in another licence due to licence   */
004    /*  incompatibility, please mail hellmann@informatik.uni-leipzig.de        */
005    /*                                                                         */
006    /*  This file is part of NLP2RDF.                                          */
007    /*                                                                         */
008    /*  NLP2RDF is free software; you can redistribute it and/or modify        */
009    /*  it under the terms of the GNU General Public License as published by   */
010    /*  the Free Software Foundation; either version 3 of the License, or      */
011    /*  (at your option) any later version.                                    */
012    /*                                                                         */
013    /*  NLP2RDF is distributed in the hope that it will be useful,             */
014    /*  but WITHOUT ANY WARRANTY; without even the implied warranty of         */
015    /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           */
016    /*  GNU General Public License for more details.                           */
017    /*                                                                         */
018    /*  You should have received a copy of the GNU General Public License      */
019    /*  along with this program. If not, see <http://www.gnu.org/licenses/>.   */
020    /***************************************************************************/
021    
022    package org.nlp2rdf.core;
023    
024    import eu.lod2.nlp2rdf.schema.sso.Sentence;
025    import opennlp.tools.util.Span;
026    
027    import java.util.Collection;
028    import java.util.HashSet;
029    import java.util.List;
030    import java.util.Set;
031    
032    /**
033     * @author Sebastian Hellmann - http://bis.informatik.uni-leipzig.de/SebastianHellmann
034     *         <p/>
035     *         This is a data collection class (Plain Old Java Object) with no functionality.
036     *         It is used to decouple tokenization from RDF generation.
037     */
038    public class SentencePOJO {
039    
040        public static Set<Span> getSpans(Collection<? extends SentencePOJO> sentencePOJOs) {
041            Set<Span> spans = new HashSet<Span>();
042            for (SentencePOJO sp : sentencePOJOs) {
043                spans.add(sp.getSpan());
044                for (WordPOJO wp : sp.getWordPOJOs()) {
045                    spans.add(wp.getSpan());
046                }
047            }
048            return spans;
049        }
050    
051    
052        //these should be set before the conversion
053        private Span span;
054        private String text;
055        private List<WordPOJO> wordPOJOs;
056    
057        //these will be set during the conversion to owl
058        private String uri;
059        private Sentence sentence;
060    
061        public Span getSpan() {
062            return span;
063        }
064    
065        public void setSpan(Span span) {
066            this.span = span;
067        }
068    
069        public String getText() {
070            return text;
071        }
072    
073        public void setText(String text) {
074            this.text = text;
075        }
076    
077        public List<WordPOJO> getWordPOJOs() {
078            return wordPOJOs;
079        }
080    
081        public void setWordPOJOs(List<WordPOJO> wordPOJOs) {
082            this.wordPOJOs = wordPOJOs;
083        }
084    
085        public String getUri() {
086            return uri;
087        }
088    
089        public void setUri(String uri) {
090            this.uri = uri;
091        }
092    
093        public Sentence getSentence() {
094            return sentence;
095        }
096    
097        public void setSentence(Sentence sentence) {
098            this.sentence = sentence;
099        }
100    }