ECDICT includes a hidden field called sw (strip-word). This field is a normalized version of the word where all non-alphanumeric characters are removed and the string is converted to lowercase.
Normalization Logic:
def stripword(word):
return (''.join([ n for n in word if n.isalnum() ])).lower()
How to use it:
When using the match method in stardict.py, pass True as the third parameter to enable fuzzy matching via the sw field.
- Strict Match (
sw parameter is False): Matches the exact string. Searching long-time will only match words starting with long-time (e.g., long-time base). - Fuzzy Match (
sw parameter is True): Matches based on the normalized sw value. Searching long-time will match any word where the sw field starts with longtime (e.g., longtime, long time, long-time base).
This is useful for finding different morphological forms of a word (e.g., transitioning from a hyphenated phrase to a single word) that might not be explicitly indexed in other dictionaries.
# Example of the internal stripword logic used for fuzzy matching
def stripword(word):
return (''.join([ n for n in word if n.isalnum() ])).lower()