Adapted (via wish-coding) the incapacitated (due to it overwhelming a pop-up menu with a list of unique surnames) core Soundex gramplet (soundgen.py) into a more flexible Phonetic Encoding matching gramplet. It would recognize additional phonetic encoding systems with modules dropped in subfolder. Which really restricted the path for collaborating developers.
Since a matching system also needs a “Rule” type addon to be useful, started exploring an bundling of the Rule Python with the encoding/decoding Python. That should give the most re-usability. (Plus the README.md files could explain the System’s history, target audience and methodology.)
But like the addon filters for genetic genealogy; the discovery for GUI placement, re-use, and maintenance would be better from the plugin registry.
Claude is suggesting pre-fixing the ID. But that seems like a bad approach.
Are there existing options in the ruleclass for categorizing such special purpose Rules?
Attributes for RULE plugins
namespace
The class (Person, Event, Media, etc.) the rule applies to.
ruleclass
The exact class name of the rule; ex: HasSourceParameter
The General rule grouping is overloaded and not very helpful when searching for rules of similar objectives.
The Soundex-related rule (Soundex match of People with the <name>) set a bad precedent of starting with the Unique portion (Soundex) first and not having a generic category word in the rule name. So neither sorting nor searching would help when there are similar addon rules to be found.
Very ugly, did you test something like:
from gramps.gen.filters import GenericFilterFactory, rules
[..]
default_person = self.dbstate.db.get_default_person()
root_id = default_person.get_gramps_id()
# surnames = ? get surnames for root_id ?
# name.surname_list ? not tested
[..]
def __init__(self, dbstate):
self.dbstate = dbstate
self.filter = GenericFilterFactory('Person')()
self.soundex = rules.person.HasSoundexName([str(surnames)])
self.filter.add_rule(self.soundex)
[..]
(Analysis and code by Claude AI, from my wish-coding questions.)
Thanks, Jérôme. Could you say which part you found ugly: the ID-prefix idea for identifying encoder rules, or the crowded “General filters” group in the screenshots? I would like to fix the right thing.
On the filter approach: the gramplet already builds a GenericFilter this way, but only for its action that saves a reusable custom filter (falling back to the built-in HasSoundexName for Soundex). The live match list uses a cached per-tree index instead, because applying a filter scans the whole tree on every query, and that slowness on large trees is what the rework set out to fix.
A few notes on the sketch, in case someone else picks it up:
str(surnames) on a list would encode the text "['Smith', 'Jones']" as a single name. HasSoundexName takes one name, so several surnames need one rule each, with the filter set to set_logical_op("or").
get_default_person() returns None when no Home Person is set.
- The surnames can come from
person.get_primary_name().get_surname_list(), then .get_surname() on each (plus alternate names, to be thorough).
HasSoundexName compares every name field, given names included. That is why the Phonetic Filter Rules version adds a “Match in:” option.
On my original question, I found part of an answer: the grouping in the Define Filter rule tree comes from each rule class’s own category attribute, not from the registry. So the encoder rules could use something like category = _("Phonetic filters") instead of landing in General filters. Is that an acceptable use, or is that list of categories meant to stay fixed? And is there a better registry-level way than an ID prefix for one addon to discover another addon’s rules?
Yes. We could add a new category.
Oh yes, by ugly, we should read “note for myself”. As the copy of code was only basic, this might also be translated by unfinished, not tested and incomplete. Handling a list of surnames (or part of name), as well as groups, were ignored by the few lines in python.
Maybe like for alternate place names or variations, a proper design around search and match was missing. So, it was my ugly or lazy contribution.
There might be some translation noise creeping in.
For this technical discussion, could you respond in your native language? I think Claude can better help me with a layered analysis of the response. (Such as: highlighting where cultural differences might shade the interpretation of phrasings.)
Much of the need for different phonetic systems is because of regional dialects and cultures. So let’s avoid “shoehorning” the richness of French into the English language and culture.
Nothing “ugly” about the proposals or the encoding handling.
Simply going through the factory logic (?) “factory” for filtering rules isn’t really direct or “clean”.
For me, it’s good—you’ve listed solutions for more advanced name handling and found a solution for the person filter category.
I wonder what would be the most flexible category name. It is foreseeable that we will also have rules to compensate for common typos (or dyslexia) in addition to phonetic variation.
I’ve been using “fuzzy” … is that appropriately generic?