<commit_before>package parsers

import java.net.URL
import com.itextpdf.text.pdf.PdfReader
import com.itextpdf.text.pdf.parser.{PdfTextExtractor, LocationTextExtractionStrategy, FilteredTextRenderListener, RegionTextRenderFilter}
import com.itextpdf.text.Rectangle
import org.joda.time.{Weeks, LocalDate, DateTime}
import org.joda.time.format.DateTimeFormatterBuilder

case class FichierMenus(du: LocalDate, au: LocalDate, listeMenus: List[String])

trait PdfParserComponent {
  val pdfParser: PdfParser
}

trait PdfParser {
  def parsePdf(url: URL): FichierMenus
}

trait ITextPdfParserComponent extends PdfParserComponent {

  override val pdfParser: PdfParser = new ITextPdfParser

  object ITextPdfParser {
    val xOffset = 80
    val yOffset = 16

    val rowWidth = 160
    val colHeight = 121

    // Trying to match "Menus du 2 au 27 septembre" or "Menus du 27 janvier au 21 février"
    val TitleRegexPattern = """Menus\s+du\s+(\d{1,2})\s*(\p{L}+)?\s*au\s+(\d{1,2})\s+(\p{L}+)""" r

    val dateTimeParser = new DateTimeFormatterBuilder()
      .appendYear(4, 4)<commit_msg>Formatage<commit_after>package parsers

import java.net.URL
import com.itextpdf.text.pdf.PdfReader
import com.itextpdf.text.pdf.parser.{PdfTextExtractor, LocationTextExtractionStrategy, FilteredTextRenderListener, RegionTextRenderFilter}
import com.itextpdf.text.Rectangle
import org.joda.time.{LocalDate, DateTime}
import org.joda.time.format.DateTimeFormatterBuilder

case class FichierMenus(du: LocalDate, au: LocalDate, listeMenus: List[String])

trait PdfParserComponent {
  val pdfParser: PdfParser
}

trait PdfParser {
  def parsePdf(url: URL): FichierMenus
}

trait ITextPdfParserComponent extends PdfParserComponent {

  override val pdfParser: PdfParser = new ITextPdfParser

  object ITextPdfParser {
    val xOffset = 80
    val yOffset = 16

    val rowWidth = 160
    val colHeight = 121

    // Trying to match "Menus du 2 au 27 septembre" or "Menus du 27 janvier au 21 février"
    val TitleRegexPattern = """Menus\s+du\s+(\d{1,2})\s*(\p{L}+)?\s*au\s+(\d{1,2})\s+(\p{L}+)""" r

    val dateTimeParser = new DateTimeFormatterBuilder()
      .appendYear(4, 4)
{'fraction_non_alphanumeric': 0.1070931849791377, 'fraction_numerical': 0.02132591562355123, 'mean_word_length': 4.73936170212766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3686128', 'n_tokens_mistral': 775, 'n_tokens_neox': 737, 'n_words': 176}