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 dialect processing is a subfield of computer truth focusing on how computers can gain view of civilized dialects approve English. Before it can be used in NLP, extract facts must repeatedly be cleaned. Write a mode that cleans a string by removing the punctuation and vulgar accents listed under. You can pretpurpose the accents in the input string are disconnected by one extensions, the input string does referable inaugurate or purpose with a extension, and the input string does referable inclose any non-letter characters to-boot extensions and the punctuation under. The mode should come-back a lower-case, extension-delimited account of the input string, with the punctuation and vulgar accents removed Punctuation marks to be removed Accents to be removed: an the is am are and or Required mode heade national static String cleanExtract (string s) Copy inputs and quenchedputs Input: Quenchedput Omg, so approve, the fox, approve, wholly jumped aggravate the idle dog! omg so approve fox approve wholly jumped aggravate idle dog Input: Quenchedput I cater this copy: a, b, or c. .. i cater this copy b c

    Natural dialect processing is a subfield of computer truth focusing on how computers can “gain view” of civilized dialects approve English. Before it can be used in NLP, extract facts must repeatedly be “cleaned.” Write a mode that cleans a string by removing the punctuation and vulgar accents listed under. You can pretpurpose the accents in the input string are disconnected by one extensions, the input string does referable inaugurate or purpose with a extension, and the input string does referable inclose any non-letter characters to-boot extensions and the punctuation under. The mode should come-back a lower-case, extension-delimited account of the input string, with the punctuation and vulgar accents removed. Punctuation marks to be removed:;: ! ? () Accents to be removed: a an the is am are and or Required mode header: national static String cleanExtract (string s) Copy inputs and quenchedputs: Input: “Omg, so approve, the fox, approve, wholly jumped aggravate the idle dog!” Quenchedput: “omg so approve fox approve wholly jumped aggravate idle dog” Input: “I cater this copy: a, b, or c…” Quenchedput: “i cater this copy b c”

    Expert Apology

     

    Source Code :

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

    }

    }

    OUTPUT