Package net.sf.okapi.common
Class RenumberingUtil
- java.lang.Object
-
- net.sf.okapi.common.RenumberingUtil
-
public class RenumberingUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description RenumberingUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcalculateCodeOffset(TextFragment tf)Find the minimum ID of any code in the TextFragment, then use that to calculate the offset/delta by which all code IDs in the TextFragment need to be adjusted.static booleancontainsOnlyMatchingCodes(TextFragment tf)Check to see if this text fragment contains either open or closed tags that do not have a corresponding paired tag within the same TextFragment.static voidrenumberCodesForDesegmentation(TextContainer tc)Reverse the renumbering process that was performed during segmentation.static voidrenumberCodesForSegmentation(TextContainer tc)Renumber the codes in a TextContainer for segmentation.static voidrenumberTextUnitCodes(ITextUnit tu, LocaleId trgLocale)Renumber the codes in the TextUnit's source container, then align with the codes in the target.
-
-
-
Method Detail
-
renumberCodesForSegmentation
public static void renumberCodesForSegmentation(TextContainer tc)
Renumber the codes in a TextContainer for segmentation. As much as possible, this will renumber the code IDs in each TextFragment to begin at 1. In cases where a tag pair is split across one or more TextFragments, this is not possible. In this case, these "runs" of connected TextFragments will be treated as a single logical ID-space and collectively renumbered to start at 1.
Note that this can cause problems when code IDs are not consecutive or non-numeric.- Parameters:
tc- TextContainer to renumber
-
renumberTextUnitCodes
public static void renumberTextUnitCodes(ITextUnit tu, LocaleId trgLocale)
Renumber the codes in the TextUnit's source container, then align with the codes in the target.- Parameters:
tu-ITextUnitto renumbertrgLocale- the target locale.
-
calculateCodeOffset
public static int calculateCodeOffset(TextFragment tf)
Find the minimum ID of any code in the TextFragment, then use that to calculate the offset/delta by which all code IDs in the TextFragment need to be adjusted.- Parameters:
tf- TextFragment to examine- Returns:
- code ID offset for the TextFragment, which is one less than the minimum code ID
-
containsOnlyMatchingCodes
public static boolean containsOnlyMatchingCodes(TextFragment tf)
Check to see if this text fragment contains either open or closed tags that do not have a corresponding paired tag within the same TextFragment.- Parameters:
tf- the text fragment.- Returns:
- true if unmatched/unpaired codes are present
-
renumberCodesForDesegmentation
public static void renumberCodesForDesegmentation(TextContainer tc)
Reverse the renumbering process that was performed during segmentation.- Parameters:
tc- the text container to renumber.
-
-