| Segment Methods |
The Segment type exposes the following members.
| Name | Description | |
|---|---|---|
| Add(String) |
Adds the provided string as a new text element to the segment's list of elements. If
the last segment element is a Text element as well, they will be merged.
| |
| Add(SegmentElement) |
Adds the provided segment element to the segment's list of elements. When adding a text element,
and the last segment element is a text element as well, they will be merged.
| |
| AddRange |
Adds all segment elements in the collection to this segment.
| |
| AnchorDanglingTags |
Sets the anchor for any tags which are not yet anchored (including standalone/placeholder tags).
Does not modify tag IDs or alignment anchors.
| |
| Clear |
Empties the list of segment elements.
| |
| DeleteEmptyTagPairs |
Deletes empty tag pairs (a start tag directly followed by the end tag with the same
tag anchor) from the segment.
| |
| DeleteTags |
Removes all tags from the segment, applying the DeleteAll tag
deletion mode.
| |
| DeleteTags(SegmentDeleteTagsAction) |
Removes all tags from the segment, applying the specified tag deletion mode.
| |
| Duplicate |
Creates a new instance that is a deep copy of this instance.
| |
| Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| Equals(Segment) |
Compares this instance to another Segment object.
| |
| FillUnmatchedStartAndEndTags |
Inserts corresponding start and end tags for unmatched end and start tags to the segment.
For unmatched end tags, the corresponding start tags are inserted at the beginning of the
segment. Corresponding end tags for unmatched start tags are added at the end. In certain
cases, not all dangling tags can be filled, and in order to obtain a valid segment without
any unmatched tags, RemoveUnmatchedStartAndEndTags(Boolean) should be called after
calling this method. Note that only the tag type is checked, not whether there are
start or end tags without a corresponding tag having the same tag anchor.
The method will discontinue if the tag pairing structure is incorrect (i.e. if there are overlapping tags). | |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
| FindTag |
Finds and returns the tag with the provided type and the provided tag anchor, or null
if no such tag exists in the segment.
| |
| GetHashCode | (Overrides ObjectGetHashCode.) | |
| GetMaxTagAnchor |
Returns the highest tag anchor used in the segment, or 0 if no tags are present.
| |
| GetMinMaxTagAnchor |
Returns the smallest and largest tag anchor used in the segment. Both default to 0.
| |
| GetTagCount |
Returns the number of tags in the segment. Paired tags are counted only once.
| |
| GetTagIDGroups |
Computes a mapping from the start tag token index to that tag's tag ID. Only
start and standalone/placeholder tags are included in the mapping. The mapping may be n:1.
The segment must be tokenized, or an exception is thrown.
| |
| GetTagPairings |
Returns a dictionary of paired tag token indices, mapping from the start tag's
token index to the end tag's token index. The segment must be tokenized, or an
exception is thrown.
| |
| GetTokenIndex |
Returns the index of the token at the specified position.
| |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| GetWeakHashCode |
Returns a hash code which does not depend on tag anchors in the segment. This
can be used for translation tracking in bilingual documents.
| |
| HasPeripheralWhitespace |
Determines whether the segment starts or ends with at least one whitespace character.
| |
| HasTokenBundles |
Returns true if any of the segment's tokens is a TokenBundle (i.e. an ambigous tokenization),
and false otherwise. Token bundles should only be used inside the TM Kernel and not be returned
through the TM API.
| |
| HasUnmatchedStartOrEndTags |
Determines whether the segment has any unmatched start or end tags. Note that this
method only tests the tag type, and does not handle paired tags where the start or
end tag are missing.
| |
| IsValid |
Determines if this segment is valid.
| |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| MergeAdjacentTextRuns |
Merges adjacent text runs.
| |
| RemoveTokenBundles |
Replaces token bundles with the "best" token in that bundle. Returns true if any
replacement has been done, and false otherwise.
| |
| RemoveUnmatchedStartAndEndTags |
Deletes all tags from the segment which have a tag type of UnmatchedStart
or UnmatchedEnd. Note that this method only tests the tag type, and
does not handle paired tags where the start or end tag are missing.
| |
| RemoveUnmatchedStartAndEndTags(Boolean) |
Deletes all tags from the segment which have a tag type of UnmatchedStart
or UnmatchedEnd, if these tags occur in peripheral positions, which means
that dangling end tags are only removed if they appear at the start of the segment, and dangling start
tags are only removed if they appear at the end of the segment, with no other tags or text preceding the
tag (in case of segment-initial dangling end tags), or following the tag (for segment-trailing dangling
start tags).
Note that this method only tests the tag type, and does not handle paired tags where the start or end tag are missing. | |
| RenumberTagAnchors(Int32) |
Renumbers tag anchors so that they start at 1 and are consecutive. Although tag anchors
have no semantics for standalone tags, they are also anchored in the same manner. Errors
in tag numbering will be ignored (but preserved, i.e. invalid tag anchors will be mapped to
potentially new, also invalid tag anchors).
| |
| RenumberTagAnchors(Int32, Int32) |
Renumbers tag anchors, starting at nextTagAnchor, in a consecutive manner. Although tag anchors
have no semantics for standalone tags, they are also anchored in the same manner. Errors
in tag numbering will be ignored (but preserved, i.e. invalid tag anchors will be mapped to
potentially new, also invalid tag anchors).
| |
| ToPlain |
Returns a string containing only the plain text in this segment. Note that
text placeholders will be replaced with their text equivalent.
| |
| ToPlain(SegmentRange) |
Computes the plain-text version of the part of the segment specified by the provided range.
| |
| ToPlain(Int32, Int32) |
Returns a string containing only the plain text in this segment, covering the given token range.
An exception will be thrown if the segment's tokens are not set or the token range is outside the
bounds.
| |
| ToPlain(Boolean, Boolean, ListSegmentPosition) |
Computes the plain-text version of the segment and returns, in the ranges list,
the segment range of each character of the result string. The number of elements
in that collection will be equal to the length of the string in characters.
| |
| ToString | (Overrides ObjectToString.) | |
| Trim |
Removes leading whitespace from the first segment element, if that is a text element,
and trailing whitespace from the last segment element, if that is a text element. If the first/last
segment element is not a text element, it will not be altered. Also, leading (trailing) whitespace
will not be removed from a text element if it is preceded (followed) only by non-text elements. Also
deletes any null elements.
| |
| TrimEnd |
Removes trailing whitespace from the last segment element, if that is a text element.
If the last segment element is not a text element, nothing will happen. Hence, trailing
whitespace will not be removed from a text element if it is followed by non-text
elements. The number of elements may be altered by this method. Empty (null) elements
will also be removed.
| |
| TrimStart |
Removes leading whitespace from the first segment element, if that is a text element.
If the first segment element is not a text element, nothing will happen. Hence, leading
whitespace will not be removed from a text element if it is preceded by non-text
elements. The number of elements may be altered by this method. Empty (null) elements
will also be removed.
| |
| UpdateFromTokenIndices |
Updates the segment's text from the tokens, and adjusts span indices accordingly. An exception
is thrown if the segment is not tokenized.
| |
| Validate |
Validates the current instance, with the ReportAllErrors validation mode.
| |
| Validate(SegmentValidationMode) |
Performs validation checks on this instance, applying the specified validation mode.
| |
| VerifyTokenSpans |
Verifies whether the spans of the segment's tokens are correct and reflect the segment's text.
Note that the segment should be tokenized. If not, true is returned.
| |
| WeakEquals |
Computes weak equality with another segment.
Weak equality does not check culture compatibility and tag anchors do not need to be identical, but text elements must match, as well as the order of tags (element similarity must not be None) |