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
 
 @SuppressWarnings("deprecation")
 @XmlType(propOrder = {
     "textLayer",
     "tokensLayer",
     "sentencesLayer",
     "lemmasLayer",
     "posTagsLayer",
     "constituentParsingLayer",
     "dependencyParsingLayer",
     "morphologyLayer",
     "namedEntitiesLayer",
     "referencesLayer",
     "relationsLayer",
     "matchesLayer",
     "wordSplittingLayer",
     "phoneticsLayer",
     "synonymyLayer",
     "antonymyLayer",
     "hyponymyLayer",
     "hyperonymyLayer",
     "geoLayer",
     "textStructureLayer",
     "orthographyLayer",
     "discourseConnectivesLayer",
     "wordSensesLayer",
     "textSourceLayer"})
 public class TextCorpusStored implements TextCorpus {
 
     public static final String XML_NAME = "TextCorpus";
     public static final String XML_NAMESPACE = "http://www.dspin.de/data/textcorpus";
     @XmlAttribute
     protected String lang;
 
     TextCorpusStored() {
          = new TextCorpusLayersConnector();
          = new TextCorpusLayerStoredAbstract[TextCorpusLayerTag.orderedLayerTags().size()];
     }
 
     public TextCorpusStored(String language) {
         this();
         this. = language;
     }
 
     @Override
     public String getLanguage() {
         return ;
     }
 
     @Override
     public List<TextCorpusLayergetLayers() {
         List<TextCorpusLayerallLayers = new ArrayList<TextCorpusLayer>(this..length);
         for (TextCorpusLayer layer : this.) {
             if (layer != null) {
                 allLayers.add(layer);
             }
         }
         return allLayers;
    }
    @Override
    public TextLayer createTextLayer() {
        TextLayer layer = initializeLayer(TextLayerStored.class);
        return layer;
    }
    @Override
    public TokensLayer createTokensLayer() {
        return initializeLayer(TokensLayerStored.class);
    }
    @Override
    public TokensLayer createTokensLayer(boolean hasCharOffsets) {
        return initializeLayer(TokensLayerStored.class, Boolean.valueOf(hasCharOffsets));
    }
    @Override
    public LemmasLayer createLemmasLayer() {
        return initializeLayer(LemmasLayerStored.class);
    }
    @Override
    public PosTagsLayer createPosTagsLayer(String tagset) {
        return initializeLayer(PosTagsLayerStored.classtagset);
    }
    @Override
        return initializeLayer(SentencesLayerStored.class);
    }
    @Override
    public SentencesLayer createSentencesLayer(boolean hasCharOffsets) {
        return initializeLayer(SentencesLayerStored.class, Boolean.valueOf(hasCharOffsets));
    }
    @Override
        return initializeLayer(ConstituentParsingLayerStored.classtagset);
    }
    @Override
            boolean multipleGovernorsPossibleboolean emptyTokensPossible) {
        return initializeLayer(DependencyParsingLayerStored.classtagset,
                Boolean.valueOf(multipleGovernorsPossible), Boolean.valueOf(emptyTokensPossible));
    }
    @Override
            boolean multipleGovernorsPossibleboolean emptyTokensPossible) {
        return initializeLayer(DependencyParsingLayerStored.class,
                Boolean.valueOf(multipleGovernorsPossible), Boolean.valueOf(emptyTokensPossible));
    }
    @Override
        return initializeLayer(MorphologyLayerStored.class);
    }
    @Override
    public MorphologyLayer createMorphologyLayer(boolean hasSegmentation) {
        return initializeLayer(MorphologyLayerStored.class, Boolean.valueOf(hasSegmentation));
    }
    @Override
    public MorphologyLayer createMorphologyLayer(boolean hasSegmentationboolean hasCharOffsets) {
        return initializeLayer(MorphologyLayerStored.class, Boolean.valueOf(hasSegmentation), Boolean.valueOf(hasCharOffsets));
    }
    @Override
    public NamedEntitiesLayer createNamedEntitiesLayer(String entitiesType) {
        return initializeLayer(NamedEntitiesLayerStored.classentitiesType);
    }
    @Override
    public ReferencesLayer createReferencesLayer(String typetagsetString reltagsetString externalReferencesSource) {
        layer.typetagset = typetagset;
        layer.reltagset = reltagset;
        layer.externalReferenceSource = externalReferencesSource;
        return layer;
    }
    @Override
    public RelationsLayer createRelationsLayer(String type) {
        return initializeLayer(RelationsLayerStored.classtype);
    }
    @Override
    public MatchesLayer createMatchesLayer(String queryLanguageString queryString) {
        return initializeLayer(MatchesLayerStored.classqueryLanguagequeryString);
    }
    @Override
        return initializeLayer(WordSplittingLayerStored.classtype);
    }
    @Override
    public PhoneticsLayer createPhotenicsLayer(String alphabet) {
        return initializeLayer(PhoneticsLayerStored.classalphabet);
    }
    @Override
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat);
    }
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat,
            GeoContinentFormat continentFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat,
                continentFormat);
    }
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat,
            GeoContinentFormat continentFormatGeoCountryFormat countryFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat,
                continentFormatcountryFormat);
    }
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat,
            GeoContinentFormat continentFormatGeoCapitalFormat capitalFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat,
                continentFormatcapitalFormat);
    }
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat,
            GeoCountryFormat countryFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat,
                countryFormat);
    }
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat,
            GeoCountryFormat countryFormatGeoCapitalFormat capitalFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat,
                countryFormatcapitalFormat);
    }
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat,
            GeoCapitalFormat capitalFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat,
                capitalFormat);
    }
    @Override
    public GeoLayer createGeoLayer(String sourceGeoLongLatFormat coordFormat,
            GeoContinentFormat continentFormatGeoCountryFormat countryFormatGeoCapitalFormat capitalFormat) {
        return initializeLayer(GeoLayerStored.classsourcecoordFormat,
                continentFormatcountryFormatcapitalFormat);
    }
    @Override
        return initializeLayer(SynonymyLayerStored.class);
    }
    @Override
        return initializeLayer(AntonymyLayerStored.class);
    }
    @Override
        return initializeLayer(HyponymyLayerStored.class);
    }
    @Override
        return initializeLayer(HyperonymyLayerStored.class);
    }
    @Override
        return initializeLayer(OrthographyLayerStored.class);
    }
    @Override
        return initializeLayer(TextStructureLayerStored.class);
    }
    @Override
        return initializeLayer(DiscourseConnectivesLayerStored.class);
    }
    @Override
        return initializeLayer(DiscourseConnectivesLayerStored.classtypesTagset);
    }
    
    @Override
    public WordSensesLayer createWordSensesLayer(String source) {
        return initializeLayer(WordSensesLayerStored.classsource);
    }
    @Override
        return initializeLayer(TextSourceLayerStored.class);
    }
    @SuppressWarnings("unchecked")
    private <T extends TextCorpusLayerStoredAbstract> T initializeLayer(Class<T> layerClassObject... params) {
        Class<?>[] paramsClass = null;
        if (params != null) {
            paramsClass = new Class<?>[params.length];
            for (int i = 0; i < params.lengthi++) {
                paramsClass[i] = params[i].getClass();
            }
        }
        TextCorpusLayerTag layerTag = TextCorpusLayerTag.getFromClass(layerClass);
        try {
            Constructor<?> ct;
            T instance;
            if (params == null) {
                ct = layerClass.getDeclaredConstructor();
                instance = (T) ct.newInstance();
            } else {
                ct = layerClass.getDeclaredConstructor(paramsClass);
                instance = (T) ct.newInstance(params);
            }
            [layerTag.ordinal()] = instance;
            instance.setLayersConnector();
        } catch (Exception e) {
            //e.printStackTrace();
            Logger.getLogger(TextCorpusStored.class.getName()).log(.nulle);
        }
        return (T) [layerTag.ordinal()];
    }
    protected void setTextLayer(TextLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    public TextLayerStored getTextLayer() {
    }
    protected void setTokensLayer(TokensLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    public TokensLayerStored getTokensLayer() {
    }
    protected void setSentencesLayer(SentencesLayerStored layer) {
    }
    @Override
    }
    protected void setLemmasLayer(LemmasLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    public LemmasLayerStored getLemmasLayer() {
    }
    protected void setPosTagsLayer(PosTagsLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    }
    }
    @Override
    }
    }
    @Override
    }
    protected void setMorphologyLayer(MorphologyLayerStored layer) {
    }
    @Override
    }
    protected void setNamedEntitiesLayer(NamedEntitiesLayerStored layer) {
    }
    @Override
    }
    protected void setReferencesLayer(ReferencesLayerStored layer) {
    }
    @Override
    }
    protected void setRelationsLayer(RelationsLayerStored layer) {
    }
    @Override
    }
    protected void setMatchesLayer(MatchesLayerStored layer) {
    }
    @Override
    }
    protected void setWordSplittingLayer(WordSplittingLayerStored layer) {
    }
    @Override
    }
    protected void setPhoneticsLayer(PhoneticsLayerStored layer) {
    }
    @Override
    }
    protected void setGeoLayer(GeoLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    public GeoLayerStored getGeoLayer() {
    }
    protected void setSynonymyLayer(SynonymyLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    }
    protected void setAntonymyLayer(AntonymyLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    }
    protected void setHyponymyLayer(HyponymyLayerStored layer) {
        [..ordinal()] = layer;
    }
    @Override
    }
    protected void setHyperonymyLayer(HyperonymyLayerStored layer) {
    }
    @Override
    }
    protected void setTextStructureLayer(TextStructureLayerStored layer) {
    }
    @Override
    }
    protected void setOrthographyLayer(OrthographyLayerStored layer) {
    }
    @Override
    }
    }
    protected void setTextSourceLayer(TextSourceLayerStored layer) {
    }
    @Override
    }
    
    protected void setWordSensesLayer(WordSensesLayerStored layer) {
    }
    @Override
    }
    @Override
    }
    protected void afterUnmarshal(Unmarshaller uObject parent) {
        connectLayers();
    }
    protected void connectLayers() {
        for (int i = 0; i < this..lengthi++) {
            if ([i] != null) {
                [i].setLayersConnector();
            }
        }
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(":\n");
        for (TextCorpusLayer layer : this.) {
            if (layer != null) {
                sb.append(layer);
                sb.append("\n");
            }
        }
        return sb.toString().trim();
    }

    
Composes the layers into one document. Normally, you should not use this method, unless you want to manually compose document from the layer pieces.The method composes correctly only in case referencing between layers (IDs <- IDREFs) is correct

Parameters:
lang
layers
Returns:
text corpus data composed of the provided layers
    public static TextCorpusStored compose(String langTextCorpusLayerStoredAbstract... layers) {
        TextCorpusStored tc = new TextCorpusStored(lang);
        for (TextCorpusLayerStoredAbstract layer : layers) {
            tc.layersInOrder[TextCorpusLayerTag.getFromClass(layer.getClass()).ordinal()] = layer;
        }
        tc.connectLayers();
        return tc;
    }
New to GrepCode? Check out our FAQ X