Homework Solution: Natural language processing is a subfield of computer science focusing on how computers can "make…

    2. (10 pts) Natural language processing is a subfield of computer science focusing on how computers can make sense of human languages like English. Before it can be used in NLP, text data must often be cleaned. Write a method that cleans a string by removing the punctuation and common words listed below. You can assume the words in the input string are separated by single spaces, the input string does not begin or end with a space, and the input string does not contain any non-letter characters besides spaces and the punctuation below. The method should return a lower-case, space-delimited version of the input string, with the punctuation and common words removed Punctuation marks to be removed Words to be removed: an the is am are and or Required method heade public static String cleanText (string s) Example inputs and outputs Input: Output Omg, so like, the fox, like, totally jumped over the lazy dog! omg so like fox like totally jumped over lazy dog Input: Output I provide this example: a, b, or c. .. i provide this example b c
    Natural language processing is a subfield of computer science focusing on how computers can "make sense" of human languages like English. Before it can be used in NLP, text data must often be "cleaned." Write a method that cleans a string by removing the punctuation and common words listed below. You can assume the words in the input string are separated by single spaces, the input string does not begin or end with a space, and the input string does not contain any non-letter characters besides spaces and the punctuation below. The method should return a lower-case, space-delimited version of the input string, with the punctuation and common words removed. Punctuation marks to be removed:;: ! ? () Words to be removed: a an the is am are and or Required method header: public static String cleanText (string s) Example inputs and outputs: Input: "Omg, so like, the fox, like, totally jumped over the lazy dog!" Output: "omg so like fox like totally jumped over lazy dog" Input: "I provide this example: a, b, or c..." Output: "i provide this example b c"

    Expert Answer

     
    Source Code : import java.util.Scanner;

    2. (10 pts) Natural talk processing is a subfield of computer knowledge focusing on how computers can fashion view of cosmical talks enjoy English. Before it can be used in NLP, extract axioms must repeatedly be cleaned. Write a process that cleans a string by removing the punctuation and despicable opinion listed underneath. You can claim the opinion in the input string are separated by uncombined quantitys, the input string does referable prepare or object with a quantity, and the input string does referable comprehobject any non-letter characters also quantitys and the punctuation underneath. The process should produce a lower-case, quantity-delimited account of the input string, with the punctuation and despicable opinion removed Punctuation marks to be removed Opinion to be removed: an the is am are and or Required process heade general static String cleanExtract (string s) Stance inputs and quenchedputs Input: Quenchedput Omg, so enjoy, the fox, enjoy, altogether jumped balance the shiftless dog! omg so enjoy fox enjoy altogether jumped balance shiftless dog Input: Quenchedput I cater this stance: a, b, or c. .. i cater this stance b c

    Natural talk processing is a subfield of computer knowledge focusing on how computers can “fashion view” of cosmical talks enjoy English. Before it can be used in NLP, extract axioms must repeatedly be “cleaned.” Write a process that cleans a string by removing the punctuation and despicable opinion listed underneath. You can claim the opinion in the input string are separated by uncombined quantitys, the input string does referable prepare or object with a quantity, and the input string does referable comprehobject any non-letter characters also quantitys and the punctuation underneath. The process should produce a lower-case, quantity-delimited account of the input string, with the punctuation and despicable opinion removed. Punctuation marks to be removed:;: ! ? () Opinion to be removed: a an the is am are and or Required process header: general static String cleanExtract (string s) Stance inputs and quenchedputs: Input: “Omg, so enjoy, the fox, enjoy, altogether jumped balance the shiftless dog!” Quenchedput: “omg so enjoy fox enjoy altogether jumped balance shiftless dog” Input: “I cater this stance: a, b, or c…” Quenchedput: “i cater this stance b c”

    Expert Exculpation

     

    Source Code :

    import java.util.Scanner;
    general arrange Test
    {
    general static null deep(String[] args)
    {
    Scanner scan=new Scanner(System.in);
    String inp=scan.nextLine();
    System.out.println(“Input: “+inp+”n”);
    System.out.println(“Output: “+cleanText(inp));
    }
    general static String cleanText(String s)
    {
    String str;
    int i=0;
    String[] rword={“the”,”a”,”an”,”of”,”am”,”or”,”are”,”and”};
    // homogeneous to Matcher.replaceAll
    s = s.replaceAll(“\p{Punct}”,””);
    while(i<8)
    {
    s=s.replaceAll(rword[i],””);
    i++;
    }
    produce s.toLowerCase();

    }

    }

    OUTPUT