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) Yana Panchenko. 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;
 import java.util.Map;

Author(s):
Yana Panchenko
 
 public class MatchesLayerStored extends TextCorpusLayerStoredAbstract implements MatchesLayer {
 
     public static final String XML_NAME = "matches";
     //public static final String XML_ATTRIBUTE_QUERY_TYPE = "type";
     //public static final String XML_ATTRIBUTE_QUERY_STRING = "query";
     //@XmlAttribute(name=XML_ATTRIBUTE_QUERY_TYPE, required=true)
     //private String queryType;
     //@XmlAttribute(name=XML_ATTRIBUTE_QUERY_STRING, required=true)
     //private String queryString;
     @XmlElement(name = "query")
     private MatchesQuery query;
 
     protected void setLayersConnector(TextCorpusLayersConnector connector) {
         this. = connector;
         for (MatchedCorpusStored corpus : ) {
             for (MatchedItemStored item : corpus.matchedItems) {
                 for (String tokRef : item.tokIds) {
                     connector.token2ItsMatchedItem.put(connector.tokenId2ItsToken.get(tokRef), item);
                 }
             }
         }
     }
 
     protected MatchesLayerStored() {
     }
 
     protected MatchesLayerStored(String queryLanguageString queryString) {
         this. = new MatchesQuery(queryLanguagequeryString);
     }
 
     protected MatchesLayerStored(TextCorpusLayersConnector connector) {
         this. = connector;
     }
 
     @Override
     public boolean isEmpty() {
         return .isEmpty();
     }
 
     @Override
     public int size() {
         return .size();
     }
 
     @Override
     public String getQueryType() {
         return .;
     }
 
     @Override
     public String getQueryString() {
        return .;
    }
    @Override
    public MatchedCorpus getCorpus(int index) {
        return .get(index);
    }
    @Override
    public MatchedItem getMatchedItem(Token token) {
        MatchedItem item = ..get(token);
        return item;
    }
    @Override
    public MatchedCorpus addCorpus(String corpusNameString corpusPID) {
        MatchedCorpusStored corpus = new MatchedCorpusStored(corpusNamecorpusPID);
        this..add(corpus);
        return corpus;
    }
    @Override
    public MatchedItem addItem(MatchedCorpus corpusToAddItem,
            List<TokenitemTokensList<StringitemOriginCorpusTokenIds) {
        return addItem(corpusToAddItemitemTokensitemOriginCorpusTokenIds,
                new HashMap<StringString>(0), new HashMap<StringString>(0));
    }
    @Override
    public MatchedItem addItem(MatchedCorpus corpusToAddItem,
            List<TokenitemTokens) {
        return addItem(corpusToAddItemitemTokensnew ArrayList<String>(0),
                new HashMap<StringString>(0), new HashMap<StringString>(0));
    }
    @Override
    public MatchedItem addItem(MatchedCorpus corpusToAddItem,
            List<TokenitemTokens,
            Map<StringStringitemTargetsMap<StringStringitemCategories) {
        return addItem(corpusToAddItemitemTokensnew ArrayList<String>(0),
                itemTargetsitemCategories);
    }
    @Override
    public MatchedItem addItem(MatchedCorpus corpusToAddItem,
            List<TokenitemTokensList<StringitemOriginCorpusTokenIds,
            Map<StringStringitemTargetsMap<StringStringitemCategories) {
        if (!(corpusToAddItem instanceof MatchedCorpusStored)) {
            //TODO log warning? how to let user know?
            return null;
        }
        String[] srcIds = new String[itemOriginCorpusTokenIds.size()];
        String[] tokIds = WlfUtilities.tokens2TokenIds(itemTokens);
        srcIds = itemOriginCorpusTokenIds.toArray(srcIds);
        MatchedItemStored item = new MatchedItemStored(
                tokIdssrcIdsitemTargetsitemCategories);
        ((MatchedCorpusStoredcorpusToAddItem)..add(item);
        for (int i = 0; i < itemTokens.size(); i++) {
            Token token = itemTokens.get(i);
            ..put(tokenitem);
        }
        return item;
    }
    @Override
    public Token[] getTokens(MatchedItem item) {
        if (item instanceof MatchedItemStored) {
            MatchedItemStored iStored = (MatchedItemStoreditem;
            Token[] tokens = new Token[iStored.tokIds.length];
            for (int i = 0; i < iStored.tokIds.lengthi++) {
                tokens[i] = ..get(iStored.tokIds[i]);
            }
            return tokens;
        } else {
            return null;
        }
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(" {");
        sb.append(.).append(" ").append(.);
        sb.append("}: ");
        sb.append(.toString());
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X