Buggy code:
@ Getter @ NoArgsConstructor ( access = AccessLevel . PRIVATE ) public class Chatbot { private Logger log = LoggerFactory . getLogger ( Chatbot . class ) ; public Brain brain ; private User user ; private String chatbotName = "Eustachy" ; private Conversation conversation = new Conversation ( chatbotName ) ; public Chatbot ( Brain brain ) { } public Chatbot ( Brain brain , User user ) { } public String commentMood ( ) { } public String catchUserAge ( ) { } public void catchUserMood ( ) { } public String catchUserName ( ) { } public void updateInformationAboutUser ( String answer ) { } private void tryToCatchUserGender ( String answer ) { } public void updatePersonality ( String answer ) { } private Set < String > convertToMainWords ( String [ ] userWords ) { } private String removeMatchingPhraseFromSentence ( String userSentence , PersonalityRecognizer . Phrase phrase ) { } private void updatePersonalities ( List < PersonalityId > ids ) { } private Gender getGender ( String name ) { } public String prepareAnswer ( String lastAnswer ) throws Exception { } private boolean mentionPersonality ( int chooseAnswer ) { } private String prepareAnswerReferringPersonality ( ) { } private String getChatbotAnswerForExclamation ( ) { } private String getAnswerForStadardDialog ( String userAnswerToLowerCaseWithoutPolishChars ) { } private String tryToGetLastChatbotAnswer ( ) { } private String answerForStandardDialog ( String userAnswerToLowerCaseWithoutPolishChars ) { } private String getChatbotAnswerFromChatbotPatterns ( int userAnswerNote ) throws NotFoundExceptionAnswer { } private String answerForSingleWord ( String userAnswer ) throws NotFoundExceptionAnswer , NotFoundResponseForOneWordAnswer { } public String getChatbotResponseForFeelingSentence ( String userAnswer ) throws NotFoundResponsesForFeelingSentence { } private String tryAnswerForOpinionQuestion ( String sentenceWithReplacedQuestionMarks ) throws NotFoundResponsesForOpinionQuestion , UnrecognizedUserAnswerException { } public String answerQuestion ( String userAnswer ) { } private boolean isAnswerForBackQuestion ( String sentenceWithReplacedQuestionMarks ) { } private boolean isPersonalQuestion ( String sentenceWithReplacedQuestionMarks ) { } public String getAnswerForQuestion ( String sentenceWithReplacedQuestionMarks ) throws NotFoundExceptionAnswer { } private List < String > removeConjuctionFromBeginingOfQuestion ( String [ ] wordsInSentence ) { } private String answerForQuestionAboutOpinion ( String sentenceWithReplacedQuestionMarks , String opinionVerb ) throws NotFoundResponsesForOpinionQuestion , UnrecognizedUserAnswerException { } private String pharapraseQuestion ( String sentenceWithReplacedQuestionMarks , String opinionVerb ) throws UnrecognizedUserAnswerException { } private String questionAboutOpinion ( String sentenceWithReplacedQuestionMarks ) { } private boolean verbIsInDictionary ( String word ) { } private boolean verbIsInPerson ( String word , GrammaPerson grammaPerson ) { } public String paraphrase ( String userAnswer , boolean addBeginParaphrase ) { } private String changePronouns ( String answer ) { } private String changeToOpposite ( String word ) { } private Map < Integer , String > findVerbsRightToParaphrasize ( List < String > words ) { } private String createPharaprasizedAnswer ( List < String > words , Map < Integer , String > mapIndexToChangedVerb , String begin ) { } private StringBuffer negativeSentence ( String [ ] words , Map < Integer , String > mapIndexToChangedVerb ) { } private StringBuffer changeVerbsIntoOpposite ( List < String > words , Map < Integer , String > mapIndexToChangedVerb , int firstVerb ) { } private String [ ] divideIntoSentences ( String userAnswer , String [ ] ar ) { } private String findPharaprasizedVerbIfVerbIsInDictionary ( String word ) { } private void addRestOfUserAnswerToChatbotAnswer ( String [ ] words , int j , StringBuffer sb ) { } private void prepareBeginningOfChatbotAnswer ( String changedVerb , boolean negation , StringBuffer sb ) { } private Record findRecordWithVerbInDictionary ( String userAnswer ) { } private Record getOppositePersonVerb ( PolishDictionary . Record record ) { } public String getChatbotAnswerFromAnswerPatterns ( int userAnswerNote ) throws NotFoundExceptionAnswer { } private String getRandomExceptionAnswer ( ) throws NotFoundExceptionAnswer { } public int catchUserAnswerNote ( String userAnswer ) { int noteSum = 0 ; int weights = 0 ; int average = 0 ; String tempAnswer = userAnswer ; try { for ( PatternAnswer pattern : brain . getComplexPatterns ( ) ) { <START_BUG> if ( ( PreprocessString . computeLevenshteinDistance ( tempAnswer , pattern . getSentence ( ) ) ) < 2 ) { <END_BUG> noteSum += ( pattern . getImportance ( ) ) * ( pattern . getNote ( ) ) ; weights += pattern . getImportance ( ) ; tempAnswer = tempAnswer . replace ( pattern . getSentence ( ) , "" ) ; updateTopicsAndLcu ( pattern ) ; } } String [ ] splittedWords = tempAnswer . split ( "<seq2seq4repair_space>" ) ; for ( String word : splittedWords ) { PatternAnswer oneWord = brain . getOneWordPattern ( word ) ; if ( oneWord != null ) { noteSum += ( oneWord . getImportance ( ) ) * ( oneWord . getNote ( ) ) ; weights += oneWord . getImportance ( ) ; tempAnswer = tempAnswer . replace ( oneWord . getSentence ( ) , "" ) ; updateTopicsAndLcu ( oneWord ) ; } } if ( weights != 0 ) { average = noteSum // weights ; } else { return - 1 ; } return average ; } catch ( Exception e ) { System . out . println ( e ) ; } return average ; } private void updateTopicsAndLcu ( PatternAnswer pattern ) { } public boolean isUserTurn ( ) { } public String getLastAnswer ( ) { } public void addUserAnswer ( String s ) { } public void answer ( ) throws Exception { } public List < String > getConversationCourse ( ) { } public String getUserName ( ) { } private boolean userIsAFemale ( ) { } public TypeOfSentence recognizeTypeOfSentence ( String s ) { } }

Fix:
if ( tempAnswer . contains ( pattern . getSentence ( ) ) ) {