Skip to content

Commit

Permalink
More cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Mar 12, 2023
1 parent ab9ad5d commit b12f01f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pyphen/__init__.py
Expand Up @@ -62,7 +62,7 @@ def language_fallback(language):
parts.pop()


class AlternativeParser(object):
class AlternativeParser:
"""Parser of nonstandard hyphen pattern alternative.
The instance returns a special int with data about the current position in
Expand Down Expand Up @@ -103,7 +103,7 @@ def __new__(cls, value, data=None, reference=None):
return obj


class HyphDict(object):
class HyphDict:
"""Hyphenation patterns."""

def __init__(self, path):
Expand All @@ -130,8 +130,7 @@ def __init__(self, path):

# read nonstandard hyphen alternatives
if '/' in pattern and '=' in pattern:
pattern, alternative = pattern.split('/', 1)
factory = AlternativeParser(pattern, alternative)
factory = AlternativeParser(*pattern.split('/', 1))
else:
factory = int

Expand Down Expand Up @@ -196,14 +195,13 @@ def positions(self, word):
slice_ = slice(i + offset, i + offset + len(values))
references[slice_] = map(max, values, references[slice_])

points = [
self.cache[word] = points = [
DataInt(i - 1, reference=reference)
for i, reference in enumerate(references) if reference % 2]
self.cache[word] = points
return points


class Pyphen(object):
class Pyphen:
"""Hyphenation class, with methods to hyphenate strings in various ways."""

def __init__(self, filename=None, lang=None, left=2, right=2, cache=True):
Expand Down

0 comments on commit b12f01f

Please sign in to comment.