public interface IAlignedSegments extends Iterable<Segment>
Segments of
a ITextUnit.
To create an instance of this interface, use the method
ITextUnit.getAlignedSegments().
| Modifier and Type | Method and Description |
|---|---|
void |
align(List<AlignedPair> alignedSegmentPairs,
LocaleId trgLoc)
Aligns all the segments listed in the aligned pairs for given locale.
|
void |
align(LocaleId trgLoc)
Aligns all the target segments with the source segments for the given
locale.
|
void |
alignCollapseAll(LocaleId trgLoc)
Aligns all the segments for the specified sources and targets by
collapsing all segments into one.
|
void |
append(Segment srcSeg,
Segment trgSeg,
LocaleId trgLoc)
Adds given source and target segments to the end of the content.
|
AlignmentStatus |
getAlignmentStatus()
Gets the status of the alignment for this entire text unit.
|
AlignmentStatus |
getAlignmentStatus(LocaleId trgLoc)
Gets the status of the alignment the given target locale in this text
unit.
|
Segment |
getCorrespondingSource(Segment trgSeg,
LocaleId trgLoc)
Gets the source segment corresponding to a given target segment
|
Segment |
getCorrespondingTarget(Segment seg,
LocaleId trgLoc)
Gets the target segment corresponding to a given source segment
|
Segment |
getSource(int index,
LocaleId trgLoc)
Gets the source segment for the given target locale at a given position.
|
void |
insert(int index,
Segment srcSeg,
Segment trgSeg,
LocaleId trgLoc)
Inserts given source and target segments at the specified position in the
list of segments.
|
Iterator<Segment> |
iterator()
Gets an iterator for the default source segments of this text unit.
|
Iterator<Segment> |
iterator(LocaleId trgLoc)
Gets an iterator for the source of the specified target locale.
|
void |
joinAll(LocaleId trgLoc)
Joins all segments for the specified sources and targets.
|
void |
joinWithNext(Segment seg,
LocaleId trgLoc)
Joins the segment for a given segment's id to the next segment, including
all the parts between the two segments.
|
boolean |
remove(Segment seg,
LocaleId trgLoc)
Removes the given segment and any segments with the same id from the
specified sources and targets.
|
void |
segmentSource(ISegmenter segmenter,
LocaleId targetLocale)
Segments the source content used for the given target locale based on the
rules provided by a given
ISegmenter. |
void |
segmentTarget(ISegmenter segmenter,
LocaleId targetLocale)
Segments the specified target content based on the rules provided by a
given
ISegmenter. |
void |
setSegment(int index,
Segment seg,
LocaleId trgLoc)
Replaces a segment at a given position with a clone of the given segment.
|
Segment |
splitSource(LocaleId trgLoc,
Segment srcSeg,
int splitPos)
Splits a given source segment into two.
|
Segment |
splitTarget(LocaleId trgLoc,
Segment trgSeg,
int splitPos)
Splits a given target segment into two.
|
forEach, spliteratorIterator<Segment> iterator()
Iterator<Segment> iterator(LocaleId trgLoc)
trgLoc - the target locale for the source to iterate over.void append(Segment srcSeg, Segment trgSeg, LocaleId trgLoc)
If srcSeg is non-null, the content of srcSeg will be used for any new segments that are not empty, otherwise the content of trgSeg will be used. srcSeg and trgSeg cannot both be null.
srcSeg - the source segment to add.trgSeg - the target segment to add. Null to use a clone of srcSeg
instead.trgLoc - the target locale for which to append segmentsIllegalArgumentException - if srcSeg and trgSeg are both nullvoid insert(int index,
Segment srcSeg,
Segment trgSeg,
LocaleId trgLoc)
The validated id (after insertion) of srcSeg will be applied to all other inserted segments, including trgSeg.
index - the segment index position.srcSeg - the source segment to insert.trgSeg - the target segment to insert. Null to use srcSeg instead.trgLoc - the target locale for which to insert the segmentIllegalArgumentException - if srcSeg is nullvoid setSegment(int index,
Segment seg,
LocaleId trgLoc)
The segment id is determined by the segment at the position of index in the source for trgLoc, the segment id is then used to locate the segments in other sources and targets to replace.
index - the segment index positionseg - the new segment to place at the positiontrgLoc - the target localeIndexOutOfBoundsException - if the index is out of bounds.IllegalArgumentException - if seg is nullboolean remove(Segment seg, LocaleId trgLoc)
seg - the segment to remove.trgLoc - the locale used in specifying which sources and targets to
use.Segment getSource(int index, LocaleId trgLoc)
The first segment has the index 0, the second has the index 1, etc.
index - the segment index of the segment to retrieve.trgLoc - the target locale for the source from which to retrieve the
indicated segment.IndexOutOfBoundsException - if the index is out of bounds.Segment getCorrespondingTarget(Segment seg, LocaleId trgLoc)
seg - the source (or other target) segment for which a corresponding
target segment is requested.trgLoc - the target to look up.Segment (may be empty).Segment getCorrespondingSource(Segment trgSeg, LocaleId trgLoc)
trgSeg - the target segment for which the corresponding source segment
is requested.trgLoc - the target locale of the source to look up.void align(List<AlignedPair> alignedSegmentPairs, LocaleId trgLoc)
This will replace any content in the target and variant source for the given target locale (if either are not present they will be created).
The target for the given locale will be considered aligned with its source when this operation is complete.
alignedSegmentPairs - the list of pairs to aligntrgLoc - the target locale to work with.void align(LocaleId trgLoc)
Assumes the same number of source and target segments otherwise an exception is thrown.
trgLoc - the locale of the target to work with.OkapiMisAlignmentException - if there are a different number of source and target
segments.void alignCollapseAll(LocaleId trgLoc)
trgLoc - the target locale of the target (and its corresponding source)
to collapse.Segment splitSource(LocaleId trgLoc, Segment srcSeg, int splitPos)
Alignment statuses are updated for the locales that have been modified. May cause a misalignment.
trgLoc - the target locale that uses the source in which the segment is
to be splitsrcSeg - the source segment to split.splitPos - the position where to split.Segment splitTarget(LocaleId trgLoc, Segment trgSeg, int splitPos)
Alignment statuses are updated for the locales that have been modified. May cause a misalignment.
trgLoc - the target locale to work on.trgSeg - the targets segment.splitPos - the position where to split.void joinWithNext(Segment seg, LocaleId trgLoc)
seg - a segment holding the id to use for the join.trgLoc - the target localevoid joinAll(LocaleId trgLoc)
trgLoc - the target localeAlignmentStatus getAlignmentStatus()
AlignmentStatus getAlignmentStatus(LocaleId trgLoc)
trgLoc - the target locale for which to get the alignment status.void segmentSource(ISegmenter segmenter, LocaleId targetLocale)
ISegmenter.
No associated targets are modified.
segmenter - the segmenter to use to create the segments.targetLocale - the target locale that uses the source to segment.void segmentTarget(ISegmenter segmenter, LocaleId targetLocale)
ISegmenter.
If the given target does not exist one is created.
segmenter - the segmenter to use to create the segments.targetLocale - LocaleId of the target we want to segment.Copyright © 2021. All rights reserved.