    001    package org.maltparser.core.helper;
    002
    003    import org.apache.log4j.Logger;
    004    import org.maltparser.core.exception.MaltChainedException;
    005    import org.maltparser.core.io.dataformat.ColumnDescription;
    006    import org.maltparser.core.options.OptionManager;
    007    import org.maltparser.core.symbol.SymbolTableHandler;
    008    /**
    009    *
    010    *
    011    * @author Johan Hall
    012    */
    013    public class Malt04 {
    014            public static void loadAllMalt04Tagset(OptionManager om, int containerIndex, SymbolTableHandler symbolTableHandler, Logger logger) throws MaltChainedException {
    015                    String malt04Posset = om.getOptionValue(containerIndex, "malt0.4", "posset").toString();
    016                    String malt04Cposset = om.getOptionValue(containerIndex, "malt0.4", "cposset").toString();
    017                    String malt04Depset = om.getOptionValue(containerIndex, "malt0.4", "depset").toString();
    018                    String nullValueStrategy = om.getOptionValue(containerIndex, "singlemalt", "null_value").toString();
    019    //              String rootLabels = om.getOptionValue(containerIndex, "graph", "root_label").toString();
    020                    String inputCharSet = om.getOptionValue(containerIndex, "input", "charset").toString();
    021                    loadMalt04Posset(malt04Posset, inputCharSet, nullValueStrategy, symbolTableHandler, logger);
    022                    loadMalt04Cposset(malt04Cposset, inputCharSet, nullValueStrategy, symbolTableHandler, logger);
    023                    loadMalt04Depset(malt04Depset, inputCharSet, nullValueStrategy, symbolTableHandler, logger);
    024            }
    025
    026            public static void loadMalt04Posset(String fileName, String charSet, String nullValueStrategy, SymbolTableHandler symbolTableHandler, Logger logger) throws MaltChainedException {
    027                    if (!fileName.toString().equalsIgnoreCase("")) {
    028                            if (logger.isInfoEnabled()) {
    029                                    logger.info("Loading part-of-speech tagset '"+fileName+"'...\n");
    030                            }
    031                            symbolTableHandler.loadTagset(fileName, "POSTAG", charSet, ColumnDescription.INPUT, nullValueStrategy);
    032                    }
    033            }
    034
    035            public static void loadMalt04Cposset(String fileName, String charSet, String nullValueStrategy, SymbolTableHandler symbolTableHandler, Logger logger) throws MaltChainedException {
    036                    if (!fileName.equalsIgnoreCase("")) {
    037                            if (logger.isInfoEnabled()) {
    038                                    logger.info("Loading coarse-grained part-of-speech tagset '"+fileName+"'...\n");
    039                            }
    040                            symbolTableHandler.loadTagset(fileName, "CPOSTAG", charSet, ColumnDescription.INPUT, nullValueStrategy);
    041                    }
    042            }
    043
    044            public static void loadMalt04Depset(String fileName, String charSet, String nullValueStrategy, SymbolTableHandler symbolTableHandler, Logger logger) throws MaltChainedException {
    045                    if (!fileName.equalsIgnoreCase("")) {
    046                            if (logger.isInfoEnabled()) {
    047                                    logger.info("Loading dependency type tagset '"+fileName+"'...\n");
    048                            }
    049                            symbolTableHandler.loadTagset(fileName, "DEPREL", charSet, ColumnDescription.DEPENDENCY_EDGE_LABEL, nullValueStrategy);
    050                    }
    051            }
    052    }