Package cz.vutbr.fit.layout.map
Class MetadataExampleGenerator
- java.lang.Object
-
- cz.vutbr.fit.layout.map.MetadataExampleGenerator
-
public class MetadataExampleGenerator extends Object
Implements extracting ocurrence examples from metadata.- Author:
- burgetr
-
-
Constructor Summary
Constructors Constructor Description 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.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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringfilterKey(String src)Applies the configured keyFilter function to a source string.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.Map<Float,List<Example>>getFloatExamples()Creates the mapping from floats to examples for the examples that may be converted to float.FloatgetFloatValue(String src)Converts a string to a float value if possible.Map<String,List<Example>>getStringExamples()Creates the mapping from filtered strings to examples taken from the repository.static StringnormalizeText(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 valuesstatic StringuseExact(String s)A filter function that uses the string exactly as it is.
-
-
-
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
-
-