package com.knecon.fforesight.service.layoutparser.processor.model.text;

import java.util.ArrayList;
import java.util.List;

import com.knecon.fforesight.service.layoutparser.processor.utils.TextNormalizationUtilities;

import lombok.Getter;

@Getter
public class SearchableText {

    private final List<Word> sequences = new ArrayList<>();


    public void add(Word word) {

        sequences.add(word);
    }


    public void addAll(List<Word> words) {

        sequences.addAll(words);
    }


    @Override
    public String toString() {

        return buildString(sequences);
    }


    public static String buildString(List<Word> sequences) {

        StringBuilder sb = new StringBuilder();
        for (Word word : sequences) {
            sb.append(word);
            sb.append(' ');
        }
        return TextNormalizationUtilities.cleanString(sb.toString());
    }

}
