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

edu.isi.nlp.strings.offsets.OffsetGroupSpan Maven / Gradle / Ivy

The newest version!
package edu.isi.nlp.strings.offsets;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import edu.isi.nlp.symbols.Symbol;
import java.util.Map;

public final class OffsetGroupSpan {

  private final OffsetGroupRange range;
  private final Symbol type;
  private final ImmutableMap attributes;

  public OffsetGroupRange range() {
    return range;
  }

  public Symbol type() {
    return type;
  }

  public Map attributes() {
    return attributes;
  }

  /*private static final Symbol REGION_SPAN = Symbol.from("RegionSpan");

  public static OffsetGroupSpan createRegionSpan(final OffsetGroupRange range) {
  	return new OffsetGroupSpan(REGION_SPAN, range, ImmutableMap.of());
  }*/

  public static OffsetGroupSpan create(
      final Symbol spanType,
      final OffsetGroupRange range,
      final Map otherAttributes) {
    return new OffsetGroupSpan(spanType, range, otherAttributes);
  }

  public static OffsetGroupSpan create(final Symbol spanType, final OffsetGroupRange range) {
    return create(spanType, range, ImmutableMap.of());
  }

  private OffsetGroupSpan(
      final Symbol spanType,
      final OffsetGroupRange range,
      final Map otherAttributes) {
    this.range = checkNotNull(range);
    this.type = checkNotNull(spanType);
    this.attributes = ImmutableMap.copyOf(otherAttributes);
  }

  public static Function toOffsetGroupRangeFunction() {
    return new Function() {
      @Override
      public OffsetGroupRange apply(OffsetGroupSpan input) {
        return input.range();
      }
    };
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy