Domanda

Sto cercando di scrivere un codice per rimuovere le parole degli stop come "il", "questo" in un elenco di stringhe ecc.

Ho scritto questo codice:

let rec public stopword (a : string list, b :string list) =

    match [a.Head] with
        |["the"]|["this"] -> stopword (a.Tail, b)
        |[] -> b
        |_ ->  stopword (a.Tail, b@[a.Head])

L'ho eseguito nell'interattivo:

stopword (["this";"is";"the"], []);;

Ho ricevuto questo errore:

This expression was expected to have type string list but here has type 'a * 'b

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top