문제

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: http://i.imgur.com/XdLig.png

도움이 되었습니까?

해결책

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.

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top