Skip to content

Instantly share code, notes, and snippets.

@syfluqs
Created June 18, 2017 08:04
Show Gist options
  • Save syfluqs/c188e51fa885104bdae51695bec4e2ba to your computer and use it in GitHub Desktop.
Save syfluqs/c188e51fa885104bdae51695bec4e2ba to your computer and use it in GitHub Desktop.
Zsh script for comparing levenshtein performance
#!/bin/zsh
source=$1
q=$2
echo -n "Levenshtein : "
python -c "import time;import Levenshtein as L;s=time.time();ret=L.ratio('$source','$q');st=time.time()-s;print(round(ret,5),st)"
echo -n "Relevance : "
python -c "import os,time;os.chdir('../kupfer-master');from kupfer.core import relevance;s=time.time();ret=relevance.score('$source','$q');st=time.time()-s;print(round(ret,5),st)"
echo -n "Relevance + Levenshtein : "
python -c "import time;import Levenshtein as L;import os;os.chdir('../kupfer-master');from kupfer.core import relevance;s=time.time();ret=(L.ratio('$source','$q')+relevance.score('$source','$q'))/2;st=time.time()-s;print(round(ret,5),st)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment