<commit_before>package net.categoricaldata.server.transformers
import com.recursivity.commons.bean.StringValueTransformer



class OntologyTransformer extends StringValueTransformer[net.categoricaldata.ontology.Ontology] {
  implicit val formats = net.liftweb.json.DefaultFormats
  import net.liftweb.json.JsonParser.parse

  def toValue(from: String): Option[net.categoricaldata.ontology.Ontology] = Some(parse(from).extract[net.categoricaldata.server.json.Ontology].copy(json = Some(from))).map(_.unpack)
}
class TranslationTransformer extends StringValueTransformer[net.categoricaldata.ontology.Translation] {
  implicit val formats = net.liftweb.json.DefaultFormats
  import net.liftweb.json.JsonParser.parse

  def toValue(from: String): Option[net.categoricaldata.ontology.Translation] = Some(parse(from).extract[net.categoricaldata.server.json.Translation].copy(json = Some(from))).map(_.unpack)
}
class DatasetTransformer extends StringValueTransformer[net.categoricaldata.ontology.Dataset] {
  implicit val formats = net.liftweb.json.DefaultFormats
  import net.liftweb.json.JsonParser.parse

  def toValue(from: String): Option[net.categoricaldata.ontology.Dataset] = Some(parse(from).extract[net.categoricaldata.server.json.Dataset].copy(json = Some(from))).map(_.unpack)
}<commit_msg>allowing URLs as parameters to the server; it hopefully automatically loads them<commit_after>package net.categoricaldata.server.transformers
import com.recursivity.commons.bean.StringValueTransformer
import scala.io.Source

trait StringOrURLTransformer[A] extends StringValueTransformer[A] {
  def stringToValue(from: String): Option[A]
 
  def toValue(from: String) = {
    stringToValue(if (from.startsWith("http")) {
      Source.fromURL(from).mkString
    } else {
      from
    })
  }
}

class OntologyTransformer extends StringOrURLTransformer[net.categoricaldata.ontology.Ontology] {
  implicit val formats = net.liftweb.json.DefaultFormats
  import net.liftweb.json.JsonParser.parse

  def stringToValue(from: String): Option[net.categoricaldata.ontology.Ontology] = Some(parse(from).extract[net.categoricaldata.server.json.Ontology].copy(json = Some(from))).map(_.unpack)
}
class TranslationTransformer extends StringOrURLTransformer[net.categoricaldata.ontology.Translation] {
  implicit val formats = net.liftweb.json.DefaultFormats
  import net.liftweb.json.JsonParser.parse

  def stringToValue(from: String): Option[net.categoricaldata.ontology.Translation] = Some(parse(from).extract[net.categoricaldata.server.json.Translation].copy(json = Some(from))).map(_.unpack)
}
class DatasetTransformer extends StringOrURLTransformer[net.categoricaldata.ontology.Dataset] {
  implicit val formats = net.liftweb.json.DefaultFormats
  import net.liftweb.json.JsonParser.parse

  def stringToValue(from: String): Option[net.categoricaldata.ontology.Dataset] = Some(parse(from).extract[net.categoricaldata.server.json.Dataset].copy(json = Some(from))).map(_.unpack)
}
{'fraction_non_alphanumeric': 0.11253369272237197, 'fraction_numerical': 0.0, 'mean_word_length': 6.516455696202532, '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': '4742510', 'n_tokens_mistral': 935, 'n_tokens_neox': 914, 'n_words': 133}