java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_ml.util.VectorOperations

public class VectorOperations extends Object
Some utility provided in the form of static methods for vector operations.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
  • Constructor Details

    • VectorOperations

      public VectorOperations()
  • Method Details

    • readVectorFile

      public static Map<String,Double[]> readVectorFile(String textModelFilePath)
      Read the provided text file.
      Parameters:
      textModelFilePath - Path to the text file. Each line represents a concept vector. All elements are space-separated. The first element is the concept string. Afterwards, the vector elements are named. The file must be UTF-8 encoded.
      Returns:
      Parsed text model. Null in the case of an error.
    • readVectorFileAsFloat

      public static Map<String,Float[]> readVectorFileAsFloat(String textModelFilePath)
      Read the provided text file.
      Parameters:
      textModelFilePath - Path to the text file. Each line represents a concept vector. All elements are space-separated. The first element is the concept string. Afterwards, the vector elements are named. The file must be UTF-8 encoded.
      Returns:
      Parsed text model. Null in the case of an error.
    • readVectorFileAsFloat

      public static Map<String,Float[]> readVectorFileAsFloat(File textModelFile)
      Read the provided text file.
      Parameters:
      textModelFile - The text file. Each line represents a concept vector. All elements are space-separated. The first element is the concept string. Afterwards, the vector elements are named. The file must be UTF-8 encoded.
      Returns:
      Parsed text model. Null in the case of an error.
    • isFileOk

      private static boolean isFileOk(File textModelFile)
      Checks the provided file.
      Parameters:
      textModelFile - File to be checked.
      Returns:
      True if ok, else false.
    • readVectorFile

      public static Map<String,Double[]> readVectorFile(File textModelFile)
      Read the provided text file.
      Parameters:
      textModelFile - The text file. Each line represents a concept vector. All elements are space-separated. The first element is the concept string. Afterwards, the vector elements are named. The file must be UTF-8 encoded.
      Returns:
      Parsed text model. Null in the case of an error.
    • analyzeVectorTextFile

      static org.javatuples.Triplet<Set<String>,Integer,Boolean> analyzeVectorTextFile(File textModelFile)
      Parses the concepts (not the vectors) from a text model file, i.e. a UTF-8 file where the concept is followed by its vector. One concept appears per line. Everything is space separated.
      Parameters:
      textModelFile - The file the shall be parsed.
      Returns:
      Triplet with:
      [0] A set with the full vocabulary.
      [1] Dimension
      [2] True if dimension is consistent, else false.