Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose suggestion scores #524

Closed
wants to merge 3 commits into from

Conversation

kwhumphreys
Copy link

Updated version of Ethan Bradford's patch from #365
Renamed to suggest_plus as suggested at #365 (comment)

Kevin Humphreys added 2 commits March 21, 2017 10:59
// The internal, C++ version of the external Suggest/AspellSuggest
// struct. I don't use that struct because I want the convenience
// of automatically allocated space for the strings.
typedef vector<pair<String,int> > NearMissesFinal;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment from #365 (comment)

A "String" as a struct member will behave in the exact
same fashion of a "String" in a pair. Please use a struct to allow
for the inclusion of additional information in the future.

but I'm not clear on the scope of this change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use something like:

struct Suggestion {
  String word;
  int    score;
};
typedef vector<Suggestion> NearMissesFinal;

And then fix any compile errors.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. I thought that the comment meant to reuse the existing AspellSuggestion struct and was more involved.

@robvanderg
Copy link

robvanderg commented May 4, 2017

When I apply this patch and link with -lm ../headers/libaspell.so.15.2.0 it compiles fine, but at runtime I get:
./binary: symbol lookup error: ./binary: undefined symbol: aspell_speller_suggest_plus

Would you have any idea on how to solve this?

@kwhumphreys
Copy link
Author

@robvanderg on Ubuntu I build with:

RUN curl -O http://ftp.gnu.org/gnu/aspell/aspell-0.60.6.1.tar.gz && \
    tar xzf aspell-0.60.6.1.tar.gz && \
    cd aspell-0.60.6.1 && \
    patch -p1 < aspell-0.60.6.1.patch && \
    ./maintainer/autogen && ./configure && make && make install && ldconfig -v

Try the ldconfig -v?

@robvanderg
Copy link

robvanderg commented May 7, 2017

I Did this:

curl -O http://ftp.gnu.org/gnu/aspell/aspell-0.60.6.1.tar.gz
tar xzf aspell-0.60.6.1.tar.gz
cd aspell-0.60.6.1
wget https://patch-diff.githubusercontent.com/raw/GNUAspell/aspell/pull/524.patch
patch -p1 < 524.patch
./maintainer/autogen && ./configure --prefix=/home/p270396/.local && make && make install && ldconfig -v -n /home/p270396/.local/
/home/p270396/.local:

Then I use interfaces/cc/aspell.h and .libs/libaspell.so.15.1.5 in my c++ code:

    AspellConfig * spell_config = new_aspell_config();
    AspellCanHaveError * possible_err = new_aspell_speller(spell_config);
    AspellSpeller * spell_checker = 0;
    if (aspell_error_number(possible_err) != 0)
        puts(aspell_error_message(possible_err));
    else
        spell_checker = to_aspell_speller(possible_err);
    const AspellSuggestionList * suggestions = aspell_speller_suggest_plus(
                                                      spell_checker,
                                                      word, -1);
    AspellSuggestionEnumeration * elements =
                              aspell_suggestion_list_elements(suggestions);
    const AspellSuggestion * sugg;
    while ( (sugg = aspell_suggestion_enumeration_next(elements)) != NULL )
        cout << sugg->word << '\t' << sugg->score << '\n';
    delete_aspell_suggestion_enumeration(elements);

It works fine with the original aspell. But this one only compiles, during runtime I still get:
./binary: symbol lookup error: ./binary: undefined symbol: aspell_speller_suggest_plus

@robvanderg
Copy link

The patch includes all 3 commits in sequence (just scroll down)
Using aspell_speller_scored_suggest results in uncompilable code. I also tried to clone from this pull request, but I get the same issue. Could you maybe share your aspell-0.60.6.1.patch?

@kwhumphreys
Copy link
Author

Patch attached. This works for me on Ubuntu and OS X (with one additional OS X change).
On Ubuntu strings .libs/libaspell.so.15.1.5 | grep -c aspell_speller_suggest_plus returns 3.

aspell-0.60.6.1.patch.txt

@robvanderg
Copy link

I still get the same error, after I patched a clean download. I attached a minimal example.
compiled with
g++ --std=c++17 -Wall -lm .libs/libaspell.so.15.1.5 main.cc
main.cc.txt

@kwhumphreys
Copy link
Author

export LD_LIBRARY_PATH=/home/p270396/.local/lib/ to make the runtime use the library that you built, instead of the default in /usr/lib/aspell.

./maintainer/autogen && ./configure --prefix=/home/myuser/.local && make && make install && ldconfig -v -n /home/myuser/.local/
cd /home/myuser/.local
g++ main.cc -I./include lib/libaspell.so -lm -o main
export LD_LIBRARY_PATH=/home/myuser/.local/lib/:$LD_LIBRARY_PATH
./main test
test	0
testy	59
teat	73
tests	73
...

@robvanderg
Copy link

The export did the trick; thank you so much for your help!

@kwhumphreys
Copy link
Author

Note that make install tells you to do this.

----------------------------------------------------------------------
Libraries have been installed in:
   /home/myuser/.local/lib/aspell-0.60

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

@kevina kevina modified the milestone: 0.60.7 May 5, 2019
@kevina
Copy link
Member

kevina commented Aug 9, 2019

Closing this in favor of #567.

@kevina kevina closed this Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants