Re: Re: Can I get "edit distance" for the suggestions?

Kevin Atkinson <[email protected]>
Newsgroups gmane.comp.gnu.aspell.devel
Message-ID <[email protected]>
>>> All the various indirection in the data structures confuses me, though I
>>> think I've settled in to a proposal for the internal architecture.
>>>
>>> (1) I leave the SuggestionList and SuggestionEnumeration virtual.
>>> (2) In suggest.cpp, I rename the SuggestionList class to SuggestList (so
>> as
>>> not to collide with the new acommon::SuggestionList).
>>> (3) I add a vector of Suggestions to SuggestionListImpl (renamed
>>> SuggestListImpl), parallel to the vector of Strings in the field
>>> "suggestions"; I can call it "scored_suggestions".
>>> (4) When Speller->suggest is called, it calculates scored_suggestions,
>> then
>>> copies that into suggestions and continues as now.
>>> (5) I create a derived class of (new) SuggestionList in suggest.cppwhich
>>> contains SuggestListImpl, called SuggestionListImpl.
>>> (6) Its elements() call returns a SuggestionEnumeration pointing to the
>> the
>>> new scored_suggestions field of its SuggestionListImpl.
>>>     -- I hope this can use MakeEnumeration from enumeration.hpp.
>>> (7) A new method in Speller (maybe "scored_suggest") returns a new
>>> SuggestionList initialized with code common to the existing suggest
>> method.
>>>
>>> An option is to store only the vector of Suggestion and make the
>> enumerator
>>> which returns string suggestions know about the Suggestion structure,
>>> extracting the string it needs from that.  I don't favor that because
>> it's
>>> extra work and doesn't save much space.
>>
>> I'm not sure I 100% understand.  Please show me some what the interface
>> will look like so I can have a better understanding of what you propose.
>
> At the interface level, a dialog will look something like this, matching (as
> far as I understand it) what you asked for:
>
>     AspellSuggestionList * suggestions =
> aspell_speller_scored_suggest(spell_checker,
>                                                           word, size);
>     AspellSuggestionEnumeration * elements =
> aspell_suggestion_list_elements(suggestions);
>     while (!aspell_string_enumeration_atend(aspell_elements))
>     {
>       AspellSuggestion sug =
> aspell_suggestion_enumeration_next(aspell_elements);
>       // Use sug...
>     }
>     delete_aspell_suggestion_enumeration(elements);

Ok that looks good.  AspellSuggestion should proabaly be a const pointer 
rather than an object.

> At a lower level, I'm planning to add memory for an extra vector of
> Suggestion in the class that aspell_speller_suggestion returns (which will
> also be the main part of the class that aspell_speller_scored_suggest
> returns).
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.