Package com.ubs.backend.services
Class IntentFinderNew
java.lang.Object
com.ubs.backend.services.IntentFinderNew
- Since:
- 10.08.2021
- Author:
- Tim Irmler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static floatif the levenshtein distance is equals to this or higher, we are certain that the user meant this word!private static floatif the levenshtein distance is equals or higher to this, we are not certain, but it could be that the user meant this word so the word is classified as match anything below this number is ignored -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddAnsweredQuestionToDB(String question, PossibleAnswer answer, javax.persistence.EntityManager em)Add questions that can be answered to the db or update their statisticsprivate voidaddUnansweredQuestionToDB(StatistikTimes times, String question, javax.persistence.EntityManager em)Add questions that cannot be answered to the dbprivate voidaddUnansweredQuestionToDB(String question, javax.persistence.EntityManager em)javax.ws.rs.core.ResponsefindAnswer(String input)WebService for getting an Answer to an Input questiongenerateJSONResponse(PossibleAnswer answer)private PossibleAnswergetPossibleAnswerFromArray(ArrayList<PossibleAnswer> possibleAnswers, Answer answer)private booleanisBlacklisted(String word, BlacklistEntryDAO blacklistEntryDAO, javax.persistence.EntityManager em)Method to check if a word is blacklisted.Takes a String as an Input and compares it with the Tags from the Database Matches Tags to Words in the String
-
Field Details
-
levenshteinCertain
private static final float levenshteinCertainif the levenshtein distance is equals to this or higher, we are certain that the user meant this word!- See Also:
- Constant Field Values
-
levenshteinMatch
private static final float levenshteinMatchif the levenshtein distance is equals or higher to this, we are not certain, but it could be that the user meant this word so the word is classified as match anything below this number is ignored- See Also:
- Constant Field Values
-
-
Constructor Details
-
IntentFinderNew
public IntentFinderNew()
-
-
Method Details
-
findAnswer
@GET @Produces("application/json") @Path("/answer2") public javax.ws.rs.core.Response findAnswer(@QueryParam("q") String input)WebService for getting an Answer to an Input question- Parameters:
input- the question from the Frontend- Returns:
- HTTP Response which contains the Answer which will be displayed on the Frontend. (Can Contain Files)
-
search
Takes a String as an Input and compares it with the Tags from the Database Matches Tags to Words in the String- Parameters:
input- the input QuestionaffectStatistics- if the statistics in the Database will be updated- Returns:
- the Best Answer as a JSON String
-
isBlacklisted
private boolean isBlacklisted(String word, BlacklistEntryDAO blacklistEntryDAO, javax.persistence.EntityManager em)Method to check if a word is blacklisted. Goes through array and checks if it is contained.- Parameters:
word- the word we are looking forblacklistEntryDAO- the blacklistentry daoem- the entity manager- Returns:
- if the word is blacklisted
- Since:
- 17.07.2021
-
getPossibleAnswerFromArray
private PossibleAnswer getPossibleAnswerFromArray(ArrayList<PossibleAnswer> possibleAnswers, Answer answer)- Parameters:
possibleAnswers-answer-- Returns:
- Since:
- 10.08.2021
-
generateJSONResponse
- Parameters:
answer-- Returns:
- Since:
- 12.08.2021
-
addUnansweredQuestionToDB
- Parameters:
question-em-- Since:
- 02.09.2021
-
addUnansweredQuestionToDB
private void addUnansweredQuestionToDB(StatistikTimes times, String question, javax.persistence.EntityManager em)Add questions that cannot be answered to the db- Parameters:
question- the question itselfem- the entity manager- Since:
- 17.07.2021
-
addAnsweredQuestionToDB
private void addAnsweredQuestionToDB(String question, PossibleAnswer answer, javax.persistence.EntityManager em)Add questions that can be answered to the db or update their statistics- Parameters:
question- the question itself, how it should be displayedanswer- the final answer, containing all the resultsem- the entity manager- Since:
- 17.07.2021
-