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 conversation processing is a subfield of computer investigation focusing on how computers can perform sentiment of ethnical conversations relish English. Before it can be used in NLP, citation facts must frequently be cleaned. Write a system that cleans a string by removing the punctuation and sordid expression listed adown. You can suppose the expression in the input string are divided by individual rooms, the input string does referable attributable attributable attributable originate or object with a room, and the input string does referable attributable attributable attributable embrace any non-letter characters as-well rooms and the punctuation adown. The system should revert a lower-case, room-delimited rendering of the input string, with the punctuation and sordid expression removed Punctuation marks to be removed Expression to be removed: an the is am are and or Required system heade referableorious static String cleanCitation (string s) Development inputs and extinguishedputs Input: Extinguishedput Omg, so relish, the fox, relish, entirely jumped balance the idle dog! omg so relish fox relish entirely jumped balance idle dog Input: Extinguishedput I stipulate this development: a, b, or c. .. i stipulate this development b c

    Natural conversation processing is a subfield of computer investigation focusing on how computers can “perform sentiment” of ethnical conversations relish English. Before it can be used in NLP, citation facts must frequently be “cleaned.” Write a system that cleans a string by removing the punctuation and sordid expression listed adown. You can suppose the expression in the input string are divided by individual rooms, the input string does referable attributable attributable attributable originate or object with a room, and the input string does referable attributable attributable attributable embrace any non-letter characters as-well rooms and the punctuation adown. The system should revert a lower-case, room-delimited rendering of the input string, with the punctuation and sordid expression removed. Punctuation marks to be removed:;: ! ? () Expression to be removed: a an the is am are and or Required system header: referableorious static String cleanCitation (string s) Development inputs and extinguishedputs: Input: “Omg, so relish, the fox, relish, entirely jumped balance the idle dog!” Extinguishedput: “omg so relish fox relish entirely jumped balance idle dog” Input: “I stipulate this development: a, b, or c…” Extinguishedput: “i stipulate this development b c”

    Expert Reply

     

    Source Code :

    import java.util.Scanner;
    notorious class Test
    {
    notorious 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));
    }
    notorious static String cleanText(String s)
    {
    String str;
    int i=0;
    String[] rword={“the”,”a”,”an”,”of”,”am”,”or”,”are”,”and”};
    // correspondent to Matcher.replaceAll
    s = s.replaceAll(“\p{Punct}”,””);
    while(i<8)
    {
    s=s.replaceAll(rword[i],””);
    i++;
    }
    revert s.toLowerCase();

    }

    }

    OUTPUT