package com.knecon.fforesight.service.layoutparser.processor.utils;

import lombok.experimental.UtilityClass;

@UtilityClass
public final class TextNormalizationUtilities {

    /**
     * Revert hyphenation due to line breaks.
     *
     * @param text Text to be processed.
     * @return Text without line-break hyphenation.
     */
    public static String removeHyphenLineBreaks(String text) {

        return text.replaceAll("([^\\s\\d\\-]{2,500})[\\-\\u00AD]\\R", "$1");
    }


    public static String removeLineBreaks(String text) {

        return text.replaceAll("\n", " ");
    }


    public static String removeRepeatingWhitespaces(String text) {

        return text.replaceAll(" {2}", " ");
    }

}
