[demo] Use the new implemantation of findneigbours()
authorSimon Chabot <simon.chabot@logilab.fr>
Wed, 07 Nov 2012 17:24:42 +0100
changeset 85 ab75d8ffb260
parent 84 3cd1edfd28d0
child 86 ecf97bda4259
[demo] Use the new implemantation of findneigbours()
demo.py
--- a/demo.py	Wed Nov 07 17:09:20 2012 +0100
+++ b/demo.py	Wed Nov 07 17:24:42 2012 +0100
@@ -1,11 +1,9 @@
 #!/usr/bin/python
 #-*- coding:utf-8 -*-
 
-from scipy.spatial import KDTree
-
 import alignment.distances as d
 import alignment.normalize as n
-from alignment.aligner import align, parsefile
+from alignment.aligner import align, parsefile, findneighbours
 
 def demo_0():
     # prixgoncourt is the list of Goncourt Prize, extracted
@@ -81,13 +79,11 @@
     print dmatrix
 
 def demo_2():
-    targetset = parsefile('demo/FR.txt', indexes = [0, 1, (4, 5)])
-    alignset = parsefile('demo/frenchbnf', indexes = [0, 2, (14, 12)])
+    targetset = parsefile('demo/FR.txt', indexes=[0, 1, (4, 5)])
+    alignset = parsefile('demo/frenchbnf', indexes=[0, 2, (14, 12)])
 
-    aligntree = KDTree([elt[2] or (0, 0) for elt in alignset])
-    targettree = KDTree([elt[2] or (0, 0) for elt in targetset])
-
-    neighbors = aligntree.query_ball_tree(targettree, 0.1)
+    neighbors = findneighbours(alignset, targetset, indexes=(2, 2),
+                               mode='kdtree', threshold=0.1)
 
     # Let's define the treatements to apply on the location's name
     tr_name = { 'normalization': [lambda x: str(x),#Some names are casted to