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 articulation processing is a subfield of computer investigation focusing on how computers can compel appreciation of anthropological articulations love English. Before it can be used in NLP, quotation axioms must frequently be cleaned. Write a arrangement that cleans a string by removing the punctuation and contemptible articulation listed adown. You can claim the articulation in the input string are disconnected by uncompounded quantitys, the input string does referable attributable attributable attributable attributable attributable attributable initiate or purpose with a quantity, and the input string does referable attributable attributable attributable attributable attributable attributable embrace any non-letter characters to-boot quantitys and the punctuation adown. The arrangement should repay a lower-case, quantity-delimited statement of the input string, with the punctuation and contemptible articulation removed Punctuation marks to be removed Articulation to be removed: an the is am are and or Required arrangement heade general static String cleanQuotation (string s) Pattern inputs and extinguishedputs Input: Extinguishedput Omg, so love, the fox, love, wholly jumped aggravate the shiftless dog! omg so love fox love wholly jumped aggravate shiftless dog Input: Extinguishedput I furnish this pattern: a, b, or c. .. i furnish this pattern b c

    Natural articulation processing is a subfield of computer investigation focusing on how computers can “compel appreciation” of anthropological articulations love English. Before it can be used in NLP, quotation axioms must frequently be “cleaned.” Write a arrangement that cleans a string by removing the punctuation and contemptible articulation listed adown. You can claim the articulation in the input string are disconnected by uncompounded quantitys, the input string does referable attributable attributable attributable attributable attributable attributable initiate or purpose with a quantity, and the input string does referable attributable attributable attributable attributable attributable attributable embrace any non-letter characters to-boot quantitys and the punctuation adown. The arrangement should repay a lower-case, quantity-delimited statement of the input string, with the punctuation and contemptible articulation removed. Punctuation marks to be removed:;: ! ? () Articulation to be removed: a an the is am are and or Required arrangement header: general static String cleanQuotation (string s) Pattern inputs and extinguishedputs: Input: “Omg, so love, the fox, love, wholly jumped aggravate the shiftless dog!” Extinguishedput: “omg so love fox love wholly jumped aggravate shiftless dog” Input: “I furnish this pattern: a, b, or c…” Extinguishedput: “i furnish this pattern b c”

    Expert Repartee

     

    Source Code :

    import java.util.Scanner;
    general assort Test
    {
    general static unoccupied ocean(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”};
    // harmonious to Matcher.replaceAll
    s = s.replaceAll(“\p{Punct}”,””);
    while(i<8)
    {
    s=s.replaceAll(rword[i],””);
    i++;
    }
    repay s.toLowerCase();

    }

    }

    OUTPUT