Search in sources :

Example 1 with SvmHmmAdapter

use of org.dkpro.tc.ml.svmhmm.SvmHmmAdapter in project dkpro-tc by dkpro.

the class SVMHMMSaveAndLoadModelTest method getParameterSpace.

private ParameterSpace getParameterSpace() throws ResourceInitializationException {
    DemoUtils.setDkproHome(this.getClass().getName());
    String trainFolder = "src/main/resources/data/brown_tei/";
    // configure training and test data reader dimension
    // train/test will use both, while cross-validation will only use the
    // train part
    Map<String, Object> dimReaders = new HashMap<String, Object>();
    CollectionReaderDescription readerTrain = CollectionReaderFactory.createReaderDescription(BrownCorpusReader.class, BrownCorpusReader.PARAM_LANGUAGE, "en", BrownCorpusReader.PARAM_SOURCE_LOCATION, trainFolder, BrownCorpusReader.PARAM_LANGUAGE, "en", BrownCorpusReader.PARAM_PATTERNS, "*.xml");
    dimReaders.put(DIM_READER_TRAIN, readerTrain);
    Dimension<TcFeatureSet> dimFeatureSets = Dimension.create(DIM_FEATURE_SET, new TcFeatureSet(TcFeatureFactory.create(WordNGram.class, WordNGram.PARAM_NGRAM_USE_TOP_K, 50, WordNGram.PARAM_NGRAM_MIN_N, 1, WordNGram.PARAM_NGRAM_MAX_N, 3), TcFeatureFactory.create(TokenRatioPerDocument.class)));
    Map<String, Object> wekaConfig = new HashMap<>();
    wekaConfig.put(DIM_CLASSIFICATION_ARGS, new Object[] { new SvmHmmAdapter() });
    wekaConfig.put(DIM_DATA_WRITER, new SvmHmmAdapter().getDataWriterClass().getName());
    wekaConfig.put(DIM_FEATURE_USE_SPARSE, new SvmHmmAdapter().useSparseFeatures());
    Dimension<Map<String, Object>> mlas = Dimension.createBundle("config", wekaConfig);
    ParameterSpace pSpace = new ParameterSpace(Dimension.createBundle("readers", dimReaders), Dimension.create(DIM_LEARNING_MODE, LM_SINGLE_LABEL), Dimension.create(DIM_FEATURE_MODE, FM_SEQUENCE), dimFeatureSets, mlas);
    return pSpace;
}
Also used : CollectionReaderDescription(org.apache.uima.collection.CollectionReaderDescription) HashMap(java.util.HashMap) ParameterSpace(org.dkpro.lab.task.ParameterSpace) TcFeatureSet(org.dkpro.tc.api.features.TcFeatureSet) SvmHmmAdapter(org.dkpro.tc.ml.svmhmm.SvmHmmAdapter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with SvmHmmAdapter

use of org.dkpro.tc.ml.svmhmm.SvmHmmAdapter in project dkpro-tc by dkpro.

the class SvmHmmBrownPosDemo method getParameterSpace.

public static ParameterSpace getParameterSpace() throws ResourceInitializationException {
    // configure training and test data reader dimension
    Map<String, Object> dimReaders = getDimReaders();
    Dimension<TcFeatureSet> dimFeatureSets = Dimension.create(Constants.DIM_FEATURE_SET, new TcFeatureSet(TcFeatureFactory.create(TokenRatioPerDocument.class), TcFeatureFactory.create(CharacterNGram.class, CharacterNGram.PARAM_NGRAM_USE_TOP_K, 20, CharacterNGram.PARAM_NGRAM_MIN_N, 2, CharacterNGram.PARAM_NGRAM_MAX_N, 3)));
    Map<String, Object> config = new HashMap<>();
    config.put(DIM_CLASSIFICATION_ARGS, new Object[] { new SvmHmmAdapter(), "-c", "5.0", "-t", "1", "-m", "0" });
    config.put(DIM_DATA_WRITER, new SvmHmmAdapter().getDataWriterClass().getName());
    config.put(DIM_FEATURE_USE_SPARSE, new SvmHmmAdapter().useSparseFeatures());
    Dimension<Map<String, Object>> mlas = Dimension.createBundle("config", config);
    return new ParameterSpace(Dimension.createBundle("readers", dimReaders), Dimension.create(Constants.DIM_LEARNING_MODE, Constants.LM_SINGLE_LABEL), Dimension.create(Constants.DIM_FEATURE_MODE, Constants.FM_SEQUENCE), dimFeatureSets, mlas);
}
Also used : HashMap(java.util.HashMap) ParameterSpace(org.dkpro.lab.task.ParameterSpace) TcFeatureSet(org.dkpro.tc.api.features.TcFeatureSet) SvmHmmAdapter(org.dkpro.tc.ml.svmhmm.SvmHmmAdapter) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 ParameterSpace (org.dkpro.lab.task.ParameterSpace)2 TcFeatureSet (org.dkpro.tc.api.features.TcFeatureSet)2 SvmHmmAdapter (org.dkpro.tc.ml.svmhmm.SvmHmmAdapter)2 CollectionReaderDescription (org.apache.uima.collection.CollectionReaderDescription)1