<commit_before>package io.mediachain.rpc

import io.mediachain.Types._
import io.mediachain.rpc.{Types => RPCTypes}

object TypeConversions {

  implicit class CanonicalToRPC(canonical: Canonical) {
    def toRPC: RPCTypes.Canonical = canonicalToRPC(canonical)
  }


  implicit class RPCToCanonical(rpcCanonical: RPCTypes.Canonical) {
    def fromRPC: Canonical = canonicalFromRPC(rpcCanonical)
  }


  implicit class ImageBlobToRPC(imageBlob: ImageBlob) {
    def toRPC: RPCTypes.ImageBlob = imageBlobToRPC(imageBlob)
  }


  implicit class RPCToImageBlob(rpcBlob: RPCTypes.ImageBlob) {
    def fromRPC: ImageBlob = imageBlobFromRPC(rpcBlob)
  }


  implicit class PersonToRPC(person: Person) {
    def toRPC: RPCTypes.Person = personToRPC(person)
  }


  implicit class RPCToPerson(rpcPerson: RPCTypes.Person) {
    def fromRPC: Person = personFromRPC(rpcPerson)
  }


  implicit class RawMetadataBlobToRPC(raw: RawMetadataBlob) {
    def toRPC: RPCTypes.RawMetadataBlob = rawMetadataBlobToRPC(raw)
  }


  implicit class RPCToRawMetadataBlob(rpcRaw: RPCTypes.RawMetadataBlob) {
    def fromRPC: RawMetadataBlob = rawMetadataBlobFromRPC(rpcRaw)
  }


  def canonicalToRPC(canonical: Canonical): RPCTypes.Canonical =
    RPCTypes.Canonical(canonicalID = canonical.canonicalID)


  def canonicalFromRPC(rpcCanonical: RPCTypes.Canonical) =
    Canonical(None, rpcCanonical.canonicalID)



  def imageBlobToRPC(imageBlob: ImageBlob): RPCTypes.ImageBlob =
    RPCTypes.ImageBlob(
      title = imageBlob.title,
      description = imageBlob.description,
      date = imageBlob.date
    )


  def imageBlobFromRPC(rpcBlob: RPCTypes.ImageBlob): ImageBlob =
    ImageBlob(id = None,
      title = rpcBlob.title,
      description = rpcBlob.description,
      date = rpcBlob.date)


  def personToRPC(person: Person): RPCTypes.Person =
    RPCTypes.Person(name = person.name)


  def personFromRPC(rpcPerson: RPCTypes.Person): Person =
    Person(id = None, name = rpcPerson.name)


  def rawMetadataBlobToRPC(raw: RawMetadataBlob): RPCTypes.RawMetadataBlob =
    RPCTypes.RawMetadataBlob(
      blob = raw.blob
    )

  def rawMetadataBlobFromRPC(rpcRaw: RPCTypes.RawMetadataBlob): RawMetadataBlob =
    RawMetadataBlob(None, blob = rpcRaw.blob)

  def metadataBlobToRPC(blob: MetadataBlob): RPCTypes.MetadataBlob =
    blob match {
      case image: ImageBlob => RPCTypes.MetadataBlob(
        blobType = RPCTypes.MetadataBlob.BlobType.ImageBlob,
        blob = RPCTypes.MetadataBlob.Blob.Image(image.toRPC))

      case person: Person => RPCTypes.MetadataBlob(
        blobType = RPCTypes.MetadataBlob.BlobType.Person,
        blob = RPCTypes.MetadataBlob.Blob.Person(person.toRPC))<commit_msg>fill in multiHash field when converting to RPC types<commit_after>package io.mediachain.rpc

import io.mediachain.Types._
import io.mediachain.rpc.{Types => RPCTypes}

object TypeConversions {

  implicit class CanonicalToRPC(canonical: Canonical) {
    def toRPC: RPCTypes.Canonical = canonicalToRPC(canonical)
  }


  implicit class RPCToCanonical(rpcCanonical: RPCTypes.Canonical) {
    def fromRPC: Canonical = canonicalFromRPC(rpcCanonical)
  }


  implicit class ImageBlobToRPC(imageBlob: ImageBlob) {
    def toRPC: RPCTypes.ImageBlob = imageBlobToRPC(imageBlob)
  }


  implicit class RPCToImageBlob(rpcBlob: RPCTypes.ImageBlob) {
    def fromRPC: ImageBlob = imageBlobFromRPC(rpcBlob)
  }


  implicit class PersonToRPC(person: Person) {
    def toRPC: RPCTypes.Person = personToRPC(person)
  }


  implicit class RPCToPerson(rpcPerson: RPCTypes.Person) {
    def fromRPC: Person = personFromRPC(rpcPerson)
  }


  implicit class RawMetadataBlobToRPC(raw: RawMetadataBlob) {
    def toRPC: RPCTypes.RawMetadataBlob = rawMetadataBlobToRPC(raw)
  }


  implicit class RPCToRawMetadataBlob(rpcRaw: RPCTypes.RawMetadataBlob) {
    def fromRPC: RawMetadataBlob = rawMetadataBlobFromRPC(rpcRaw)
  }


  def canonicalToRPC(canonical: Canonical): RPCTypes.Canonical =
    RPCTypes.Canonical(
      canonicalID = canonical.canonicalID,
      multiHash = canonical.multiHash.base58)


  def canonicalFromRPC(rpcCanonical: RPCTypes.Canonical) =
    Canonical(None, rpcCanonical.canonicalID)



  def imageBlobToRPC(imageBlob: ImageBlob): RPCTypes.ImageBlob =
    RPCTypes.ImageBlob(
      title = imageBlob.title,
      description = imageBlob.description,
      date = imageBlob.date,
      multiHash = imageBlob.multiHash.base58
    )


  def imageBlobFromRPC(rpcBlob: RPCTypes.ImageBlob): ImageBlob =
    ImageBlob(id = None,
      title = rpcBlob.title,
      description = rpcBlob.description,
      date = rpcBlob.date)


  def personToRPC(person: Person): RPCTypes.Person =
    RPCTypes.Person(
      name = person.name,
      multiHash = person.multiHash.base58)


  def personFromRPC(rpcPerson: RPCTypes.Person): Person =
    Person(id = None, name = rpcPerson.name)


  def rawMetadataBlobToRPC(raw: RawMetadataBlob): RPCTypes.RawMetadataBlob =
    RPCTypes.RawMetadataBlob(
      blob = raw.blob,
      multiHash = raw.multiHash.base58
    )

  def rawMetadataBlobFromRPC(rpcRaw: RPCTypes.RawMetadataBlob): RawMetadataBlob =
    RawMetadataBlob(None, blob = rpcRaw.blob)

  def metadataBlobToRPC(blob: MetadataBlob): RPCTypes.MetadataBlob =
    blob match {
      case image: ImageBlob => RPCTypes.MetadataBlob(
        blobType = RPCTypes.MetadataBlob.BlobType.ImageBlob,
        blob = RPCTypes.MetadataBlob.Blob.Image(image.toRPC))

      case person: Person => RPCTypes.MetadataBlob(
        blobType = RPCTypes.MetadataBlob.BlobType.Person,
        blob = RPCTypes.MetadataBlob.Blob.Person(person.toRPC))
{'fraction_non_alphanumeric': 0.08808844507845934, 'fraction_numerical': 0.0014265335235378032, 'mean_word_length': 4.094459582198001, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1690637', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1811, 'n_words': 331}