missing people search system
I am going to develop missing people search system of sahana eden. Is the search support of searching with sound like names or without knowing correct spellings of the name. I downloaded Sahana Eden few days early and that functionality seem to be not implemented yet. What are the classes deal with searching of missing people ?
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Sahana-Eden Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
If I understand it right, this question refers to the use-case of finding a person by their name(s).
This is currently implemented as pr/person/
In search_simple, if one does not know the exact spelling of a name, he's currently to use wildcards in that form (there is some automatic wildcarding as well). Note, that person search_simple does not only search in names, but in IDs as well.
We did not want sounds-like as it is supported by only some DB engines and works for English only, and thus makes no sense in almost all of the cases. A generic sounds-like-engine (=one that does take the languages into account) does currently not exist for any DB system, and there is not much hope that such will be developed in the near future.
As an alternative solution, Levenshtein-
currently). If one comes up with a smart query solution for Levenshtein-
A different, but not less important use-case is to find candidate matches between missing-person records and unknown-person records (or dead body records, respectively). For this, there is a basic implementation as S3Vita.
If you intend to extend S3Vita.
Btw: S3Vita.
Regards,
Dominic
Revision history for this message
|
#2 |
You may try this, but not sure it would be supported by all our DB systems:
http://
Revision history for this message
|
#3 |
Dear Sir,
I have done some improvements in 02_pr.py to integrate the ability to search using Levenshtein-
#levdis() functions returns a flot value reflecting the diffece between the two input strings
def levdis(str1,str2):
matrix = {}
l1 = len(str1)
l2 = len(str2)
for i in range(0, l1+1): matrix[i, 0] = i
for j in range(0, l2+1): matrix[0, j] = j
for i in range(1, l1+1):
for j in range(1, l2+1):
x = matrix[i-1, j] + 1
y = matrix[i, j-1] + 1
if str1[i-1] == str2[j-1]:
return float(matrix[l1, l2]) / float(max(l1, l2))
def shn_pr_
""" Simple search form for persons """
resource = r.resource
table = resource.table
r.id = None
# Check permission
if not shn_has_
if r.representation == "html":
# Check for redirection
next = r.request.
if not next:
next = URL(r=request, f="person", args="[id]")
#generate form using the table
form = SQLFORM.
output = dict(form=form, vars=form.vars)
# Accept action
items = None
if form.accepts(
# if no search keword typed use % to display all the entries in the table
if form.vars.label == "":
# Search
# search for the inserted keyword and take the list of ids of the result
results = s3xrc.search_
gen =int(form.
age = int(form.
print results
# Get the results
if results: #if there is a result from normal query the display it
else:
# if there is no reslts load all the records to the rows1 object but in this occasion it will consider the values of gender and
# age group fields, because their is a very high probability that user knows the correct values of those fields
# But if both values ore one of the values are unknown it will ignoner them and build the query
if gen != "unknown" and age != "unknown":
# for each entry in the table calculate the levdis for firstname, middlename and lastname
for row in rows1:
if results: #if there is a result after calculating levdis display it
# Title and subtitle
title = T("Search for a Person")
subtitle = T("Matching Records")
# Add-button
add_btn = A(label_
return output
else:
# Plug into REST controller
s3xrc.model.
Revision history for this message
|
#4 |
Dear Sir,
I have done some improvements in 02_pr.py to integrate the ability to search using Levenshtein-
#levdis() functions returns a flot value reflecting the diffece between the two input strings
def levdis(str1,str2):
matrix = {}
l1 = len(str1)
l2 = len(str2)
for i in range(0, l1+1): matrix[i, 0] = i
for j in range(0, l2+1): matrix[0, j] = j
for i in range(1, l1+1):
for j in range(1, l2+1):
x = matrix[i-1, j] + 1
y = matrix[i, j-1] + 1
if str1[i-1] == str2[j-1]:
return float(matrix[l1, l2]) / float(max(l1, l2))
def shn_pr_
""" Simple search form for persons """
resource = r.resource
table = resource.table
r.id = None
# Check permission
if not shn_has_
if r.representation == "html":
# Check for redirection
next = r.request.
if not next:
next = URL(r=request, f="person", args="[id]")
#generate form using the table
form = SQLFORM.
output = dict(form=form, vars=form.vars)
# Accept action
items = None
if form.accepts(
# if no search keword typed use % to display all the entries in the table
if form.vars.label == "":
# Search
# search for the inserted keyword and take the list of ids of the result
results = s3xrc.search_
gen =int(form.
age = int(form.
print results
# Get the results
if results: #if there is a result from normal query the display it
else:
# if there is no reslts load all the records to the rows1 object but in this occasion it will consider the values of gender and
# age group fields, because their is a very high probability that user knows the correct values of those fields
# But if both values ore one of the values are unknown it will ignoner them and build the query
if gen != "unknown" and age != "unknown":
# for each entry in the table calculate the levdis for firstname, middlename and lastname
for row in rows1:
if results: #if there is a result after calculating levdis display it
# Title and subtitle
title = T("Search for a Person")
subtitle = T("Matching Records")
# Add-button
add_btn = A(label_
return output
else:
# Plug into REST controller
s3xrc.model.
Revision history for this message
|
#5 |
Dear Sir,
I have done some improvements in 02_pr.py to integrate the ability to search using Levenshtein-
#levdis() functions returns a flot value reflecting the diffece between the two input strings
def levdis(str1,str2):
matrix = {}
l1 = len(str1)
l2 = len(str2)
for i in range(0, l1+1): matrix[i, 0] = i
for j in range(0, l2+1): matrix[0, j] = j
for i in range(1, l1+1):
for j in range(1, l2+1):
x = matrix[i-1, j] + 1
y = matrix[i, j-1] + 1
if str1[i-1] == str2[j-1]:
return float(matrix[l1, l2]) / float(max(l1, l2))
def shn_pr_
""" Simple search form for persons """
resource = r.resource
table = resource.table
r.id = None
# Check permission
if not shn_has_
if r.representation == "html":
# Check for redirection
next = r.request.
if not next:
next = URL(r=request, f="person", args="[id]")
#generate form using the table
form = SQLFORM.
output = dict(form=form, vars=form.vars)
# Accept action
items = None
if form.accepts(
# if no search keword typed use % to display all the entries in the table
if form.vars.label == "":
# Search
# search for the inserted keyword and take the list of ids of the result
results = s3xrc.search_
gen =int(form.
age = int(form.
print results
# Get the results
if results: #if there is a result from normal query the display it
else:
# if there is no reslts load all the records to the rows1 object but in this occasion it will consider the values of gender and
# age group fields, because their is a very high probability that user knows the correct values of those fields
# But if both values ore one of the values are unknown it will ignoner them and build the query
if gen != "unknown" and age != "unknown":
# for each entry in the table calculate the levdis for firstname, middlename and lastname
for row in rows1:
if results: #if there is a result after calculating levdis display it
# Title and subtitle
title = T("Search for a Person")
subtitle = T("Matching Records")
# Add-button
add_btn = A(label_
return output
else:
# Plug into REST controller
s3xrc.model.
Revision history for this message
|
#6 |
Dear Sir,
I have done some improvements in 02_pr.py to integrate the ability to search using Levenshtein-
#levdis() functions returns a flot value reflecting the diffece between the two input strings
def levdis(str1,str2):
matrix = {}
l1 = len(str1)
l2 = len(str2)
for i in range(0, l1+1): matrix[i, 0] = i
for j in range(0, l2+1): matrix[0, j] = j
for i in range(1, l1+1):
for j in range(1, l2+1):
x = matrix[i-1, j] + 1
y = matrix[i, j-1] + 1
if str1[i-1] == str2[j-1]:
return float(matrix[l1, l2]) / float(max(l1, l2))
def shn_pr_
""" Simple search form for persons """
resource = r.resource
table = resource.table
r.id = None
# Check permission
if not shn_has_
if r.representation == "html":
# Check for redirection
next = r.request.
if not next:
next = URL(r=request, f="person", args="[id]")
#generate form using the table
form = SQLFORM.
output = dict(form=form, vars=form.vars)
# Accept action
items = None
if form.accepts(
# if no search keword typed use % to display all the entries in the table
if form.vars.label == "":
# Search
# search for the inserted keyword and take the list of ids of the result
results = s3xrc.search_
gen =int(form.
age = int(form.
print results
# Get the results
if results: #if there is a result from normal query the display it
else:
# if there is no reslts load all the records to the rows1 object but in this occasion it will consider the values of gender and
# age group fields, because their is a very high probability that user knows the correct values of those fields
# But if both values ore one of the values are unknown it will ignoner them and build the query
if gen != "unknown" and age != "unknown":
# for each entry in the table calculate the levdis for firstname, middlename and lastname
for row in rows1:
if results: #if there is a result after calculating levdis display it
# Title and subtitle
title = T("Search for a Person")
subtitle = T("Matching Records")
# Add-button
add_btn = A(label_
return output
else:
# Plug into REST controller
s3xrc.model.
Revision history for this message
|
#7 |
Thanks for this!
As you might have seen, the Levenshtein distance algorithm was already implemented as vita.rlevenshte
So I had the idea to have that implemented in SQL (therefore the example), and the respective Python routine just returning the magic query. But this has neither been implemented nor requested thus far. Nevertheless, I'd really be happy if someone comes up with it.
In regard of the code suggested here:
1) the search part doesn't implement authorization, it searches all records regardless of whether the user is permitted to access them or not. Using the resource iterator would solve this (=for record in resource).
2) this method searches in the names of a person, while the fields to search in should basically be configurable. It should also be configurable whether to use levenshtein or not (exact match).
Also note that the shn_pr_
The current Eden trunk implements search methods in modules/
Hopefully you're up for that.
Kind regards,
Dominic
Revision history for this message
|
#8 |
I'd say we should take a look at this:
Can you help with this problem?
Provide an answer of your own, or ask Prasad Tissera for more information if necessary.