Codota Logo
AlignedString
Code IndexAdd Codota to your IDE (free)

How to use
AlignedString
in
de.tudarmstadt.ukp.dkpro.core.api.transform.alignment

Best Java code snippets using de.tudarmstadt.ukp.dkpro.core.api.transform.alignment.AlignedString (Showing top 15 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: dkpro/dkpro-core

private static AlignedString createBase(final String base)
{
  final AlignedString d = new AlignedString();
  d._first._next = d.new BaseSegment(d._first, d._last, base);
  d._last._prev = d._first._next;
  return d;
}
origin: dkpro/dkpro-core

/**
 * Deletes data.
 * 
 * @param start
 *            the start offset.
 * @param end
 *            the end offset+1.
 */
public void delete(final int start, final int end)
{
  replace(start, end, null);
}
origin: dkpro/dkpro-core

public void updateCaches()
{
  if (_underlying != null) {
    _underlying.updateCaches();
  }
  get();
  if (_startDirty) {
    int length = 0;
    AbstractDataSegment seg = _first;
    while (seg != null) {
      seg._cachedStart = length;
      length += seg.length();
      seg = seg._next;
    }
    _startDirty = false;
    System.out.println("startDirty false");
  }
}
origin: dkpro/dkpro-core

public AlignedString(final AlignedString underlying)
{
  _underlying = underlying;
  _underlying.addChangeListener(this);
  _first._next = new ObliqueSegment(_first, _last, _underlying.getAnchor(0),
      _underlying.getAnchor(_underlying.length()));
  _last._prev = _first._next;
}
origin: dkpro/dkpro-core

@Override
public void afterProcess(JCas aInput, JCas aOutput)
  AlignedString alignedString = new AlignedString(aInput.getDocumentText());
    switch (change.getAction()) {
    case INSERT:
      alignedString.insert(change.getStart(), change.getText());
      break;
    case DELETE:
      alignedString.delete(change.getStart(), change.getEnd());
      break;
    case REPLACE:
      alignedString.replace(change.getStart(), change.getEnd(), change.getText());
      break;
    default:
  aOutput.setDocumentText(alignedString.get());
          Interval i = alignedString.inverseResolve(new ImmutableInterval(annoFs
              .getBegin(), annoFs.getEnd()));
          fsCopy.setIntValue(beginFeature, i.getStart());
origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.castransformation-asl

AlignedString alignmentState = new AlignedString(aSourceView.getDocumentText());
  for (SofaChangeAnnotation a : edits) {
    if (ApplyChangesAnnotator.OP_INSERT.equals(a.getOperation())) {
      alignmentState.insert(a.getBegin(), a.getValue());
      alignmentState.delete(a.getBegin(), a.getEnd());
      alignmentState.replace(a.getBegin(), a.getEnd(), a.getValue());
origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.textnormalizer-asl

  public static void applyChanges(AlignedString as, List<SofaChangeAnnotation> changes) {
    
    // If we remove or add stuff all offsets right of the change location
    // will change and thus the offsets in the change annotation are no
    // longer valid. If we move from right to left it works better because
    // the left offsets remain stable.
    Collections.reverse(changes);
    for (SofaChangeAnnotation c : changes) {
      if (OP_INSERT.equals(c.getOperation())) {
        // getContext().getLogger().log(INFO,
        // "Performing insert: "+a.getBegin()+"-"+a.getEnd());
        as.insert(c.getBegin(), c.getValue());
      }
      if (OP_DELETE.equals(c.getOperation())) {
        // getContext().getLogger().log(INFO,
        // "Performing delete: "+a.getBegin()+"-"+a.getEnd());
        as.delete(c.getBegin(), c.getEnd());
      }
      if (OP_REPLACE.equals(c.getOperation())) {
        // getContext().getLogger().log(INFO,
        // "Performing replace: "+a.getBegin()+"-"+a.getEnd());
        as.replace(c.getBegin(), c.getEnd(), c.getValue());
      }
    }
  }
}
origin: dkpro/dkpro-core

  insert(start, d);
  return;
final AbstractDataSegment segAtStart = getSegmentAt(start);
final AbstractDataSegment segAtEnd = getSegmentAt(end - 1, end > 1);
dropSuperflourous(prefix);
dropSuperflourous(suffix);
fireChange();
origin: dkpro/dkpro-core

/**
 * Fetch data
 * 
 * @param start
 *            the start offset.
 * @param end
 *            the end offset.
 * @return the data.
 */
public String get(final int start, final int end)
{
  return get().substring(start, end);
}
origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.castransformation-asl

  private void updateOffsets(CAS sourceView, JCas targetView, AlignedString as, 
      PositiveIntSet aCopiedFs)
    throws CASException, AnalysisEngineProcessException
  {
    // We only update annotations that were copied, nothing that was already there.
    IntListIterator it = aCopiedFs.iterator();
    
    while (it.hasNext()) {
      FeatureStructure fs = targetView.getLowLevelCas().ll_getFSForRef(it.next());
      if (fs instanceof Annotation) {

        // Now we update the offsets
        Annotation a = (Annotation) fs;
//            System.out.printf("Orig   %s %3d %3d : %s%n", a.getType().getShortName(),
//                    a.getBegin(), a.getEnd(),
//                    sourceView.getDocumentText().substring(a.getBegin(), a.getEnd()));
//            System.out.printf("Before %s %3d %3d : %s%n", a.getType().getShortName(),
//                    a.getBegin(), a.getEnd(), a.getCoveredText());
        Interval resolved = as.resolve(new ImmutableInterval(a.getBegin(), a.getEnd()));
        a.setBegin(resolved.getStart());
        a.setEnd(resolved.getEnd());
//            System.out.printf("After  %s %3d %3d : %s%n", a.getType().getShortName(),
//                    a.getBegin(), a.getEnd(), a.getCoveredText());
      }
    }
  }
}
origin: dkpro/dkpro-core

@Override
public String toString()
{
  return dataSegmentsToString();
}
origin: dkpro/dkpro-core

public AlignedString(final String base)
{
  this(createBase(base));
}
origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.castransformation-asl

  protected void applyChanges(JCas aSourceView, JCas aTargetView)
  {
    AlignedString as = AlignmentFactory.createAlignmentsFor(aSourceView);

    // Set the text of the new Sofa
    aTargetView.setDocumentText(as.get());

    // Set document language
    aTargetView.setDocumentLanguage(aSourceView.getDocumentLanguage());

    // Optionally we may want to remember the AlignedString for the backmapper.
    AlignmentStorage.getInstance().put(aSourceView.getCasImpl().getBaseCAS(),
        aSourceView.getViewName(), aTargetView.getViewName(), as);
  }
}
origin: dkpro/dkpro-core

final Interval ulpos = resolve(new ImmutableInterval(seg.getStart(), seg.getEnd()));
origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.textnormalizer-asl

AlignedString as = new AlignedString(jcas.getDocumentText());
NormalizationUtils.applyChanges(as, allChanges);
de.tudarmstadt.ukp.dkpro.core.api.transform.alignmentAlignedString

Javadoc

Allows to stack strings on top of each other and modifying each of them propagating changes up to the top while leaving lower levels unchanged. This class is not synchronized internally.

Most used methods

  • <init>
  • delete
  • insert
  • replace
  • get
  • resolve
  • addChangeListener
  • createBase
  • dataSegmentsToString
    Create a string representation of the segments. This is for debugging purposes.
  • dropSuperflourous
    If the given segment is a zero-length base segment, then it can be dropped. Zero-length oblique segm
  • fireChange
  • getAnchor
    Get an anchor at the specified position. Breaks up the segment at the given point if necessary. If t
  • fireChange,
  • getAnchor,
  • getFirst,
  • getSegmentAt,
  • inverseResolve,
  • length,
  • updateCaches

Popular in Java

  • Finding current android device location
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement.A servlet is a small Java program that runs within
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now