Class CalculateRating

java.lang.Object
com.ubs.backend.util.CalculateRating

public class CalculateRating extends Object
Since:
10.08.2021
Author:
Tim Irmler
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
     
    private static float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    getLevenshteinDistance​(int distanceRaw, int stringLengthDifference)
    Converts the Levenshtein Distance to a useful value between 0 and 1 a smaller number is better
    static String
    Returns if a Match is Translated as a String Used in the Frontend to visualize it to the admins
    static float
    getOffset​(int upvotes)
    Calculate the amount of downvotes which are needed to mark a Match as bad
    static float
    getRating​(int upvotes, int downvotes)
    Get the Rating for a Translation to check if it is good or bad
    static float
    getRating​(int upvotes, int downvotes, float levenstheinDistance)
    Get the Rating for a Translation to check if it is good or bad
    static float
    getRating​(long upvotes, long downvotes)
    Get the Rating for a Translation to check if it is good or bad
    static boolean
    isBadMatch​(int upvotes, int downvotes)
    Checks if a Match is considered bad based on the amount of Upvotes and Downvotes it received.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 a Match as 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 a Match is considered bad based on the amount of Upvotes and Downvotes it received.
      Parameters:
      upvotes - the amount of upvotes this Match received
      downvotes - the amount of downvotes this Match received
      Returns:
      if a Match is bad
      See Also:
      Match
    • getMatchStatus

      public static String getMatchStatus(Match match)
      Returns if a Match is 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 distance
      stringLengthDifference - the length of the longer String of 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 the Match has
      downvotes - the amount of Downvotes the Match has
      levenstheinDistance - 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 the Match has
      downvotes - the amount of Downvotes the Match has
      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 the Match has
      downvotes - the amount of Downvotes the Match has
      Returns:
      the Rating for this Match