def get_strings_for_search(value):
"""
Returns all statements which have a substring of the given value
:param value: String
:return: dict() with Statements.uid as key and 'text', 'distance' as well as 'arguments' as values
"""
tmp_dict = OrderedDict()
db_statements = get_not_disabled_statement_as_query().join(TextVersion, Statement.textversion_uid == TextVersion.uid).all()
for stat in db_statements:
if value.lower() in stat.textversions.content.lower():
# get distance between input value and saved value
rd = __get_fuzzy_string_dict(current_text=value, return_text=stat.textversions.content, uid=stat.uid)
tmp_dict[str(stat.uid)] = rd
tmp_dict = __sort_dict(tmp_dict)
return_index = list(islice(tmp_dict, list_length))
return_dict = OrderedDict()
for index in return_index:
return_dict[index] = tmp_dict[index]
return return_dict
评论列表
文章目录