PhonologicalCorpusTools / CorpusTools

Phonological CorpusTools
http://phonologicalcorpustools.github.io/CorpusTools/
GNU General Public License v3.0
111 stars 16 forks source link

[BUG] `load_corpus_csv` does not work on example corpus #786

Closed lstolcman closed 2 years ago

lstolcman commented 2 years ago

Describe the bug

Function load_corpus_csv does not work

Minimal example code:

from corpustools.corpus import io

ipa2hayes = io.binary.load_binary('ipa2hayes')

my_corpus = io.csv.load_corpus_csv(
    corpus_name='example_corpus',
    path='example_corpus.csv',
    delimiter='\t',
    annotation_types=None,
    feature_system_path='ipa2hayes',
    stop_check=None,
    call_back=None
    )

result:

(venv) λ python test1.py
Traceback (most recent call last):
  File "C:\dev\test1.py", line 20, in <module>
    my_corpus = io.csv.load_corpus_csv(
  File "C:\dev\venv\lib\site-packages\corpustools\corpus\io\csv.py", line 243, in load_corpus_csv
    word = Word(**d)
  File "C:\dev\venv\lib\site-packages\corpustools\corpus\classes\lexicon.py", line 1141, in __init__
    raise(ValueError('Words must be specified with at least a spelling or a transcription.'))
ValueError: Words must be specified with at least a spelling or a transcription.

Sample corpus file

  1. https://github.com/PhonologicalCorpusTools/CorpusTools/blob/master/examples/example_corpus.txt
  2. cor.csv

To Reproduce Steps to reproduce the behavior:

  1. save sample corpus as file named example_corpus.csv
  2. run code from above

Expected behavior

loaded csv without an error

Screenshots

none

Operating system and PCT version

Additional context

none

stannam commented 2 years ago

Thanks for raising this issue.

We'll take a deeper look into this, but right now the problem seems to be from the setting of the 'annotation_types' parameter. To bypass the problem, could you try loading the files as .corpus using the GUI version?

lstolcman commented 2 years ago

Hi

I am using corpus tools as a library in my python application. I switched to custom csv reader using standard python library, so it is not a blocker anymore for me

kchall commented 2 years ago

Thanks for your interest in the project. It sounds like you may have solved your problem, which is great! That said, while our software is open source and you're welcome to use it however you like, we do not actively provide support for API functionality, only for the GUI interface.