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, Jim Hargrave

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `MAX`
    `protected boolean` | `postSegmentation`
    `protected SimplifierRules` | `ruleEvaluator`
    `protected java.lang.String` | `rules`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CodeSimplifier()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isPostSegmentation()`
    `void` | `setPostSegmentation(boolean postSegmentation)`
    `void` | `setRules(java.lang.String rules)`
    `TextFragment[]` | `simplifyAll(TextContainer tc, boolean removeLeadingTrailingCodes, boolean mergeCodes)` Simplifies all possible tags in a given possibly segmented text container.
    `TextFragment[]` | `simplifyAll(TextFragment tf, boolean removeLeadingTrailingCodes)` Simplifies all possible tags in a given text fragment.
    `TextFragment[]` | `simplifyAll(TextFragment tf, boolean removeLeadingTrailingCodes, boolean mergeCodes)` Simplifies all possible tags in a given text fragment.
    `TextFragment[]` | `simplifyAll(TextFragment tf, int maxIterations, boolean removeLeadingTrailingCodes, boolean mergeCodes)` 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

    - #### postSegmentation

          protected boolean postSegmentation

    - #### rules

          protected java.lang.String rules

    - #### ruleEvaluator

          protected SimplifierRules ruleEvaluator

  - ### Constructor Detail

    - #### CodeSimplifier

          public CodeSimplifier()

  - ### Method Detail

    - #### simplifyAll

          public TextFragment[] simplifyAll(TextFragment tf,
                                   int maxIterations,
                                   boolean removeLeadingTrailingCodes,
                                   boolean mergeCodes)

      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.
        `mergeCodes` - true to merge adjacent codes, false to leave as-is
      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 TextFragment[] simplifyAll(TextContainer tc,
                                   boolean removeLeadingTrailingCodes,
                                   boolean mergeCodes)

      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.
        `mergeCodes` - true to merge adjacent codes, false to leave as-is 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.
      Returns:
        Null (no leading or trailing code removal was) or a string array with the

    - #### simplifyAll

          public TextFragment[] simplifyAll(TextFragment tf,
                                   boolean removeLeadingTrailingCodes,
                                   boolean mergeCodes)

      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.
        `mergeCodes` - true to merge adjacent codes, false to leave as-is
      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 TextFragment[] 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)

    - #### setRules

          public void setRules(java.lang.String rules)

    - #### isPostSegmentation

          public boolean isPostSegmentation()

    - #### setPostSegmentation

          public void setPostSegmentation(boolean postSegmentation)