vendredi 1 mai 2015

Errors with If statement

Okay, so i am having some issues with my code. First the positive. Everything works as i want to. So firstly, i want my program to search a text file for some keyword or synonyms of the keyword. That works, but my issue lies with keywords that are not found. my if(found) statement never seems to be reached. I tried using debugger but i haven't seen what the issuse is.

    public static void main(String args[]) throws ParseException, IOException {
    /* Initialization */
    List<DicEntry> synonymMap = populateSynonymMap(); // populate the map

    Scanner scanner = new Scanner(System.in);
    String input = null;
    /* End Initialization */
    System.out.println("Welcome ");
    System.out.println("What would you like to know?");

    System.out.print("> ");
    input = scanner.nextLine().toLowerCase();
    String[] inputs = input.split(" ");

    for (String ing : inputs) {
        boolean found = false;

        for (DicEntry entry : synonymMap) { // iterate over each word of the
                                            // sentence.

            if (entry.pattern.matcher(input).matches()) {
                found = true;
                // System.out.println(entry.key);
                parseFile(entry.key);

                System.out
                        .println(" Would you like to update this information ? ");
                String yellow = scanner.nextLine();
                if (yellow.equals("yes")) {
                    removedata(entry.key);
                    break;
                }
                if (yellow.equals("no")) {

                    System.out.println("Have a good day");
                    break;
                }
            }


        if (found) {

                    Writer();


                // break;
            }

        }       
            // break;

}   



}
   }

Assume that the Writer(),removedata(),parsefile() methods work, can someone help?

Aucun commentaire:

Enregistrer un commentaire