Is it possible to import 'Levenshtein distance between two given strings' in order to detect mispelled words in sikuli?

Asked by eduardobedoya

Hi
I would like to detect mispelled words in strings
So, Is it possible to import Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module?
Python also has its own Levenshtein module called 'fuzzywuzzy' module
Is there a way to import any of both in Sikuli??

Thanks Advanced.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

JavaScript modules cannot be imported into a Python/Jython environment.

Wether an available Python module can be used in a Jython environment (SikuliX) depends on the way it is implemented.
Modules written in pure Python language usually can be used with SikuliX (an example are the XLS access modules xl..).
Modules relying on C-based stuff cannot be used.

Revision history for this message
eduardobedoya (gonnabdh) said :
#2

Hi Rainman
I googled,
fuzzywuzzy is written in pure python
please look at this page, it says "the code is pure python and it depends only on the (excellent) difflib python library"
do you think I could try to import it on Sikuli?
How could I do that?

Thanks Advanced.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

I just checked: fuzzywuzzy can be imported with SikuliX.
The usage you have to sort out for yourself.

The steps:
- download from:
https://pypi.python.org/pypi/fuzzywuzzy

- unpack the ...tar.gz

- do NOT run setup!!! (this is for use with Python only)

- in the folder where you have your sikulixsetup stuff (you might use any other folder as well) create a folder Lib (you might name it as you like though, but that is some Python naming convention)

- into this folder copy the folder fuzzywuzzy from the downloaded stuff. (the folder contains a __init__.py)

- in your script add
addImportPath("<absolute path to the above created Lib folder>") # take care for the backslashes!
import fuzzywuzzy as FW
FW.whatever()

Revision history for this message
eduardobedoya (gonnabdh) said :
#4

Thanks RaiMan, that solved my question.