<commit_before>package ml.wolfe.ui

import java.io.{FileWriter, File}

import org.json4s.NoTypeHints
import org.json4s.native.Serialization

import scala.collection.mutable.ArrayBuffer

/**
 * @author <NAME>
 */
class MutableMoroNotebook extends MutableNotebook[MutableMoroNotebook] {

  val cells = new ArrayBuffer[Cell]()

  object OutputFormats extends Enumeration {
    val string, html, javascript = Value
  }
  case class Input(code: String, outputFormat: String = OutputFormats.html.toString, extraFields: Map[String, String] = Map.empty)
  case class Cell(id: Int, compiler: String, input: Input)
  case class DocumentData(name: String, cells: Seq[Cell])

  def stripLeadingWhitespace(text:String) = text.split("\n").map(_.trim).mkString("\n")

  def html(text: String) = {
    cells += Cell(cells.size,"html",Input(text,OutputFormats.html.toString))
    this
  }
  def h2(text: String) = {
    cells += Cell(cells.size,"heading2",Input(text,OutputFormats.html.toString))
    this
  }

  def trimEmptyLines(text:String) = {
    val lines = text.split("\n").toList
    val prefixRemoved = lines.dropWhile(_.trim == "")
    val postfixRemoved = prefixRemoved.reverse.dropWhile(_.trim == "").reverse
    postfixRemoved.mkString("\n")
  }

  def source(src: String) = {
    cells += Cell(cells.size,"scala",Input(trimEmptyLines(src.stripMargin),OutputFormats.string.toString))
    this
  }

  def section(name:String) = {
    cells += Cell(cells.size,"section",Input(name,OutputFormats.html.toString))
    this
  }

  def h1(text: String) = {
    cells += Cell(cells.size,"heading1",Input(text,OutputFormats.html.toString))
    this
  }
  def md(markdown: String) = {
    cells += Cell(cells.size,"markdown",Input(trimEmptyLines(markdown.stripMargin),OutputFormats.html.toString))
    this
  }

  def saveTo(name:String, file:File): Unit = {<commit_msg>added Wolfe cell to Moro notebook<commit_after>package ml.wolfe.ui

import java.io.{FileWriter, File}

import org.json4s.NoTypeHints
import org.json4s.native.Serialization

import scala.collection.mutable.ArrayBuffer

/**
 * @author <NAME>
 */
class MutableMoroNotebook extends MutableNotebook[MutableMoroNotebook] {

  val cells = new ArrayBuffer[Cell]()

  object OutputFormats extends Enumeration {
    val string, html, javascript = Value
  }
  case class Input(code: String, outputFormat: String = OutputFormats.html.toString, extraFields: Map[String, String] = Map.empty)
  case class Cell(id: Int, compiler: String, input: Input)
  case class DocumentData(name: String, cells: Seq[Cell])

  def stripLeadingWhitespace(text:String) = text.split("\n").map(_.trim).mkString("\n")

  def html(text: String) = {
    cells += Cell(cells.size,"html",Input(text,OutputFormats.html.toString))
    this
  }
  def h2(text: String) = {
    cells += Cell(cells.size,"heading2",Input(text,OutputFormats.html.toString))
    this
  }

  def trimEmptyLines(text:String) = {
    val lines = text.split("\n").toList
    val prefixRemoved = lines.dropWhile(_.trim == "")
    val postfixRemoved = prefixRemoved.reverse.dropWhile(_.trim == "").reverse
    postfixRemoved.mkString("\n")
  }

  def source(src: String) = {
    cells += Cell(cells.size,"scala",Input(trimEmptyLines(src.stripMargin),OutputFormats.string.toString))
    this
  }

  def wolfe(src: String) = {
    cells += Cell(cells.size,"wolfe",Input(trimEmptyLines(src.stripMargin),OutputFormats.string.toString))
    this
  }

  def section(name:String) = {
    cells += Cell(cells.size,"section",Input(name,OutputFormats.html.toString))
    this
  }

  def h1(text: String) = {
    cells += Cell(cells.size,"heading1",Input(text,OutputFormats.html.toString))
    this
  }
  def md(markdown: String) = {
    cells += Cell(cells.size,"markdown",Input(trimEmptyLines(markdown.stripMargin),OutputFormats.html.toString))
    this
  }

  def saveTo(name:String, file:File): Unit = {
{'fraction_non_alphanumeric': 0.1413491246138002, 'fraction_numerical': 0.003089598352214212, 'mean_word_length': 4.51063829787234, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '530946', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1264, 'n_words': 231}