Class MetadataExampleGenerator


  • public class MetadataExampleGenerator
    extends Object
    Implements extracting ocurrence examples from metadata.
    Author:
    burgetr
    • Constructor Detail

      • MetadataExampleGenerator

        public MetadataExampleGenerator​(RDFArtifactRepository repo,
                                        org.eclipse.rdf4j.model.IRI metadataContextIri)
        Creates an example generator for a metadata context in a repository with a identity (useExact) key filter function.
        Parameters:
        repo -
        metadataContextIri -
      • MetadataExampleGenerator

        public MetadataExampleGenerator​(RDFArtifactRepository repo,
                                        org.eclipse.rdf4j.model.IRI metadataContextIri,
                                        Function<String,​String> stringFilter)
        Creates an example generator for a metadata context in a repository with a configurable key filter function.
        Parameters:
        repo -
        metadataContextIri -
        stringFilter - the filter function to be applied to the strings in order to make them a map key.
    • Method Detail

      • getExamples

        public List<Example> getExamples()
        Finds all literals in the given metadata context and creates a list of occurrence examples containing the text, the corresponding property and subject.
        Returns:
        A list of ocurrence examples.
      • getStringExamples

        public Map<String,​List<Example>> getStringExamples()
        Creates the mapping from filtered strings to examples taken from the repository.
        Returns:
        A map that maps filtered strings to the individual examples. Generally a list of examples may be mapped to a single string.
      • getFloatExamples

        public Map<Float,​List<Example>> getFloatExamples()
        Creates the mapping from floats to examples for the examples that may be converted to float.
        Returns:
        A map that maps float values to the individual examples. Generally a list of examples may be mapped to a single string.
      • filterKey

        public String filterKey​(String src)
        Applies the configured keyFilter function to a source string.
        Parameters:
        src -
        Returns:
      • getFloatValue

        public Float getFloatValue​(String src)
        Converts a string to a float value if possible.
        Parameters:
        src -
        Returns:
      • useExact

        public static String useExact​(String s)
        A filter function that uses the string exactly as it is.
        Parameters:
        s - the source string
        Returns:
        s
      • normalizeText

        public static String normalizeText​(String src)
        A filter function that normalizes the text which includes
        • Conversion to lower case
        • Reduction of sequences of white space characters to a single space
        • Replacing HTML entities by their values
        Parameters:
        src - the source string
        Returns:
        the normalized string