Пример #1
0
        for j in range(len(x2)):
            m[i,j] = ls.distance(x1[i], x2[j])
    return m

# Add path for Harry module
builddir = os.environ["BUILDDIR"]
sys.path.append(os.path.join(builddir, "python"))

# Load harry module
import harry

# Adapt path of tool (as it is not installed yet)
harry.__tool = os.path.join(builddir, "src", "harry")

x1 = ['this', 'is', 'a', 'test']
x2 = ['guess', 'what', 'this', 'is', 'not', 'a', 'test']

print "Testing Levenshtein implementation:",
m1 = harry.compare(x1, x2)
m2 = pylev_compare(x1, x2)

print
print m1
print m2

if np.linalg.norm(m1 - m2) < 1e-9:
    print "Ok"
else:
    print "Failed"
    sys.exit(1)
Пример #2
0
# Add path for Harry module
builddir = os.environ["BUILDDIR"]
sys.path.append(os.path.join(builddir, "python"))

# Load harry module
import harry

# Adapt path of tool (as it is not installed yet)
harry.__tool = os.path.join(builddir, "src", "harry")

a = " abcdefghijklmnopqrstuvwxyz.,"
x = [''.join(random.choice(a) for _ in range(10)) for _ in range(50)]

print "Testing options:",
m1 = harry.compare(x)
m2 = harry.compare(x, x)
if np.linalg.norm(m1 - m2) < 1e-9:
    print "Ok"
else:
    print "Failed"
    sys.exit(1)

print "Testing kernels:",
# Check kernel matrices for negative eigenvalues
for name in ["wdegree", "subsequence", "spectrum"]:
    k = harry.compare(x, measure="kern_" + name)
    e = np.min(np.real(np.linalg.eig(k)[0]))
    print ".",

    # Test fails if Eigenvalues are negative
Пример #3
0
# Add path for Harry module
builddir = os.environ["BUILDDIR"]
sys.path.append(os.path.join(builddir, "python"))

# Load harry module
import harry

# Adapt path of tool (as it is not installed yet)
harry.__tool = os.path.join(builddir, "src", "harry")

a = " abcdefghijklmnopqrstuvwxyz.,"
x = [''.join(random.choice(a) for _ in range(10)) for _ in range(50)]

print "Testing options:",
m1 = harry.compare(x)
m2 = harry.compare(x, x)
if np.linalg.norm(m1 - m2) < 1e-9:
    print "Ok"
else:
    print "Failed"
    sys.exit(1)

print "Testing kernels:",
# Check kernel matrices for negative eigenvalues
for name in ["wdegree", "subsequence", "spectrum"]:
    k = harry.compare(x, measure="kern_" + name)
    e = np.min(np.real(np.linalg.eig(k)[0]))
    print ".",

    # Test fails if Eigenvalues are negative
Пример #4
0
            m[i, j] = ls.distance(x1[i], x2[j])
    return m


# Add path for Harry module
builddir = os.environ["BUILDDIR"]
sys.path.append(os.path.join(builddir, "python"))

# Load harry module
import harry

# Adapt path of tool (as it is not installed yet)
harry.__tool = os.path.join(builddir, "src", "harry")

x1 = ['this', 'is', 'a', 'test']
x2 = ['guess', 'what', 'this', 'is', 'not', 'a', 'test']

print "Testing Levenshtein implementation:",
m1 = harry.compare(x1, x2)
m2 = pylev_compare(x1, x2)

print
print m1
print m2

if np.linalg.norm(m1 - m2) < 1e-9:
    print "Ok"
else:
    print "Failed"
    sys.exit(1)