Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions panphon/featuretable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:]
Expand Down Expand Up @@ -585,4 +585,3 @@ def vector_list_to_word(self, tensor, xsampa=False,fuzzy_search=False):
word = self.xsampa.convert(word)

return word

5 changes: 2 additions & 3 deletions panphon/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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]"=[]):
Expand Down