Enabled fuzzy matching by default.

This commit is contained in:
Flancian 2020-11-16 13:43:15 +01:00
parent 8ffeabed8b
commit f0284bb8a6

View file

@ -17,6 +17,7 @@ import re
import os import os
from . import config from . import config
from collections import defaultdict from collections import defaultdict
from fuzzywuzzy import fuzz
from operator import attrgetter from operator import attrgetter
RE_WIKILINKS = re.compile('\[\[(.*?)\]\]') RE_WIKILINKS = re.compile('\[\[(.*?)\]\]')
@ -146,10 +147,10 @@ def nodes_by_wikilink(wikilink):
nodes = [node for node in all_nodes() if node.wikilink == wikilink] nodes = [node for node in all_nodes() if node.wikilink == wikilink]
return nodes return nodes
def subnodes_by_wikilink(wikilink, fuzzy=True): def subnodes_by_wikilink(wikilink, fuzzy_matching=True):
if fuzzy: if fuzzy_matching:
# TODO # TODO
subnodes = [subnode for subnode in all_subnodes() if subnode.wikilink == wikilink] subnodes = [subnode for subnode in all_subnodes() if fuzz.ratio(subnode.wikilink, wikilink) > 90]
else: else:
subnodes = [subnode for subnode in all_subnodes() if subnode.wikilink == wikilink] subnodes = [subnode for subnode in all_subnodes() if subnode.wikilink == wikilink]
return subnodes return subnodes