Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
wlfxb - a library for creating and processing of TCF data streams. Copyright (C) University of Tübingen. This file is part of wlfxb. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 
 package eu.clarin.weblicht.wlfxb.tc.xb;
 
 import java.util.List;

Author(s):
Yana Panchenko
 
 public class SentencesLayerStored extends TextCorpusLayerStoredAbstract implements SentencesLayer {
 
     public static final String XML_NAME = "sentences";
     @XmlElement(name = ., type = SentenceStored.class)
     protected List<SentenceStoredsentences = new ArrayList<SentenceStored>();
     protected Boolean charOffsets;
 
     protected SentencesLayerStored() {
     }
 
     protected SentencesLayerStored(Boolean hasCharOffsets) {
         this. = hasCharOffsets;
     }
 
     protected SentencesLayerStored(TextCorpusLayersConnector connector) {
         this. = connector;
     }
 
     protected void setLayersConnector(TextCorpusLayersConnector connector) {
         this. = connector;
         for (SentenceStored sentence : ) {
             for (String tokRef : sentence.tokIds) {
                 connector.token2ItsSentence.put(connector.tokenId2ItsToken.get(tokRef), sentence);
             }
         }
     }
 
     @Override
     public boolean isEmpty() {
         return .isEmpty();
     }
 
     @Override
     public int size() {
         return .size();
     }
 
     @Override
     public boolean hasCharOffsets() {
         if ( == null) {
             return false;
         }
         return ;
     }
 
     @Override
     public Sentence getSentence(int index) {
         return .get(index);
     }
 
     @Override
     public Sentence getSentence(Token token) {
         Sentence sentence = ..get(token);
         return sentence;
     }
 
    @Override
    public Token[] getTokens(Sentence sentence) {
        if (sentence instanceof SentenceStored) {
            SentenceStored sStored = (SentenceStoredsentence;
            return WlfUtilities.tokenIdsToTokens(sStored.tokIds.);
        } else {
            return null;
        }
    }
    @Override
    public Sentence addSentence(List<TokensentenceTokens) {
        return addSentence(sentenceTokensnullnull);
    }
    @Override
    public Sentence addSentence(List<TokensentenceTokensint startint end) {
        return addSentence(sentenceTokens, (Integerstart, (Integerend);
    }
    public Sentence addSentence(List<TokensentenceTokensInteger startInteger end) {
        SentenceStored sentence = new SentenceStored();
        sentence.tokIds = new String[sentenceTokens.size()];
        if (start != null && end != null) {
            sentence.start = start;
            sentence.end = end;
            this. = true;
        }
        for (int i = 0; i < sentenceTokens.size(); i++) {
            Token sentenceToken = sentenceTokens.get(i);
            sentence.tokIds[i] = sentenceToken.getID();
            ..put(sentenceTokensentence);
        }
        .add(sentence);
        return sentence;
    }
    protected void beforeMarshal(Marshaller m) {
        setFalseAttrToNull();
    }
    private void setFalseAttrToNull() {
        if (this. == .) {
            this. = null;
        }
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(" {");
        if (hasCharOffsets()) {
            sb.append(.).append(" ").append(Boolean.toString());
        }
        sb.append("}: ");
        sb.append(.toString());
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X