Mein Code gibt "zach" in ein separates Array aus. Mein "isNonStopWord" sucht, ob eines der Wörter in skoal in "zach" erscheint. Wenn sie es tun, wird neben diesen Wörtern, die in beiden erscheinen und neben jedem Wort in "zach", das nicht in "scoal" steht, false zurückgegeben. Alles, was ich jetzt zu tun versuche, ist es, alle Wörter, die falsch waren, in ihre zu setzen eigene Array und ich kann nicht herausfinden, wie es geht. Wenn Sie eine Idee haben, lassen Sie es mich bitte wissen.Setzen Sie die Variablen, die false zurückgegeben haben, in ihr eigenes Array.
package zk;
import java.util.Arrays;
public class Class {
public boolean isNonStopWord(String x, String[] y) {
if (Arrays.asList(y).contains(x)) {
return false;
}
return true;
}
public static void main(String [] args) {
Class cs = new Class();
String zach = ("Amazon offered up more answers Thursday about what"
+ " caused a bunch of websites to fail two days ago. According "
+ "to a postmortem by the company's cloud services business, "
+ "around 9:37 a.m. PT Tuesday an Amazon worker incorrectly"
+ " punched in a command while trying to debug an issue. "
+ "That command shut down a large set of servers at Amazon Web "
+ "Services' Northern Virginia site, causing a domino effect of"
+ " problems. Other services that relied on those S3 cloud"
+ " storage servers were disrupted. Also, removing so much "
+ "server capacity required a full system restart, which then "
+ "took longer than expected, AWS said. The sites affected "
+ "included Quora, Imgur, IFTTT, Giphy and Slack. Amazon was "
+ "able to fix the issue by about 2 p.m. PT.");
String [] skoal = {"THE", "BE", "TO", "OF", "AND", "A", "IN",
"THAT", "I", "IT", "ON", "IN", "BUT", "IS", "WITH"};
zach = zach.replace(",","");
zach = zach.replace(".","");
zach = zach.toUpperCase();
String [] strings = zach.split(" ");
int july = 0;
for (String s1: strings)
{
boolean answer = cs.isNonStopWord(s1,skoal);
System.out.println((s1) + " " + (answer));
if(answer==false){
july++;
}
}
System.out.println("There are " + july +" " + "non-stop words");
zach = "...";
}
Ich fürchte, Sie könnten Ihre Zeit verschwendet haben. Lesen Sie [Elliott Frischs Kommentar] (https://stackoverflow.com/questions/43152066#comment73380873\_43152066) --- es besteht eine gute Chance, dass diese Frage (und dieser Benutzer) bald gelöscht wird. (Ich, für einen, habe es für die Aufmerksamkeit des Moderators markiert.) –