linkgrammar 5.8.1 Help needed to integrate into Python.

27 views
Skip to first unread message

Achuthaperumal Radhakrishnan

unread,
Feb 23, 2021, 4:26:53 AMFeb 23
to link-grammar
Hi,
I have built the linkgrammar 5.8.1 using visual studio 2017 community edition on my windows 10 PC. I tried building for the x64 platform. but lots of warnings and link errors were thrown in the regex library. So I built for win32 configuration. 

I need to use this library with python. So I followed the instructions for permanent installation and copied the built files into a "linkgrammar" folder, added that folder's path into the PYTHONPATH variable. Also, I copied the DLL and "data" folder into the same "linkgrammar" folder. So my linkgrammar folder looks like this:
2021-02-23_14h22_51.png

But when I run the example.py directly, I'm getting the following error:

C:\Users\aca8cob>C:/Users/aca8cob/.conda/envs/py38_32/python.exe c:/Users/aca8cob/Desktop/link-grammar-5.8.1/bindings/python-examples/example.py
Version: link-grammar-5.8.1
link-grammar: Error: Could not open dictionary "en/4.0.dict"
Traceback (most recent call last):
  File "c:/Users/aca8cob/Desktop/link-grammar-5.8.1/bindings/python-examples/example.py", line 41, in <module>
    en_dir = Dictionary() # open the dictionary only once
  File "C:\Users\aca8cob\.conda\envs\py38_32\Lib\linkgrammer\linkgrammar.py", line 387, in __init__
    raise LG_DictionaryError('Error: Failed to open dictionary {!r}'.format(lang))
linkgrammar.LG_DictionaryError: Error: Failed to open dictionary 'en'
I have added regex2.dll path, linkgrammar dll path to the PATH variable.2021-02-23_14h48_23.png

Can anyone please help me with this? for time being, I'm running my scripts using make-check.py. even that only works on this pc! If I clone the complete directory and set the environment variables, I get the same LG_DictionaryError with make-check.py. Any help would be greatly appreciated.

Thank You,
Achuthaperumal RK

Linas Vepstas

unread,
Feb 23, 2021, 11:23:11 AMFeb 23
to link-grammar, Achuthaperumal Radhakrishnan
The code automatically searches several "nearby" directories for the dictionary, including parent directories, and some subdirectories. Thus, somehow the location of the dictionary is not in that search area.

I believe that if you hard-code the location, it will work. Find the line which specifies the language "en" (in example.py), and change "en" to "C:\Users\where\ever\...\data\en" and that should work.

-- Linas

--
You received this message because you are subscribed to the Google Groups "link-grammar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to link-grammar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/link-grammar/46be1bbb-205f-4d7a-81a1-841556cd3f5bn%40googlegroups.com.


--
Patrick: Are they laughing at us?
Sponge Bob: No, Patrick, they are laughing next to us.
 

ami...@gmail.com

unread,
Feb 23, 2021, 1:29:25 PMFeb 23
to link-grammar
Hi,

On Tuesday, 23 February 2021 at 11:26:53 UTC+2 achutha...@gmail.com wrote:
Hi,
I have built the linkgrammar 5.8.1 using visual studio 2017 community edition on my windows 10 PC. I tried building for the x64 platform. but lots of warnings and link errors were thrown in the regex library. So I built for win32 configuration. 

Can it be that your regex library is 32 bit?
 
I need to use this library with python. So I followed the instructions for permanent installation and copied the built files into a "linkgrammar" folder, added that folder's path into the PYTHONPATH variable. Also, I copied the DLL and "data" folder into the same "linkgrammar" folder. So my linkgrammar folder looks like this:
2021-02-23_14h22_51.png

But when I run the example.py directly, I'm getting the following error:

C:\Users\aca8cob>C:/Users/aca8cob/.conda/envs/py38_32/python.exe c:/Users/aca8cob/Desktop/link-grammar-5.8.1/bindings/python-examples/example.py
Version: link-grammar-5.8.1
link-grammar: Error: Could not open dictionary "en/4.0.dict"
Traceback (most recent call last):
  File "c:/Users/aca8cob/Desktop/link-grammar-5.8.1/bindings/python-examples/example.py", line 41, in <module>
    en_dir = Dictionary() # open the dictionary only once
  File "C:\Users\aca8cob\.conda\envs\py38_32\Lib\linkgrammer\linkgrammar.py", line 387, in __init__
    raise LG_DictionaryError('Error: Failed to open dictionary {!r}'.format(lang))
linkgrammar.LG_DictionaryError: Error: Failed to open dictionary 'en'
I have added regex2.dll path, linkgrammar dll path to the PATH variable.2021-02-23_14h48_23.png


The solution of Linas should work for you.
However, in case you would also like to find out why it cannot find the dictionary by its short name, use the parse option verbosity=before opening the dictionary (the Dictionary() call). See the start of example.py for how to set the verbosity parse option.
With verbosity=4, you will get the list of file paths it actually tries to access.
 
Can anyone please help me with this? for time being, I'm running my scripts using make-check.py. even that only works on this pc! If I clone the complete directory and set the environment variables, I get the same LG_DictionaryError with make-check.py. Any help would be greatly appreciated.

It seems as if somehow something is not identical in the two PCs.  Try to use verbosity=4 in your script on both computers, run it by make-check-py, and compare the results.

Thank You,
Achuthaperumal RK

Amir 
Reply all
Reply to author
Forward
0 new messages