Keyword classification in Scala... simple?
The posted code won't compile without a working definition of Keyword and PrepKeyword. And type is a reserved word so kwd.type isn't allowed (might be version dependent).
The code, as presented, is inconsistent or just plain wrong in its indenting but, other than that, it's reasonably clear in intent and presentation.
The logic is, perhaps, overly convoluted. I found that I had to go back and forth to see how output was built from input. I eventually decided that kwd.name was the key value from which most everything else flows. With that in mind I tried to rebuild the logic.
def preprocess(kwd: Keyword): Option[PrepKeyword] = {
  val fooName = &quot;(?i)(foo)&quot;.r
  kwd.name.flatMap{
    case &quot;name1&quot;      =&gt; None
    case &quot;myCategory&quot; =&gt;
      kwd.typ match {
        case 1 =&gt; Some(PrepKeyword(kwd, &quot;GreatCategory&quot;, &quot;Foo2&quot;))
        case 2 =&gt; Some(PrepKeyword(kwd, &quot;myCategory&quot;, &quot;Foo2&quot;))
        case _ =&gt; None
      }
    case fooName(fnm) =&gt; Some(PrepKeyword(kwd, fnm, &quot;Foo1&quot;))
    case nonFoo       =&gt; Some(PrepKeyword(kwd, nonFoo, &quot;Foo2&quot;))
  }
}

This, according to my tests so far, produces the same results. It builds the output in multiple places but in each case it's pretty easy to see how the input directed the output.