diff --git a/panphon/featuretable.py b/panphon/featuretable.py index 0800b79..7659ee3 100644 --- a/panphon/featuretable.py +++ b/panphon/featuretable.py @@ -34,7 +34,7 @@ def segments(self): return self._segments def sort_segments(self): - self.segments.sort(key=self.segment_key) + self._segments.sort(key=self.segment_key) @staticmethod def segment_key(segment_tuple): @@ -76,7 +76,7 @@ def normalize(data: str) -> str: def _read_bases(self, fn: str, weights): fn = pkg_resources.resource_filename(__name__, fn) segments = [] - with open(fn) as f: + with open(fn, encoding="utf8") as f: reader = csv.reader(f) header = next(reader) names = header[1:] @@ -585,4 +585,3 @@ def vector_list_to_word(self, tensor, xsampa=False,fuzzy_search=False): word = self.xsampa.convert(word) return word - diff --git a/panphon/segment.py b/panphon/segment.py index ab42fc1..85f536d 100644 --- a/panphon/segment.py +++ b/panphon/segment.py @@ -2,8 +2,7 @@ from __future__ import annotations -from collections.abc import Iterator, Iterable, Mapping -from typing import TypeVar +from typing import Iterator, Mapping, TypeVar import regex as re T = TypeVar('T') @@ -13,7 +12,7 @@ class Segment(Mapping[str, int]): :param names list[str]: An ordered list of feature names. :param feature dict[str, int]: name-feature pairs for specified features. - :param ftstr str: A string, each /(+|0|-)\w+/ sequence of which is interpreted as a feature specification. + :param ftstr str: A string, each /(+|0|-)\\w+/ sequence of which is interpreted as a feature specification. :param weights list[float]: An ordered list of feature weights/saliences. """ def __init__(self, names: list[str], features: dict[str, int]={}, ftstr: str='', weights: "list[float]"=[]):