Class CodeSimplifier


  • public class CodeSimplifier
    extends Object
    Author:
    Fredrik Liden, Sergei Vasilyev, Jim Hargrave
    • 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​(String rules)
      • isPostSegmentation

        public boolean isPostSegmentation()
      • setPostSegmentation

        public void setPostSegmentation​(boolean postSegmentation)