<commit_before>package services

import org.scalatest.{Matchers, WordSpec}
import scala.io.Source
import java.net.URI
import play.api.libs.json._
import play.api.libs.functional.syntax._

class OSAddressbasePostcodeResponseSpec extends WordSpec with Matchers {

  def getResource(name: String) = Source.fromURL(this.getClass.getResource(s"/$name")).mkString("")

  implicit val uriReads: Reads[URI] = new Reads[URI] {
    override def reads(json: JsValue) = JsSuccess(new URI(json.as[String]))
  }

  case class OSAddressbaseDPA(
                               UPRN: String,
                               address: String,
                               poBoxNumber: Option[String],
                               organisationName: Option[String],
                               departmentName: Option[String],
                               subBuildingName: Option[String],
                               buildingName: Option[String],
                               buildingNumber: Option[String],
                               dependentThoroughfareName: Option[String],
                               thoroughfareName: Option[String],
                               doubleDependentLocality: Option[String],
                               dependentLocality: Option[String],
                               postTown: String,
                               postCode: String,
                               RPC: String,
                               xCordinate: Float,
                               yCordinate: Float,
                               status: String,
                               matchScore: Float,
                               matchDescription: String
                               )

  object OSAddressbaseDPA {
    implicit val reads: Reads[OSAddressbaseDPA] = (
      (__ \ "UPRN").read[String] and
        (__ \ "ADDRESS").read[String] and
        (__ \ "PO_BOX_NUMBER").readNullable[String] and
        (__ \ "ORGANISATION_NAME").readNullable[String] and
        (__ \ "DEPARTMEMT_NAME").readNullable[String] and
        (__ \ "SUB_BUILDING_NAME").readNullable[String] and
        (__ \ "BUILDING_NAME").readNullable[String] and
        (__ \ "BUILDING_NUMBER").readNullable[String] and
        (__ \ "DEPENDENT_THOROUGHFARE_NAME").readNullable[String] and
        (__ \ "THOROUGHFARE_NAME").readNullable[String] and
        (__ \ "DOUBLE_DEPENDENT_LOCALITY").readNullable[String] and
        (__ \ "DEPENDENT_LOCALITY").readNullable[String] and
        (__ \ "POST_TOWN").read[String] and
        (__ \ "POSTCODE").read[String] and
        (__ \ "RPC").read[String] and
        (__ \ "X_COORDINATE").read[Float] and
        (__ \ "Y_COORDINATE").read[Float] and
        (__ \ "STATUS").read[String] and
        (__ \ "MATCH").read[Float] and
        (__ \ "MATCH_DESCRIPTION").read[String]
      )(OSAddressbaseDPA.apply _)
  }

  case class OSAddressbaseResult(
                                  DPA: OSAddressbaseDPA
                                  )


  case class OSAddressbaseHeader(
                                  uri: URI,
                                  query: String,
                                  offset: Int,
                                  totalresults: Int,
                                  format: String,
                                  dataset: String,
                                  maxresults: Int
                                  )

  case class OSAddressbaseSearchResponse(
                                          header: OSAddressbaseHeader,
                                          results: Option[Seq[OSAddressbaseResult]]
                                          )

  "Response Parser loading json for ec1a 4jq" should {
    //implicit val readsOSAddressbaseDpa = Json.reads[OSAddressbaseDpa]
    implicit val readsOSAddressbaseResult = Json.reads[OSAddressbaseResult]
    implicit val readsOSAddressbaseHeader = Json.reads[OSAddressbaseHeader]<commit_msg>OS made POSO for result LPI<commit_after>package services

import org.scalatest.{Matchers, WordSpec}
import scala.io.Source
import java.net.URI
import play.api.libs.json._
import play.api.libs.functional.syntax._

class OSAddressbasePostcodeResponseSpec extends WordSpec with Matchers {

  def getResource(name: String) = Source.fromURL(this.getClass.getResource(s"/$name")).mkString("")

  implicit val uriReads: Reads[URI] = new Reads[URI] {
    override def reads(json: JsValue) = JsSuccess(new URI(json.as[String]))
  }

  case class OSAddressbaseDPA(
                               UPRN: String,
                               address: String,
                               poBoxNumber: Option[String],
                               organisationName: Option[String],
                               departmentName: Option[String],
                               subBuildingName: Option[String],
                               buildingName: Option[String],
                               buildingNumber: Option[String],
                               dependentThoroughfareName: Option[String],
                               thoroughfareName: Option[String],
                               doubleDependentLocality: Option[String],
                               dependentLocality: Option[String],
                               postTown: String,
                               postCode: String,
                               RPC: String,
                               xCordinate: Float,
                               yCordinate: Float,
                               status: String,
                               matchScore: Float,
                               matchDescription: String
                               )

  object OSAddressbaseDPA {
    implicit val reads: Reads[OSAddressbaseDPA] = (
      (__ \ "UPRN").read[String] and
        (__ \ "ADDRESS").read[String] and
        (__ \ "PO_BOX_NUMBER").readNullable[String] and
        (__ \ "ORGANISATION_NAME").readNullable[String] and
        (__ \ "DEPARTMEMT_NAME").readNullable[String] and
        (__ \ "SUB_BUILDING_NAME").readNullable[String] and
        (__ \ "BUILDING_NAME").readNullable[String] and
        (__ \ "BUILDING_NUMBER").readNullable[String] and
        (__ \ "DEPENDENT_THOROUGHFARE_NAME").readNullable[String] and
        (__ \ "THOROUGHFARE_NAME").readNullable[String] and
        (__ \ "DOUBLE_DEPENDENT_LOCALITY").readNullable[String] and
        (__ \ "DEPENDENT_LOCALITY").readNullable[String] and
        (__ \ "POST_TOWN").read[String] and
        (__ \ "POSTCODE").read[String] and
        (__ \ "RPC").read[String] and
        (__ \ "X_COORDINATE").read[Float] and
        (__ \ "Y_COORDINATE").read[Float] and
        (__ \ "STATUS").read[String] and
        (__ \ "MATCH").read[Float] and
        (__ \ "MATCH_DESCRIPTION").read[String]
      )(OSAddressbaseDPA.apply _)
  }


  case class OSAddressbaseLPI(
                               UPRN: String,
                               ADDRESS: String,
                               USRN: String,
                               LPI_KEY : String,
                               LEVEL : Option[String],
                               ORGANISATION : String,
                               SAO_START_NUMBER : Option[String],
                               SAO_START_SUFFIX : Option[String],
                               SAO_END_NUMBER : Option[String],
                               SAO_END_SUFFIX : Option[String],
                               PAO_START_NUMBER : Option[String],
                               PAO_START_SUFFIX : Option[String],
                               PAO_END_NUMBER : Option[String],
                               PAO_END_SUFFIX : Option[String],
                               STREET_DESCRIPTION : String,
                               LOCALITY_NAME : Option[String],
                               TOWN_NAME : Option[String]
                               )

  object OSAddressbaseLPI {
    implicit val readsOSAddressbaseLPI = Json.reads[OSAddressbaseLPI]
  }


  case class OSAddressbaseResult(
                                  DPA: Option[OSAddressbaseDPA]
                                  )

  case class OSAddressbaseHeader(
                                  uri: URI,
                                  query: String,
                                  offset: Int,
                                  totalresults: Int,
                                  format: String,
                                  dataset: String,
                                  maxresults: Int
                                  )

  case class OSAddressbaseSearchResponse(
                                          header: OSAddressbaseHeader,
                                          results: Option[Seq[OSAddressbaseResult]]
                                          )

  "Response Parser loading json for ec1a 4jq" should {
    implicit val readsOSAddressbaseResult = Json.reads[OSAddressbaseResult]
    implicit val readsOSAddressbaseHeader = Json.reads[OSAddressbaseHeader]
{'fraction_non_alphanumeric': 0.08166221033868093, 'fraction_numerical': 0.000445632798573975, 'mean_word_length': 1.3094931824028815, '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': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '799906', 'n_tokens_mistral': 2185, 'n_tokens_neox': 2145, 'n_words': 389}