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 static final String XML_NAME = "parsing";
     private String tagset;
 
     protected void setLayersConnector(TextCorpusLayersConnector connector) {
         this. = connector;
         for (ConstituentParseStored parse : ) {
             Constituent constituent = parse.getRoot();
             connect(constituent);
         }
     }
 
     private void connect(Constituent constituent) {
         if (constituent instanceof ConstituentStored) {
             ConstituentStored constitStored = (ConstituentStoredconstituent;
             if (constitStored.constituentId == null) {
                 constitStored.constituentId = . + this...size();
             }
             this...put(constitStored.constituentIdconstitStored);
         }
         if (!constituent.isTerminal()) {
             for (Constituent child : constituent.getChildren()) {
                 connect(child);
             }
         }
     }
 
     protected ConstituentParsingLayerStored() {
     }
 
     protected ConstituentParsingLayerStored(String tagset) {
         this. = tagset;
     }
 
         this. = connector;
     }
 
     @Override
     public boolean isEmpty() {
         return .isEmpty();
     }
 
     @Override
     public int size() {
         return .size();
     }
 
     @Override
     public String getTagset() {
         return ;
     }
 
     @Override
     public ConstituentParse getParse(int index) {
         ConstituentParseStored parse = .get(index);
         return parse;
     }
    @Override
    public Constituent getParseRoot(int index) {
        ConstituentStored root = .get(index).;
        return root;
    }
    @Override
    public Token[] getTokens(ConstituentParse parse) {
        if (parse instanceof ConstituentParseStored) {
            ConstituentParseStored pStored = (ConstituentParseStoredparse;
            return getTokens(pStored.constituentParseRoot);
        } else {
            return null;
        }
    }
    @Override
    public Token[] getTokens(Constituent constituent) {
        if (constituent instanceof ConstituentStored) {
            ConstituentStored cStored = (ConstituentStoredconstituent;
            //if (cStored.isTerminal()) {
            //	return WlfUtilities.tokenIdsToTokens(cStored.tokRefs, connector.tokenId2ItsToken);
            //}
            List<TokenterminalsTokens = new ArrayList<Token>();
            collectTerminalsTokens(terminalsTokenscStored);
            Token[] tokens = new Token[terminalsTokens.size()];
            return terminalsTokens.toArray(tokens);
        } else {
            return null;
        }
    }
    @Override
        if (cref instanceof ConstituentReferenceStored) {
            return this...get(
                    ((ConstituentReferenceStoredcref).);
        } else {
            return null;
        }
    }
    private void collectTerminalsTokens(List<TokenterminalsTokens,
            ConstituentStored c) {
        if (c.isTerminal()) {
            if (!c.isEmptyTerminal()) {
                for (int i = 0; i < c.tokRefs.lengthi++) {
                    terminalsTokens.add(..get(c.tokRefs[i]));
                }
            }
        } else {
            for (ConstituentStored child : c.children) {
                collectTerminalsTokens(terminalsTokenschild);
            }
        }
    }
    @Override
    public Constituent createConstituent(String categoryList<Constituentchildren) {
        return createConstituent(categorynullchildrennull);
    }
    @Override
    public Constituent createConstituent(String categoryString edgeList<Constituentchildren) {
        return createConstituent(categoryedgechildrennull);
    }
    @Override
    public Constituent createConstituent(String categoryList<ConstituentchildrenString id) {
        return createConstituent(categorynullchildrenid);
    }
    @Override
    public Constituent createConstituent(String category) {
        return createConstituent(categorynullnew ArrayList<Constituent>(), null);
    }
    @Override
    public Constituent createConstituent(String categoryString edge) {
        return createConstituent(categoryedgenew ArrayList<Constituent>(), null);
    }
    @Override
    public Constituent createConstituent(String categoryString edgeString id) {
        return createConstituent(categoryedgenew ArrayList<Constituent>(), id);
    }
    @Override
    public Constituent createConstituent(String categoryString edgeList<ConstituentchildrenString id) {
        ConstituentStored c = new ConstituentStored();
        c.category = category;
        c.edge = edge;
        if (id == null) {
            id = . + ..size();
        }
        c.constituentId = id;
        ..put(idc);
        for (Constituent child : children) {
            if (child instanceof ConstituentStored) {
                c.children.add((ConstituentStoredchild);
            } else {
                return null;
            }
        }
        return c;
    }
    @Override
    public Constituent addChild(Constituent parentConstituent child) {
        if (parent instanceof ConstituentStored
                && child instanceof ConstituentStored) {
            ((ConstituentStoredparent)..add((ConstituentStoredchild);
        } else {
            return null;
        }
        return parent;
    }
    @Override
    public Constituent addSecondaryEdgeChild(Constituent parentConstituent childString edgeLabel) {
        if (parent instanceof ConstituentStored
                && child instanceof ConstituentStored) {
            ConstituentStored parentStored = (ConstituentStoredparent;
            ConstituentStored childStored = (ConstituentStoredchild;
            ConstituentReferenceStored crefStored =
                    new ConstituentReferenceStored(childStorededgeLabel);
            parentStored.crefs.add(crefStored);
        } else {
            return null;
        }
        return parent;
    }
    @Override
    public Constituent createTerminalConstituent(String categoryList<Tokentokens) {
        return createTerminalConstituent(categorynulltokensnull);
    }
    @Override
    public Constituent createTerminalConstituent(String categoryString edgeList<Tokentokens) {
        return createTerminalConstituent(categoryedgetokensnull);
    }
    @Override
    public Constituent createTerminalConstituent(String categoryList<TokentokensString id) {
        return createTerminalConstituent(categorynulltokensid);
    }
    @Override
    public Constituent createTerminalConstituent(String categoryToken token) {
        return createTerminalConstituent(categorynull, Arrays.asList(new Token[]{token}), null);
    }
    @Override
    public Constituent createTerminalConstituent(String categoryString edgeToken token) {
        return createTerminalConstituent(categoryedge, Arrays.asList(new Token[]{token}), null);
    }
    @Override
    public Constituent createTerminalConstituent(String categoryString edgeToken tokenString id) {
        return createTerminalConstituent(categoryedge, Arrays.asList(new Token[]{token}), id);
    }
    @Override
    public Constituent createTerminalConstituent(String categoryString edgeList<TokentokensString id) {
        ConstituentStored c = new ConstituentStored();
        String[] tokRefs = WlfUtilities.tokens2TokenIds(tokens);
        c.category = category;
        c.edge = edge;
        c.tokRefs = tokRefs;
        if (id == null) {
            id = . + ..size();
        }
        c.constituentId = id;
        ..put(idc);
        return c;
    }
    @Override
    public ConstituentParse addParse(Constituent root) {
        ConstituentParseStored parse = new ConstituentParseStored();
        if (root instanceof ConstituentStored) {
            parse.constituentParseRoot = (ConstituentStoredroot;
            .add(parse);
            return parse;
        } else {
            return null;
        }
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(" {");
        sb.append(.).append(" ").append(getTagset());
        sb.append("}: ");
        sb.append(.toString());
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X