8775: Avoid using person-centric date matching for places
This commit is contained in:
parent
6980bb62d6
commit
d76757ddb4
@ -941,6 +941,25 @@ class Date(object):
|
|||||||
# return tuples not lists, for comparisons
|
# return tuples not lists, for comparisons
|
||||||
return (tuple(startmin), tuple(stopmax))
|
return (tuple(startmin), tuple(stopmax))
|
||||||
|
|
||||||
|
def match_exact(self, other_date):
|
||||||
|
"""
|
||||||
|
Perform an extact match between two dates. The dates are not treated
|
||||||
|
as being person-centric. This is used to match date ranges in places.
|
||||||
|
"""
|
||||||
|
if other_date.modifier == Date.MOD_NONE:
|
||||||
|
return other_date.sortval == self.sortval
|
||||||
|
elif other_date.modifier == Date.MOD_BEFORE:
|
||||||
|
return other_date.sortval > self.sortval
|
||||||
|
elif other_date.modifier == Date.MOD_AFTER:
|
||||||
|
return other_date.sortval < self.sortval
|
||||||
|
elif other_date.is_compound():
|
||||||
|
start, stop = other_date.get_start_stop_range()
|
||||||
|
start = Date(*start)
|
||||||
|
stop = Date(*stop)
|
||||||
|
return start.sortval <= self.sortval <= stop.sortval
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def match(self, other_date, comparison="="):
|
def match(self, other_date, comparison="="):
|
||||||
"""
|
"""
|
||||||
Compare two dates using sophisticated techniques looking for any match
|
Compare two dates using sophisticated techniques looking for any match
|
||||||
|
@ -40,7 +40,7 @@ def get_location_list(db, place, date=None, lang=''):
|
|||||||
handle = None
|
handle = None
|
||||||
for placeref in place.get_placeref_list():
|
for placeref in place.get_placeref_list():
|
||||||
ref_date = placeref.get_date_object()
|
ref_date = placeref.get_date_object()
|
||||||
if ref_date.is_empty() or date.match(ref_date):
|
if ref_date.is_empty() or date.match_exact(ref_date):
|
||||||
handle = placeref.ref
|
handle = placeref.ref
|
||||||
break
|
break
|
||||||
if handle is None or handle in visited:
|
if handle is None or handle in visited:
|
||||||
@ -56,7 +56,7 @@ def __get_name(place, date, lang):
|
|||||||
local_name = '?'
|
local_name = '?'
|
||||||
for place_name in place.get_all_names():
|
for place_name in place.get_all_names():
|
||||||
name_date = place_name.get_date_object()
|
name_date = place_name.get_date_object()
|
||||||
if name_date.is_empty() or date.match(name_date):
|
if name_date.is_empty() or date.match_exact(name_date):
|
||||||
name_lang = place_name.get_language()
|
name_lang = place_name.get_language()
|
||||||
if name_lang == '':
|
if name_lang == '':
|
||||||
local_name = place_name.get_value()
|
local_name = place_name.get_value()
|
||||||
|
Loading…
Reference in New Issue
Block a user