Class Util


  • public final class Util
    extends Object
    Utility class that provides some utility functions.
    Author:
    Jan Keim
    • Method Detail

      • getINodesInOrder

        public static org.eclipse.collections.api.list.ImmutableList<edu.kit.ipd.parse.luna.graph.INode> getINodesInOrder​(edu.kit.ipd.parse.luna.graph.IGraph graph)
        Returns the "main" INodes in order. This means that "token"-type INodes are collected and returned in a sorted list. Sorting is based on the "next"-arc, starting with the first utterance node.
        Parameters:
        graph - Graph representing an input
        Returns:
        Sorted List of "token"-INodes
      • nodeHasTokenTypeInIGraph

        public static boolean nodeHasTokenTypeInIGraph​(edu.kit.ipd.parse.luna.graph.IGraph graph,
                                                       edu.kit.ipd.parse.luna.graph.INode node)
        Returns whether a given node has type "token" within the given graph
        Parameters:
        graph - the Graph
        node - the Node that should be checked
        Returns:
        true if the node has type "token"
      • getTokenINodeType

        public static edu.kit.ipd.parse.luna.graph.INodeType getTokenINodeType​(edu.kit.ipd.parse.luna.graph.IGraph graph)
        Returns the INodeType for "token". If the given graph does not have such a type yet, the token is created
        Parameters:
        graph - Graph to operate on
        Returns:
        The INodeType for "token".
      • getINodeValue

        public static String getINodeValue​(edu.kit.ipd.parse.luna.graph.INode node)
        Returns the String value of the attribute "value" for a given node.
        Parameters:
        node - the node
        Returns:
        the String value of the attribute "value" for a given node.
      • getTextFromWords

        public static String getTextFromWords​(Stream<? extends Word> words)
      • getTextFromWords

        public static String getTextFromWords​(List<? extends Word> words)
      • relativeDistance

        public static double relativeDistance​(String first,
                                              String second)
        Based on Levenshtein Distance, that then is normalized with the length of the longer String.
        Parameters:
        first - first String
        second - second String
        Returns:
        normalized Levenshtein Distance