<commit_before>package uk.ac.wellcome.platform.transformer.sierra.transformers.sierra.subjects

import org.scalatest.{FunSpec, Matchers}
import uk.ac.wellcome.platform.transformer.sierra.generators.SierraDataGenerators
import uk.ac.wellcome.platform.transformer.sierra.source.{MarcSubfield, VarField}

class SierraOrganisationSubjectsTest extends FunSpec with Matchers with SierraDataGenerators {
  it("returns an empty list if there are no instances of MARC tag 610") {
    val bibData = createSierraBibDataWith(varFields = List())
    transformer.getSubjectsWithOrganisation(bibData) shouldBe List()
  }

  it("uses subfields a, b, c, d and e as the label") {
    val bibData = createSierraBibDataWith(
      varFields = List(
        VarField(
          marcTag = "610",
          indicator1 = "",
          indicator2 = "",
          subfields = List(
            MarcSubfield(tag = "a", content = "United States."),
            MarcSubfield(tag = "b", content = "Supreme Court,"),
            MarcSubfield(tag = "c", content = "Washington, DC."),
            MarcSubfield(tag = "d", content = "September 29, 2005,"),
            MarcSubfield(tag = "e", content = "pictured.")
          )
        )
      )
    )

    val subjects = transformer.getSubjectsWithOrganisation(bibData)
    subjects should have size 1

    subjects.head.label shouldBe "United States. Supreme Court, Washington, DC. September 29, 2005, pictured."
  }

  it("uses repeated subfields for the label if necessary") {
    // This is based on an example from the MARC spec
    val bibData = createSierraBibDataWith(
      varFields = List(
        VarField(
          marcTag = "610",
          indicator1 = "",
          indicator2 = "",
          subfields = List(
            MarcSubfield(tag = "a", content = "United States."),
            MarcSubfield(tag = "b", content = "Army."),
            MarcSubfield(tag = "b", content = "Cavalry, 7th."),
            MarcSubfield(tag = "b", content = "Company E,"),
            MarcSubfield(tag = "e", content = "depicted.")
          )
        )
      )
    )

    val subjects = transformer.getSubjectsWithOrganisation(bibData)
    subjects should have size 1

    subjects.head.label shouldBe "United States. Army. Cavalry, 7th. Company E, depicted."
  }

  val transformer = new SierraOrganisationSubjects {}
}<commit_msg>Add a helper method to clean up the tests<commit_after>package uk.ac.wellcome.platform.transformer.sierra.transformers.sierra.subjects

import org.scalatest.{FunSpec, Matchers}
import uk.ac.wellcome.platform.transformer.sierra.generators.SierraDataGenerators
import uk.ac.wellcome.platform.transformer.sierra.source.{MarcSubfield, VarField}

class SierraOrganisationSubjectsTest extends FunSpec with Matchers with SierraDataGenerators {
  it("returns an empty list if there are no instances of MARC tag 610") {
    val bibData = createSierraBibDataWith(varFields = List())
    transformer.getSubjectsWithOrganisation(bibData) shouldBe List()
  }

  it("uses subfields a, b, c, d and e as the label") {
    val bibData = createSierraBibDataWith(
      varFields = List(
        createMarc610VarField(
          subfields = List(
            MarcSubfield(tag = "a", content = "United States."),
            MarcSubfield(tag = "b", content = "Supreme Court,"),
            MarcSubfield(tag = "c", content = "Washington, DC."),
            MarcSubfield(tag = "d", content = "September 29, 2005,"),
            MarcSubfield(tag = "e", content = "pictured.")
          )
        )
      )
    )

    val subjects = transformer.getSubjectsWithOrganisation(bibData)
    subjects should have size 1

    subjects.head.label shouldBe "United States. Supreme Court, Washington, DC. September 29, 2005, pictured."
  }

  it("uses repeated subfields for the label if necessary") {
    // This is based on an example from the MARC spec
    val bibData = createSierraBibDataWith(
      varFields = List(
        createMarc610VarField(
          subfields = List(
            MarcSubfield(tag = "a", content = "United States."),
            MarcSubfield(tag = "b", content = "Army."),
            MarcSubfield(tag = "b", content = "Cavalry, 7th."),
            MarcSubfield(tag = "b", content = "Company E,"),
            MarcSubfield(tag = "e", content = "depicted.")
          )
        )
      )
    )

    val subjects = transformer.getSubjectsWithOrganisation(bibData)
    subjects should have size 1

    subjects.head.label shouldBe "United States. Army. Cavalry, 7th. Company E, depicted."
  }

  val transformer = new SierraOrganisationSubjects {}

  private def createMarc610VarField(subfields: List[MarcSubfield]): VarField =
    VarField(
      marcTag = "610",
      indicator1 = "",
      indicator2 = "",
      subfields = subfields
    )
}
{'fraction_non_alphanumeric': 0.10732929630403007, 'fraction_numerical': 0.012946335351847985, 'mean_word_length': 2.8015873015873014, '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': '1701519', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1379, 'n_words': 374}