Package com.ubs.backend.util
Class CalculateRating
java.lang.Object
com.ubs.backend.util.CalculateRating
- Since:
- 10.08.2021
- Author:
- Tim Irmler
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intprivate static float -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatgetLevenshteinDistance(int distanceRaw, int stringLengthDifference)Converts the Levenshtein Distance to a useful value between 0 and 1 a smaller number is betterstatic StringgetMatchStatus(Match match)Returns if aMatchis Translated as a String Used in the Frontend to visualize it to the adminsstatic floatgetOffset(int upvotes)Calculate the amount of downvotes which are needed to mark aMatchas badstatic floatgetRating(int upvotes, int downvotes)Get the Rating for a Translation to check if it is good or badstatic floatgetRating(int upvotes, int downvotes, float levenstheinDistance)Get the Rating for a Translation to check if it is good or badstatic floatgetRating(long upvotes, long downvotes)Get the Rating for a Translation to check if it is good or badstatic booleanisBadMatch(int upvotes, int downvotes)Checks if aMatchis considered bad based on the amount of Upvotes and Downvotes it received.
-
Field Details
-
minDownvotesForNoTranslate
public static final int minDownvotesForNoTranslate- See Also:
- Constant Field Values
-
minOffsetForNoTranslate
private static final float minOffsetForNoTranslate- See Also:
- Constant Field Values
-
-
Constructor Details
-
CalculateRating
public CalculateRating()
-
-
Method Details
-
getOffset
public static float getOffset(int upvotes)Calculate the amount of downvotes which are needed to mark aMatchas bad- Parameters:
upvotes- the amount of upvotes the Match has- Returns:
- the amount of Downvotes needed
- See Also:
Match
-
isBadMatch
public static boolean isBadMatch(int upvotes, int downvotes)Checks if aMatchis considered bad based on the amount of Upvotes and Downvotes it received.- Parameters:
upvotes- the amount of upvotes this Match receiveddownvotes- the amount of downvotes this Match received- Returns:
- if a Match is bad
- See Also:
Match
-
getMatchStatus
Returns if aMatchis Translated as a String Used in the Frontend to visualize it to the admins- Parameters:
match- The Match which will be checked- Returns:
- the String mentioned above in German
- See Also:
Match
-
getLevenshteinDistance
public static float getLevenshteinDistance(int distanceRaw, int stringLengthDifference)Converts the Levenshtein Distance to a useful value between 0 and 1 a smaller number is better- Parameters:
distanceRaw- the raw Levenshtein distancestringLengthDifference- the length of the longerStringof the two which were compared- Returns:
- useful value between 0 and 1
-
getRating
public static float getRating(int upvotes, int downvotes, float levenstheinDistance)Get the Rating for a Translation to check if it is good or bad- Parameters:
upvotes- the amount of Upvotes theMatchhasdownvotes- the amount of Downvotes theMatchhaslevenstheinDistance- the levenshtein Distance of the two Words- Returns:
- the Rating for this Match
-
getRating
public static float getRating(int upvotes, int downvotes)Get the Rating for a Translation to check if it is good or bad- Parameters:
upvotes- the amount of Upvotes theMatchhasdownvotes- the amount of Downvotes theMatchhas- Returns:
- the Rating for this Match
-
getRating
public static float getRating(long upvotes, long downvotes)Get the Rating for a Translation to check if it is good or bad- Parameters:
upvotes- the amount of Upvotes theMatchhasdownvotes- the amount of Downvotes theMatchhas- Returns:
- the Rating for this Match
-