diff -r 6e93040e3378 -r cdfa6a293453 core_templates2/docdiff.scala --- a/core_templates2/docdiff.scala Sat Oct 08 00:30:51 2022 +0100 +++ b/core_templates2/docdiff.scala Tue Nov 01 15:03:48 2022 +0000 @@ -4,44 +4,23 @@ object C2 { +// ADD YOUR CODE BELOW +//====================== -//(1) Complete the clean function below. It should find -// all words in a string using the regular expression -// \w+ and the library function -// -// some_regex.findAllIn(some_string) -// -// The words should be Returned as a list of strings. - - +//(1) def clean(s: String) : List[String] = ??? -//(2) The function occurrences calculates the number of times -// strings occur in a list of strings. These occurrences should -// be calculated as a Map from strings to integers. - - +//(2) def occurrences(xs: List[String]): Map[String, Int] = ??? -//(3) This functions calculates the dot-product of two documents -// (list of strings). For this it calculates the occurrence -// maps from (2) and then multiplies the corresponding occurrences. -// If a string does not occur in a document, the product is zero. -// The function finally sums up all products. - - +//(3) def prod(lst1: List[String], lst2: List[String]) : Int = ??? -//(4) Complete the functions overlap and similarity. The overlap of -// two documents is calculated by the formula given in the assignment -// description. The similarity of two strings is given by the overlap -// of the cleaned strings (see (1)). - - +//(4) def overlap(lst1: List[String], lst2: List[String]) : Double = ??? def similarity(s1: String, s2: String) : Double = ???