dont match substrings at beginging of value

This commit is contained in:
j 2011-10-30 22:40:57 +01:00
parent c92f19f1b6
commit eee76a5b5d
2 changed files with 2 additions and 6 deletions

View file

@ -76,9 +76,7 @@ class Event(models.Model):
value = a.value.lower()
for name in [self.name] + list(self.alternativeNames):
name = name.lower()
if name in value and (value.startswith(name) or \
value.endswith(name) or \
re.compile('\s%s[\.,;:!?\-\/\s]'%name).findall(value)):
if name in value and re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%name):
matches.append(a.id)
break
if not matches:

View file

@ -86,9 +86,7 @@ class Place(models.Model):
value = a.value.lower()
for name in [self.name] + list(self.alternativeNames):
name = name.lower()
if name in value and (value.startswith(name) or \
value.endswith(name) or \
re.compile('\s%s[\.,;:!?\-\/\s]'%name).findall(value)):
if name in value and re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%name):
matches.append(a.id)
break
if not matches: