<commit_before>package technology.tabula;

import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

import static java.lang.Float.compare;
import static java.util.Collections.min;

@SuppressWarnings("serial")
// TODO: this class should probably be called "PageArea" or something like that
public class Page extends Rectangle {

    private int number;
    private Integer rotation;
    private float minCharWidth;
    private float minCharHeight;

    private List<TextElement> textElements;

    // TODO: Create a class for 'List <Ruling>' that encapsulates all of these lists and their behaviors?
    private List<Ruling> rulings,
            cleanRulings = null,
            verticalRulingLines = null,
            horizontalRulingLines = null;

    private PDPage pdPage;
    private PDDocument pdDoc;

    private RectangleSpatialIndex<TextElement> spatialIndex;

    private static final float DEFAULT_MIN_CHAR_LENGTH = 7;

    private Page(
            PageDims pageDims,
            int rotation,
            int number,
            PDPage pdPage,
            PDDocument doc,
            List<TextElement> characters,
            List<Ruling> rulings,
            float minCharWidth,
            float minCharHeight,
            RectangleSpatialIndex<TextElement> index
    ) {
        super(pageDims.getTop(), pageDims.getLeft(), pageDims.getWidth(), pageDims.getHeight());
        this.rotation = rotation;
        this.number = number;
        this.pdPage = pdPage;
        this.pdDoc = doc;
        this.textElements = characters;
        this.rulings = rulings;
        this.minCharWidth = minCharWidth;
        this.minCharHeight = minCharHeight;
        this.spatialIndex = index;
    }

  /**
   *
   * @deprecated use {@link Builder} instead
   */
    @Deprecated
    public Page(float top, float left, float width, float height, int rotation, int number, PDPage pdPage, PDDocument doc) {
      super(top, left, width, height);
      this.rotation = rotation;
      this.number = number;
      this.pdPage = pdPage;
      this.pdDoc = doc;
    }

   /**
    *
    * @deprecated use {@link Builder} instead
    */
    public Page(float top, float left, float width, float height, int rotation, int number, PDPage pdPage, PDDocument doc,
                List<TextElement> characters, List<Ruling> rulings) {
      this(top, left, width, height, rotation, number, pdPage, doc);
      this.textElements = characters;
      this.rulings = rulings;
    }

   /**
    *
    * @deprecated use {@link Builder} instead
    */
    public Page(float top, float left, float width, float height, int rotation, int number, PDPage pdPage, PDDocument doc,
                ObjectExtractorStreamEngine streamEngine, TextStripper textStripper) {
      this(top, left, width, height, rotation, number, pdPage, doc, textStripper.textElements, streamEngine.rulings);
      this.minCharWidth = textStripper.minCharWidth;
      this.minCharHeight = textStripper.minCharHeight;
      this.spatialIndex = textStripper.spatialIndex;
    }

<commit_msg>adapt to refactor<commit_after>package technology.tabula;

import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

import static java.lang.Float.compare;
import static java.util.Collections.min;

@SuppressWarnings("serial")
// TODO: this class should probably be called "PageArea" or something like that
public class Page extends Rectangle {

    private int number;
    private Integer rotation;
    private float minCharWidth;
    private float minCharHeight;

    private List<TextElement> textElements;

    // TODO: Create a class for 'List <Ruling>' that encapsulates all of these lists and their behaviors?
    private List<Ruling> rulings,
            cleanRulings = null,
            verticalRulingLines = null,
            horizontalRulingLines = null;

    private PDPage pdPage;
    private PDDocument pdDoc;

    private RectangleSpatialIndex<TextElement> spatialIndex;

    private static final float DEFAULT_MIN_CHAR_LENGTH = 7;

    private Page(
            PageDims pageDims,
            int rotation,
            int number,
            PDPage pdPage,
            PDDocument doc,
            List<TextElement> characters,
            List<Ruling> rulings,
            float minCharWidth,
            float minCharHeight,
            RectangleSpatialIndex<TextElement> index
    ) {
        super(pageDims.getTop(), pageDims.getLeft(), pageDims.getWidth(), pageDims.getHeight());
        this.rotation = rotation;
        this.number = number;
        this.pdPage = pdPage;
        this.pdDoc = doc;
        this.textElements = characters;
        this.rulings = rulings;
        this.minCharWidth = minCharWidth;
        this.minCharHeight = minCharHeight;
        this.spatialIndex = index;
    }

  /**
   *
   * @deprecated use {@link Builder} instead
   */
    @Deprecated
    public Page(float top, float left, float width, float height, int rotation, int number, PDPage pdPage, PDDocument doc) {
      super(top, left, width, height);
      this.rotation = rotation;
      this.number = number;
      this.pdPage = pdPage;
      this.pdDoc = doc;
    }

   /**
    *
    * @deprecated use {@link Builder} instead
    */
    public Page(float top, float left, float width, float height, int rotation, int number, PDPage pdPage, PDDocument doc,
                List<TextElement> characters, List<Ruling> rulings) {
      this(top, left, width, height, rotation, number, pdPage, doc);
      this.textElements = characters;
      this.rulings = rulings;
    }

   /**
    *
    * @deprecated use {@link Builder} instead
    */
    public Page(float top, float left, float width, float height, int rotation, int number, PDPage pdPage, PDDocument doc,
                ObjectExtractorStreamEngine streamEngine, TextStripper textStripper) {
      this(top, left, width, height, rotation, number, pdPage, doc, textStripper.getTextElements(), streamEngine.rulings);
      this.minCharWidth = textStripper.getMinCharWidth();
      this.minCharHeight = textStripper.getMinCharHeight();
      this.spatialIndex = textStripper.getSpatialIndex();
    }


{'fraction_non_alphanumeric': 0.0880893300248139, 'fraction_numerical': 0.0006203473945409429, 'mean_word_length': 2.8182356423919477, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3736134', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1798, 'n_words': 510}