<commit_before>package common

import play.api._
import play.api.mvc._
import play.twirl.api.Html
import scala.xml.Utility.escape
import models.Tables._
import play.api.db.slick.Config.driver.simple._
import play.api.db.slick.Config.driver.simple.{Session => DBSession}

object Review {

  implicit val offeringsOrdering = Ordering.by[(String,List[String]),String](_._1).reverse

  // For a given department and course number, get all offerings.
  def getOfferings(dept: String, num: String)(implicit session: DBSession) = {
    CrReview2008.filter(rev =>
      rev.revision === 0 &&
      rev.departmentCode === dept &&
      rev.courseNum === num)
    .map(rev => (rev.edition, rev.section))
    .list
    .groupBy(_._1)
    .mapValues(_.map(_._2))
    .toList
    .sorted
  }


  // Given the textual contents of a review, mark it up with XML
  def markup_review_content(content: String) = {
    val ulevel = 0 // TODO: track and store ulevel
    var xml_content = "";
    content.replaceAll("\r", "").split("""(\s*\n\s*\t\s*|\s*\n\s*\n\s*)""")<commit_msg>Don't show courses from future editions.<commit_after>package common

import play.api._
import play.api.mvc._
import play.twirl.api.Html
import scala.xml.Utility.escape
import models.Tables._
import play.api.db.slick.Config.driver.simple._
import play.api.db.slick.Config.driver.simple.{Session => DBSession}

object Review {

  implicit val offeringsOrdering = Ordering.by[(String,List[String]),String](_._1).reverse

  // For a given department and course number, get all offerings.
  def getOfferings(dept: String, num: String)(implicit session: DBSession) = {
    CrReview2008.filter(rev =>
      rev.revision === 0 &&
      rev.departmentCode === dept &&
      rev.edition <= Global.current_edition &&
      rev.courseNum === num)
    .map(rev => (rev.edition, rev.section))
    .list
    .groupBy(_._1)
    .mapValues(_.map(_._2))
    .toList
    .sorted
  }


  // Given the textual contents of a review, mark it up with XML
  def markup_review_content(content: String) = {
    val ulevel = 0 // TODO: track and store ulevel
    var xml_content = "";
    content.replaceAll("\r", "").split("""(\s*\n\s*\t\s*|\s*\n\s*\n\s*)""")
{'fraction_non_alphanumeric': 0.15145985401459855, 'fraction_numerical': 0.008211678832116789, 'mean_word_length': 3.3425742574257424, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2190217', 'n_tokens_mistral': 751, 'n_tokens_neox': 728, 'n_words': 170}