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 MorphologyLayerStored extends TextCorpusLayerStoredAbstract implements MorphologyLayer {
 
     public static final String XML_NAME = "morphology";
     private Boolean hasCharoffsets;
     @XmlAttribute(name = "segmentation")
     private Boolean hasSegmentation;
 
     protected void setLayersConnector(TextCorpusLayersConnector connector) {
         this. = connector;
         for (MorphologyAnalysisStored a : ) {
             for (String tokRef : a.tokRefs) {
                 connector.token2ItsAnalysis.put(connector.tokenId2ItsToken.get(tokRef), a);
             }
         }
     }
 
     protected MorphologyLayerStored() {
     }
 
     protected MorphologyLayerStored(Boolean hasSegmentation) {
         this. = hasSegmentation;
     }
 
     protected MorphologyLayerStored(Boolean hasSegmentationBoolean hasCharOffsets) {
         this(hasSegmentation);
         this. = hasCharOffsets;
     }
 
     protected MorphologyLayerStored(TextCorpusLayersConnector connector) {
         this. = connector;
     }
 
     @Override
     public boolean isEmpty() {
         return .isEmpty();
     }
 
     @Override
     public int size() {
         return .size();
     }
 
     @Override
     public boolean hasSegmentation() {
         if (this. == .) {
             return true;
         }
         return false;
     }
 
     @Override
     public boolean hasCharoffsets() {
         if (this. == .) {
             return true;
         }
         return false;
    }
    @Override
    public MorphologyAnalysis getAnalysis(int index) {
        return .get(index);
    }
    @Override
    public MorphologyAnalysis getAnalysis(Token token) {
        MorphologyAnalysis a = ..get(token);
        return a;
    }
    @Override
    public Token[] getTokens(MorphologyAnalysis analysis) {
        if (analysis instanceof MorphologyAnalysisStored) {
            MorphologyAnalysisStored a = (MorphologyAnalysisStoredanalysis;
            return WlfUtilities.tokenIdsToTokens(a.tokRefs.);
        }
        return null;
    }
    @Override
    public MorphologyAnalysis addAnalysis(Token analysedToken,
            List<FeaturemorphologyFeatures) {
        List<Tokentoks = new ArrayList<Token>();
        toks.add(analysedToken);
        return addAnalysis(toksmorphologyFeatures);
    }
    @Override
    public MorphologyAnalysis addAnalysis(Token analysedToken,
            List<FeaturemorphologyFeaturesList<MorphologySegmentsegments) {
        List<Tokentoks = new ArrayList<Token>();
        toks.add(analysedToken);
        return addAnalysis(toksmorphologyFeaturessegments);
    }
    @Override
    public MorphologyAnalysis addAnalysis(List<TokenanalysedTokens,
            List<FeaturemorphologyFeatures) {
        FeatureStructureStored fs = new FeatureStructureStored();
        for (Feature f : morphologyFeatures) {
            if (f instanceof FeatureStored) {
                fs.features.add((FeatureStoredf);
            }
        }
        if (!fs.features.isEmpty()) {
            a.tag = new MorphologyTagStored();
            a.tag.fs = fs;
        }
        a.tokRefs = new String[analysedTokens.size()];
        for (int i = 0; i < analysedTokens.size(); i++) {
            Token token = analysedTokens.get(i);
            a.tokRefs[i] = token.getID();
            ..put(tokena);
        }
        .add(a);
        return a;
    }
    @Override
    public MorphologyAnalysis addAnalysis(List<TokenanalysedTokens,
            List<FeaturemorphologyFeaturesList<MorphologySegmentsegments) {
        MorphologyAnalysisStored a = (MorphologyAnalysisStoredaddAnalysis(analysedTokensmorphologyFeatures);
        for (MorphologySegment segment : segments) {
            if (segment instanceof MorphologySegmentStored) {
                MorphologySegmentStored s = (MorphologySegmentStoredsegment;
                this. = true;
                if (s.hasCharoffsets()) {
                    this. = true;
                }
                if (a.segments == null) {
                    a.segments = new ArrayList<MorphologySegmentStored>();
                }
                a.segments.add(s);
            }
        }
        return a;
    }
    @Override
    public Feature createFeature(String nameString value) {
        FeatureStored f = new FeatureStored();
        f.name = name;
        f.value = value;
        return f;
    }
    @Override
    public Feature createFeature(String nameList<Featuresubfeatures) {
        FeatureStored f = new FeatureStored();
        f.name = name;
        f.fs = new FeatureStructureStored();
        for (Feature sf : subfeatures) {
            if (sf instanceof FeatureStored) {
                f.fs.features.add((FeatureStoredsf);
            }
        }
        return f;
    }
    @Override
    public MorphologySegment createSegment(String typeString category,
            String functionInteger startInteger endString value) {
        MorphologySegmentStored ms = new MorphologySegmentStored();
        ms.type = type;
        ms.function = function;
        ms.category = category;
        ms.start = start;
        ms.end = end;
        ms.value = value;
        return ms;
    }
    @Override
    public MorphologySegment createSegment(String typeString category,
            String functionInteger startInteger end,
            List<MorphologySegmentsubsegments) {
        MorphologySegmentStored ms = new MorphologySegmentStored();
        ms.type = type;
        ms.function = function;
        ms.category = category;
        ms.start = start;
        ms.end = end;
        ms.subsegments = new ArrayList<MorphologySegmentStored>();
        for (MorphologySegment s : subsegments) {
            if (s instanceof MorphologySegmentStored) {
                ms.subsegments.add((MorphologySegmentStoreds);
            }
        }
        return ms;
    }
    protected void beforeMarshal(Marshaller m) {
        setFalseAttrToNull();
    }
    private void setFalseAttrToNull() {
        if (this. == .) {
            this. = null;
        }
        if (this. == .) {
            this. = null;
        }
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(" {");
        if (this. != null) {
            sb.append(.).append(" ").append(this.);
        }
        if (this. != null) {
            sb.append(" segmentation ").append(this.);
        }
        sb.append("}: ");
        sb.append(.toString());
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X