Class ComparisonUtils

java.lang.Object
org.aksw.qa.annotation.comparison.ComparisonUtils

public class ComparisonUtils extends Object
Offers functionality to extract superlatives and comparatives from strings and functions to retrieve properties and the order for a comparative or superlative.
  • Field Details

  • Constructor Details

    • ComparisonUtils

      public ComparisonUtils()
  • Method Details

    • getProperties

      public ArrayList<String> getProperties(String comparison)
      Returns a list of properties for the given superlative or comparative (also works for the basic form of the supported adjectives). Supported adjectives can be found in ComparisonEnum.
      Parameters:
      comparison - Adjective.
      Returns:
      List of properties for the given adjective, null if the adjective is not supported.
    • getOrder

      public String getOrder(String comparison)
      Returns the order for the given superlative or comparative which can then be used in SPARQL queries. Supported adjectives can be found in ComparisonEnum.
      Parameters:
      comparison - A superlative or comparative.
      Returns:
      Order for the given superlative or comparative, null if it is not supported.
    • getComparatives

      public ArrayList<String> getComparatives(String question)
      Retrieves comparatives from the string. Calls getWords(String, String).
      Parameters:
      question - String to retrieve comparatives from.
      Returns:
      List of the retrieved comparatives.
    • getSuperlatives

      public ArrayList<String> getSuperlatives(String question)
      Retrieves superlatives from the string. Calls getWords(String, String).
      Parameters:
      question - String to retrieve superlatives from.
      Returns:
      List of the retrieved superlatives.
    • getWords

      private ArrayList<String> getWords(String question, String tag)
      Retrieves a part of speech from the given string, depending on the parameter tag. JJR for comparatives and JJS for superlatives.
      Parameters:
      question - String to retrieve words from.
      tag - JJR for comparatives and JJS for superlatives.
      Returns:
      List of the retrieved words.