Package org.aksw.limes.core.io.mapping
Class MemoryMapping
- java.lang.Object
-
- org.aksw.limes.core.io.mapping.AMapping
-
- org.aksw.limes.core.io.mapping.MemoryMapping
-
- All Implemented Interfaces:
Serializable,IMapping
public class MemoryMapping extends AMapping
This class contains the mappings computed by an organizer. Each URI from the second knowledge base is mapped to the URI of instances from the first knowledge base and the corresponding similarity value. This is a help class for further processing that simply stores the mapping results in memory. It is important to notice that if (s, t, sim1) are already in the mapping and (s, t, sim2) is added then the mapping will contain (s, t, max(sim1, sim2))- Version:
- Nov 24, 2015
- Author:
- Axel-C. Ngonga Ngomo (ngonga@informatik.uni-leipzig.de), Mohamed Sherif <sherif @ informatik.uni-leipzig.de>
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.aksw.limes.core.io.mapping.AMapping
map, predicate, reversedMap, size
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMemoryMapping()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String source, String target, double similarity)Add one entry to the mappingvoidadd(String uri, HashMap<String,Double> instances)Add a batch of similarities to the mappingbooleancontains(String sourceInstance, String targetInstance)Checks whether a mapping contains a particular entrystatic AMappinggenerateRandomMapping(int mappingSize, int minSize, int maxSize)AMappinggetBestOneToNMapping()Computes the best one to n mapping for the current mapping, i.e., for each element of the source, it gets the best t from target.doublegetConfidence(String sourceInstance, String targetInstance)Checks whether the map contains a certain pair.intgetNumberofMappings()Computes the total number of mappings contained in the objectintgetNumberofPositiveMappings()Computes the number of mappings with value greater than 0 contained in the objectAMappinggetOnlyPositiveExamples()AMappinggetSubMap(double threshold)Returns a mapping that contains all elements of the current mapping that have similarity above the threshold.voidinitReversedMap()Fills the whole content of the current map into the reversed map, which uses the similarity scores as key.StringpairsOutput()AMappingreverseSourceTarget()Reverses source and targetAMappingscale(double d)intsize()StringtoString()AMappingtrim()AMappingunion(AMapping other)Union of two maps: returns all pairs of sources s and targets t of this map and the other.-
Methods inherited from class org.aksw.limes.core.io.mapping.AMapping
equals, getBestOneToOneMappings, getMap, getPredicate, getPredicateURI, getReversedMap, getSize, hashCode, setMap, setPredicate, setSize
-
-
-
-
Method Detail
-
generateRandomMapping
public static AMapping generateRandomMapping(int mappingSize, int minSize, int maxSize)
-
initReversedMap
public void initReversedMap()
Fills the whole content of the current map into the reversed map, which uses the similarity scores as key.
-
getSubMap
public AMapping getSubMap(double threshold)
Returns a mapping that contains all elements of the current mapping that have similarity above the threshold. Basically the same as filter(mapping, threshold) but should be faster
-
add
public void add(String uri, HashMap<String,Double> instances)
Add a batch of similarities to the mapping
-
getConfidence
public double getConfidence(String sourceInstance, String targetInstance)
Checks whether the map contains a certain pair. If yes, its similarity is returned. Else 0 is returned- Specified by:
getConfidencein classAMapping- Parameters:
sourceInstance- Instance from the source knowledge basetargetInstance- Instance from the target knowledge base- Returns:
- Similarity of the two instances according to the mapping
-
contains
public boolean contains(String sourceInstance, String targetInstance)
Checks whether a mapping contains a particular entry
-
getNumberofMappings
public int getNumberofMappings()
Computes the total number of mappings contained in the object- Specified by:
getNumberofMappingsin classAMapping- Returns:
- Total number of mappings
-
getNumberofPositiveMappings
public int getNumberofPositiveMappings()
Computes the number of mappings with value greater than 0 contained in the object- Specified by:
getNumberofPositiveMappingsin classAMapping- Returns:
- number of mappings with value greater than 0
-
getBestOneToNMapping
public AMapping getBestOneToNMapping()
Computes the best one to n mapping for the current mapping, i.e., for each element of the source, it gets the best t from target. This does not mean an 1 to 1 mapping, as a t can be mapped to several s.- Specified by:
getBestOneToNMappingin classAMapping- Returns:
- Best one to one mapping
-
reverseSourceTarget
public AMapping reverseSourceTarget()
Reverses source and target- Specified by:
reverseSourceTargetin classAMapping- Returns:
- Reversed map
-
scale
public AMapping scale(double d)
-
trim
public AMapping trim()
-
pairsOutput
public String pairsOutput()
-
union
public AMapping union(AMapping other)
Union of two maps: returns all pairs of sources s and targets t of this map and the other. The scores will be the maximum score of either this or the other.- Parameters:
other- , the second mapping- Returns:
- the union of the two mappings
-
getOnlyPositiveExamples
public AMapping getOnlyPositiveExamples()
- Specified by:
getOnlyPositiveExamplesin classAMapping
-
-