Permalink
Browse files

Improve accuracy of alias matching

  • Loading branch information...
1 parent cac9550 commit 41610841f013dd71a25d5d921542653a6703b848 @meldra committed Aug 5, 2012
Showing with 8 additions and 9 deletions.
  1. +8 −9 brain/views.py
View
@@ -235,21 +235,20 @@ def taghilight(body):
def getothers(subject, sender):
- subject = ' %s ' % subject
+ subject = ' %s ' % subject.lower()
cursor = connection.cursor()
cursor.execute('with list as '
'(select a.id, a.alias, '
'(select distinct count(*) '
'as cnt from brain_alias a2 where a2.alias = a.alias) '
'as occurs from brain_alias a) '
'select alias from list '
- 'where occurs = 1;')
+ 'where occurs = 1 order by length(alias);')
aliaslist = cursor.fetchall()
aliaslist = map(' '.join, aliaslist)
others = []
o = others.append
-
for alias in aliaslist:
if subject.find(alias) > 0:
matchq = Alias.objects.filter( alias = alias )
@@ -321,28 +320,28 @@ def resyncaliases():
if j['first_name']:
try:
- alias = Alias.objects.get_or_create(person_id = j['email'], alias = j['first_name'], type = 'first_name')
+ alias = Alias.objects.get_or_create(person_id = j['email'], alias = j['first_name'].lower(), type = 'first_name')
except:
alias = Alias.objects.get(person = j['email'], type = 'first_name')
- alias.alias = j['first_name']
+ alias.alias = j['first_name'].lower()
alias.save()
if j['surname']:
surname_initial = '%s%s' % (j['first_name'], j['surname'][0:1])
surname_initial_space = '%s %s' % (j['first_name'], j['surname'][0:1])
try:
- alias = Alias.objects.get_or_create(person_id = j['email'], alias = surname_initial, type = 'surname')
+ alias = Alias.objects.get_or_create(person_id = j['email'], alias = surname_initial.lower(), type = 'surname')
except:
alias = Alias.objects.get(person = j['email'], type = 'surname')
- alias.alias = surname_initial
+ alias.alias = surname_initial.lower()
alias.save()
try:
- alias = Alias.objects.get_or_create(person_id = j['email'], alias = surname_initial_space, type = 'surnamesp')
+ alias = Alias.objects.get_or_create(person_id = j['email'], alias = surname_initial_space.lower(), type = 'surnamesp')
except:
alias = Alias.objects.get(person = j['email'], type = 'surnamesp')
- alias.alias = surname_initial_space
+ alias.alias = surname_initial_space.lower()
alias.save()
if j['irc_nick']:

0 comments on commit 4161084

Please sign in to comment.