dmort27 / panphon

Python package and data files for manipulating phonological segments (phones, phonemes) in terms of universal phonological features.
MIT License
213 stars 46 forks source link

Can't instantiate abstract class Segment with abstract method __len__ #53

Closed RaidOuahioune closed 1 month ago

RaidOuahioune commented 1 month ago

I was following along with the simple example written in the readme file

import panphon
ft = panphon.FeatureTable()
ft.word_fts(u'swit')

ft.word_fts(u'swit')[0].match({'cor': 1})
True
ft.word_fts(u'swit')[0] >= {'cor': 1}
True
ft.word_fts(u'swit')[1] >= {'cor': 1}
False
ft.word_to_vector_list(u'sauɹ', numeric=False)

By I ended up having this error

{
    "name": "TypeError",
    "message": "Can't instantiate abstract class Segment with abstract method __len__",
    "stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[13], line 2
      1 import panphon
----> 2 ft = panphon.FeatureTable()
      3 ft.word_fts(u'swit')
      5 ft.word_fts(u'swit')[0].match({'cor': 1})

File ~/miniconda3/envs/main/lib/python3.11/site-packages/panphon/featuretable.py:62, in FeatureTable.__init__(self, feature_set)
     60 bases_fn, weights_fn = feature_sets[feature_set]
     61 self.weights = self._read_weights(weights_fn)
---> 62 self.segments, self.seg_dict, self.names = self._read_bases(bases_fn, self.weights)
     63 self.seg_regex = self._build_seg_regex()
     64 self.seg_trie = self._build_seg_trie()

File ~/miniconda3/envs/main/lib/python3.11/site-packages/panphon/featuretable.py:86, in FeatureTable._read_bases(self, fn, weights)
     84         ipa = FeatureTable.normalize(row[0])
     85         vals = [{'-': -1, '0': 0, '+': 1}[x] for x in row[1:]]
---> 86         vec = Segment(names,
     87                       {n: v for (n, v) in zip(names, vals)},
     88                       weights=weights)
     89         segments.append((ipa, vec))
     90 seg_dict = dict(segments)

TypeError: Can't instantiate abstract class Segment with abstract method __len__"
}