Skip to content
Merged
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
3 changes: 3 additions & 0 deletions pythainlp/tokenize/budoux.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def segment(text: str) -> list[str]:
_parser = _init_parser()
parser = _parser

if parser is None:
raise RuntimeError("Failed to initialize BudouX parser")

result = cast("list[str]", parser.parse(text))

return result
4 changes: 4 additions & 0 deletions pythainlp/transliterate/thai2rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ def forward(
attn_energies,
self.other.unsqueeze(0).expand(*hidden.size()).transpose(1, 2),
).squeeze(2)
else:
raise ValueError(
f"Unsupported attention method: {self.method!r}"
)

attn_energies = attn_energies.masked_fill(mask == 0, -1e10)

Expand Down
4 changes: 4 additions & 0 deletions pythainlp/transliterate/thaig2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def forward(
attn_energies,
self.other.unsqueeze(0).expand(*hidden.size()).transpose(1, 2),
).squeeze(2)
else:
raise ValueError(
f"Unsupported attention method: {self.method!r}"
)

attn_energies = attn_energies.masked_fill(mask == 0, -1e10)

Expand Down
6 changes: 6 additions & 0 deletions pythainlp/util/thai_lunar_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,14 @@ def to_lunar_date(input_date: date) -> str:
days_in_month = _DAYS_355
elif last_day == 384:
days_in_month = _DAYS_384
else:
raise ValueError(
f"Unexpected last_day value: {last_day!r}. "
"Expected 354, 355, or 384."
)

days_of_year = day_from_one
th_m = 0
for j, days in enumerate(days_in_month, start=1):
th_m = j
if 0 < days_of_year <= days:
Expand Down
Loading