This function takes as its only argument a function f(m1, m2) which returns a single numeric indicating the distance between two 'meanings' m1, m2 (which are themselves most likely vectors or lists). Based on f, this function returns a function g(mm) which takes as its only argument a matrix or data frame mm with the meaning elements (equivalent to the ones in m1, m2) along columns and different meaning combinations (like m1, m2, ...) along rows. This function returns a distance matrix of class dist containing all pairwise distances between the rows of mm. The resulting function g can be passed to other functions in this package, in particular mantel.test.

wrap.meaningdistfunction(pairwisemeaningdistfun)

Arguments

pairwisemeaningdistfun

a function of two arguments returning a single numeric indicating the semantic distance between its arguments

Value

A function that takes a meaning matrix and returns a corresponding distance matrix of class dist.

Details

The meaning distance function should be commutative, i.e. f(a,b) = f(b,a), and meanings should have a distance of zero to themselves, i.e. f(a,a) = 0.

Examples

trivialdistance <- function(a, b) return(a - b) trivialmeanings <- as.matrix(3:1) trivialdistance(trivialmeanings[1], trivialmeanings[2])
#> [1] 1
trivialdistance(trivialmeanings[1], trivialmeanings[3])
#> [1] 2
trivialdistance(trivialmeanings[2], trivialmeanings[3])
#> [1] 1
distmatrixfunction <- wrap.meaningdistfunction(trivialdistance) distmatrixfunction(trivialmeanings)
#> 1 2 #> 2 1 #> 3 2 1