0

I'm using the LingPy 1.0.1 library for Python 2.7, attempting to conduct Cognate Analysis on a single tab-delimited list of Spanish-English words I created. The list is named SE.lxs and looks like this:

ID  Words   Spanish
1   dog     pero
2   cat     gato
3   water   agua
4   table   meza
5   hand    mano
6   red     rojo
7   blue    azul
8   green   verde
9   person  persona
10  girl    chica

Which I believe is the appropriate format as defined here: http://lingulist.de/lingpy/docu/lingpy.lexstat.LexStat.html

However, when I run the commands:

lex = LexStat(get_file('C:\Python27\SE.lxs'))

I get the following error:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    lex = LexStat(get_file('C:\Python27\SE.lxs'))
  File "C:\Python27\lib\site-packages\lingpy-1.0.1-py2.7-win32.egg\lingpy\lexstat.py", line 62, in __init__
    self._init_lxs(infile)
  File "C:\Python27\lib\site-packages\lingpy-1.0.1-py2.7-win32.egg\lingpy\lexstat.py", line 278, in _init_lxs
    txt = array(loadtxt(infile),dtype="str")
  File "C:\Python27\lib\site-packages\lingpy-1.0.1-py2.7-win32.egg\lingpy\algorithm\misc.py", line 454, in loadtxt
    f = open(infile)
IOError: [Errno 22] invalid mode ('r') or filename: 'C:\\Python27\\lib\\site-packages\\lingpy-1.0.1-py2.7-win32.egg\\lingpy\\test/tests/lxs/C:\\Python27\\SE.lxs'

A picture of the problem can be found here: https://i.stack.imgur.com/xgUiC.png

Parseltongue
  • 11,157
  • 30
  • 95
  • 160
  • 3
    I think "or filename" in the error message is what you should be concentrating on, not "mode ('r')... Look at the filename. – Wooble Jul 30 '12 at 18:50

2 Answers2

1

Actually, the get_file (blame my bad documentation on this) is a simple shortcut function which helps me to get access to some test modules residing in the text folder. So if you want to make an analysis on some languages, you do not need the get_file argument. Just make sure that the lxs-file is in the folder from where you loaded the library. I am not sure about windows, but on Linux this usually works.

  • Awesome! I ended up giving up on this project because I could not figure out what sort of content the .lxs had to have, but now I can revive it! From what I glean, it should look like this: one column contains the ID, one column contains the items (in plain english), one item contains some foreign language words (I used Swahili) in ipa format?, and the other column contains english in ipa format. However, I couldn't find out how to transform Swahili or English words into their respective IPA equivalents. How do linguists get wordlists in this format? – Parseltongue Aug 02 '12 at 22:19
0

Wooble was right-- apparently the location of the .lxs file must be in both of the following directories (for Python 2.7)

C:\Python27\Lib\site-packages\lingpy-1.0.1-py2.7-win32.egg\lingpy\test\tests
C:\Python27\Lib\lingpy-1.0.1\lingpy\test\tests
Parseltongue
  • 11,157
  • 30
  • 95
  • 160