All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gate.plugin.learningframework.features.SeqEncoder Maven / Gradle / Ivy

Go to download

A GATE plugin that provides many different machine learning algorithms for a wide range of NLP-related machine learning tasks like text classification, tagging, or chunking.

There is a newer version: 4.2
Show newest version
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gate.plugin.learningframework.features;

import gate.Annotation;
import gate.Document;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * Class for implementing methods to convert sequences to classes and back
 * @author Johann Petrak 
 */
public abstract class SeqEncoder {
  public static final String CODESEP = "|";
  public static final String CODESEP_PATTERN = Pattern.quote(CODESEP);
  public static final String TYPESEP = ",";
  public static final String TYPESEP_PATTERN = Pattern.quote(TYPESEP);
  public static final String CODE_OUTSIDE = "O";
  public static final String CODE_BEGIN = "B";
  public static final String CODE_INSIDE = "I";
  public static final String CODE_END = "E";
  public static final String CODE_SINGLE = "S"; // = begin and end
  private Map options = new HashMap<>();
  public abstract String seqAnns2ClassLabel(Collection seqAnns, Annotation instAnn, Document curDoc);
  public void setOptions(Map options) {
    if(options != null) this.options.putAll(options);
  }

  /**
   * Return options.
   * 
   * TODO: this still needs to get implemented.
   * 
   * @return Option settings.
   */
  public Map getOptions() { return options; }
  // TODO: not sure yet what the best way is to implement the conversion back from
  // class labels to annotations. This probably needs to map the full sequence
  // of class labels to a set of annotations?
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy