net.sf.okapi.common.resource

## Class CodeSimplifier

- java.lang.Object
- - net.sf.okapi.common.resource.CodeSimplifier

-     public class CodeSimplifier
      extends java.lang.Object

  Author:
    Fredrik Liden, Sergei Vasilyev

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `MAX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CodeSimplifier()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String[]` | `simplifyAll(TextContainer tc, boolean removeLeadingTrailingCodes)` Simplifies all possible tags in a given possibly segmented text container.
    `java.lang.String[]` | `simplifyAll(TextFragment tf, boolean removeLeadingTrailingCodes)` Simplifies all possible tags in a given text fragment.
    `java.lang.String[]` | `simplifyAll(TextFragment tf, int maxIterations, boolean removeLeadingTrailingCodes)` Simplifies all possible tags in a given text fragment.
    `void` | `simplifyEmptyOpeningClosing(TextFragment tf)`
    `void` | `simplifyIsolated(TextFragment tf)` Simplifies the place-holders in a given text fragment.
    `void` | `simplifyOpeningClosing(TextFragment tf)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MAX

          protected static final int MAX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CodeSimplifier

          public CodeSimplifier()

  - ### Method Detail

    - #### simplifyAll

          public java.lang.String[] simplifyAll(TextFragment tf,
                                       int maxIterations,
                                       boolean removeLeadingTrailingCodes)

      Simplifies all possible tags in a given text fragment.
      Parameters:
        `tf` - the text fragment to modify.
        `maxIterations` - maximum number of iterations in merging of adjacent codes.
        `removeLeadingTrailingCodes` - true to remove the leading and/or the trailing codes of the fragment and place their text in the result. This works for isolated codes only for now. It is the responsibility of the caller to put the leading/trailing data into the skeleton.
      Returns:
        Null (no leading or trailing code removal was) or a string array with the original data of the codes removed. The first string if there was a leading code, the second string if there was a trailing code. Both or either can be null.

    - #### simplifyAll

          public java.lang.String[] simplifyAll(TextContainer tc,
                                       boolean removeLeadingTrailingCodes)

      Simplifies all possible tags in a given possibly segmented text container.
      Parameters:
        `tc` - the given text container to modify
        `removeLeadingTrailingCodes` - true to remove the leading and/or the trailing code of the fragment and place their text in the result. It is the responsibility of the caller to put the leading/trailing data into the skeleton.
      Returns:
        Null (no leading or trailing code removal was) or a string array with the original data of the codes removed. The first string if there was a leading code, the second string if there was a trailing code. Both or either can be null.

    - #### simplifyAll

          public java.lang.String[] simplifyAll(TextFragment tf,
                                       boolean removeLeadingTrailingCodes)

      Simplifies all possible tags in a given text fragment.
      Parameters:
        `tf` - the text fragment to modify.
        `removeLeadingTrailingCodes` - true to remove the leading and/or the trailing code of the fragment and place their text in the result. It is the responsibility of the caller to put the leading/trailing data into the skeleton.
      Returns:
        Null (no leading or trailing code removal was) or a string array with the original data of the codes removed. The first string if there was a leading code, the second string if there was a trailing code. Both or either can be null.

    - #### simplifyIsolated

          public void simplifyIsolated(TextFragment tf)

      Simplifies the place-holders in a given text fragment.
      Parameters:
        `tf` - the text fragment to modify.

    - #### simplifyOpeningClosing

          public void simplifyOpeningClosing(TextFragment tf)

    - #### simplifyEmptyOpeningClosing

          public void simplifyEmptyOpeningClosing(TextFragment tf)