Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
richardboyd committed Aug 6, 2019
1 parent c21cf58 commit 54abc44
Showing 1 changed file with 0 additions and 104 deletions.
104 changes: 0 additions & 104 deletions nlp/algorithms/finder/time_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,6 @@
_str_brackets = r'[(){}\[\]]'
_regex_brackets = re.compile(_str_brackets)

#_CANDIDATE_FIELDS = ['start', 'end', 'match_text', 'regex']
#_Candidate = namedtuple('_Candidate', _CANDIDATE_FIELDS)


###############################################################################
def enable_debug():
Expand All @@ -427,107 +424,6 @@ def enable_debug():
_TRACE = True


# ###############################################################################
# def _has_overlap(a1, b1, a2, b2):
# """
# Determine if intervals [a1, b1) and [a2, b2) overlap at all.
# """

# assert a1 <= b1
# assert a2 <= b2

# if b2 <= a1:
# return False
# elif a2 >= b1:
# return False
# else:
# return True

# ###############################################################################
# def _remove_overlap(candidates):
# """
# Given a set of match candidates, resolve into nonoverlapping matches.
# Take the longest match at any given position.

# ASSUMES that the candidate list has been sorted by matching text length,
# from longest to shortest.
# """

# if _TRACE:
# print('called _remove_overlap...')

# results = []
# overlaps = []
# indices = [i for i in range(len(candidates))]

# i = 0
# while i < len(indices):

# if _TRACE:
# print('\tstarting indices: {0}'.format(indices))

# index_i = indices[i]
# start_i = candidates[index_i].start
# end_i = candidates[index_i].end
# len_i = end_i - start_i

# overlaps.append(i)
# candidate_index = index_i

# j = i+1
# while j < len(indices):
# index_j = indices[j]
# start_j = candidates[index_j].start
# end_j = candidates[index_j].end
# len_j = end_j - start_j

# # does candidate[j] overlap candidate[i] at all
# if _has_overlap(start_i, end_i, start_j, end_j):
# if _TRACE:
# print('\t\t{0} OVERLAPS {1}, lengths {2}, {3}'.
# format(candidates[index_i].match_text,
# candidates[index_j].match_text,
# len_i, len_j))
# overlaps.append(j)
# # keep the longest match at any overlap region
# if len_j > len_i:
# start_i = start_j
# end_i = end_j
# len_i = len_j
# candidate_index = index_j
# j += 1

# if _TRACE:
# print('\t\t\twinner: {0}'.
# format(candidates[candidate_index].match_text))
# print('\t\t\tappending {0} to results'.
# format(candidates[candidate_index].match_text))

# results.append(candidates[candidate_index])

# if _TRACE:
# print('\t\toverlaps: {0}'.format(overlaps))

# # remove all overlaps
# new_indices = []
# for k in range(len(indices)):
# if k not in overlaps:
# new_indices.append(indices[k])
# indices = new_indices

# if _TRACE:
# print('\t\tindices after removing overlaps: {0}'.format(indices))

# if 0 == len(indices):
# break

# # start over
# i = 0
# overlaps = []

# return results


###############################################################################
def _clean_sentence(sentence):
"""
Expand Down

0 comments on commit 54abc44

Please sign in to comment.