Closed Josiah-tan closed 2 years ago
The checker is "conservative", in the sense that Cartesian product prohibit overlapping mask because it might lead to ambiguous result.
Also, implementation-detail-wise it kind of makes sense, as the whole dictionary is not generated in-memory and the translation is done on-demand i.e. when it gets the stroke SK, it e.g. deterministically lookups "S" in the first half and lookup "K" in the second half. So conflicting means exponentially multiple required lookups.
Workaround would be to explicitly convert the filtered dictionary into a an explicit form, I guess. Consequence would be that it takes the amount of memory proportional to the total number of dictionary entries.
Something like this.
dictionary = s(dict(dictionary.filter(lambda x: len(x) <= 2).items()))
Maybe the documentation needs to be improved a bit, I forgot already how to iterate over items (need to call .items()
on it, cannot just dict(...)
)
Alternatively maybe only remove the lookup()
function for such conflicting dictionaries? items()
method obviously can still work in this case.
I have tried the hack with the explicit form, and it seems to work thanks! Maybe a smarter filter that takes this into account can be created in the future somehow, but I guess that is for future work
version 0.4.2 try running this code:
I get an assertion error like so, even though I think the "K" should be filtered out in the previous step?