Question: import java.util.Set; public class SetUtilities { /** * Returns a new set representing the union of s and t. * * Does not modify s

import java.util.Set;

public class SetUtilities {

/**

* Returns a new set representing the union of s and t.

*

* Does not modify s or t.

* @param s

* @param t

* @return a new set representing the union of s and t

*/

public static Set union(Set s, Set t) {

}

/**

* Returns a new set representing the intersection of s and t.

*

* Does not modify s or t.

* @param s

* @param t

* @return a new set representing the intersection of s and t

*/

public static Set intersection(Set s, Set t) {

}

/**

* Returns a new set representing the set difference s and t,

* that is, s \ t.

*

* Does not modify s or t.

* @param s

* @param t

* @return a new set representing the difference of s and t

*/

public static Set setDifference(Set s, Set t) {

}

/**

* Returns the Jaccard index of the two sets s and t.

*

* It is defined as 1 if both sets are empty.

*

* Otherwise, it is defined as the size of the intersection of the sets,

* divided by the size of the union of the sets.

*

* Does not modify s or t.

*

* @param s

* @param t

* @return the Jaccard index of s and t

*/

public static double jaccardIndex(Set s, Set t) {

}

} =======================================================================

import java.util.List;

import java.util.Set;

public class SimilarityUtilities {

/**

* Returns the set of non-empty lines contained in a text, trimmed of

* leading and trailing whitespace.

*

* @param text

* @return the trimmed set of lines

*/

public static Set trimmedLines(String text) {

return null;

}

/**

* Returns a list of words in the text, in the order they appeared in the text,

* converted to lowercase.

*

* Words are defined as a contiguous sequence of letters and numbers.

*

* @param text

* @return a list of lowercase words

*/

public static List asLowercaseWords(String text) {

return null;

}

/**

* Returns the line-based similarity of two texts.

*

* The line-based similarity is the Jaccard index between each text's line

* set.

*

* A text's line set is the set of trimmed lines in that text, as defined by

* trimmedLines.

*

* @param text1

* a text

* @param text2

* another text

* @return

*/

public static double lineSimilarity(String text1, String text2) {

return -1.0;

}

/**

* Returns the line-based similarity of two texts.

*

* The line-based similarity is the Jaccard index between each text's line

* set.

*

* A text's line set is the set of trimmed lines in that text, as defined by

* trimmedLines, less the set of trimmed lines from the templateText. Removes

* the template text from consideration after trimming lines, not before.

*

* @param text1

* a text

* @param text2

* another text

* @param templateText

* a template, representing things the two texts have in common

* @return

*/

public static double lineSimilarity(String text1, String text2, String templateText) {

return -1.0;

}

/**

* Returns a set of strings representing the shingling of the given length

* of a list of words.

*

* A shingling of length k of a list of words is the set of all k-shingles

* of that list.

*

* A k-shingle is the concatenation of k adjacent words.

*

* For example, a 3-shingle of the list: ["a" "very" "fine" "young" "man"

* "I" "know"] is the set: {"averyfine" "veryfineyoung" "fineyoungman"

* "youngmanI" "manIknow"}.

*

* @param words

* @param shingleLength

* @return

*/

public static Set shingle(List words, int shingleLength) {

return null;

}

/**

* Returns the shingled word similarity of two texts.

*

* The shingled word similarity is the Jaccard index between each text's

* shingle set.

*

* A text's shingle set is the set of shingles (of the given length) for the

* entire text, as defined by shingle and asLowercaseWords,

* less the shingle set of the templateText. Removes the templateText

* from consideration after shingling, not before.

*

* @param text1

* @param text2

* @param templateText

* @param shingleLength

* @return

*/

public static double shingleSimilarity(String text1, String text2, String templateText, int shingleLength) {

return -1.0;

}

}

1. Translate written descriptions of behavior into code. 2. String.split 3. implement the shingleSimilarity method, which parallels the second lineSimilarity method

Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!