nice_relative_time raises KeyError 'now' for equal instants in 18 languages

オープン
#684 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
63/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
json, python
領域
localization

調査の方向性

Start by running the reproduce command to confirm the KeyError: 'now', then read the seconds < 1 branch of nice_relative_time_generic in ovos_date_parser/common.py and _translate_word beside it, plus the matching branch of nice_relative_time_eu in dates_eu.py. Look at how en/pt/fr entries in res/<code>/date_words.json define "now" and mirror that shape in the 18 listed language files, pairing each with a cited Wiktionary sense as the issue does for de, es and ca. Done means equal instants return the language's "now" word instead of raising, and the related date parser tests still pass. The open question is scope: decide with maintainers whether the code should also catch KeyError as a fallback alongside the data fix.

索引モデルが issue の本文から書いたものです。

説明

🤖 Auto-generated by Claude Sonnet 5.5 (claude-sonnet-5-5) via Claude Code — NOT human-reviewed. Verify before acting. The KeyError and the language list were reproduced by running the code on current dev; the "now" words come from the Wiktionary entries named below.

Observed

nice_relative_time raises KeyError: 'now' when the two instants are equal, in 18 languages: ast, az, ca, cs, da, de, es, eu, fa, gl, hu, it, nl, pl, ru, sl, sv, uk.

from datetime import datetime
from ovos_date_parser import nice_relative_time
t = datetime(2024, 1, 5, 15, 30)
nice_relative_time(t, t, "de")   # KeyError: 'now'
nice_relative_time(t, t, "en")   # "now"
nice_relative_time(t, t, "pt")   # "agora"

The res/<code>/date_words.json file of each of these languages has no "now" key.

Expected

An equal instant gives the language's word for "now", as en ("now"), pt ("agora") and fr ("maintenant") do. The code in ovos_date_parser/common.py (nice_relative_time_generic, and nice_relative_time_eu in dates_eu.py) already handles a missing language: it catches NotImplementedError and falls back to a spoken zero of seconds. A missing key raises KeyError instead, so the call crashes where it should answer.

Words for de, es and ca, from Wiktionary: de "jetzt" (de.wiktionary.org/wiki/jetzt, sense [1] "nun, in diesem Moment, zum Zeitpunkt des Sprechens"), es "ahora" (es.wiktionary.org/wiki/ahora, translation en "now"), ca "ara" (ca.wiktionary.org/wiki/ara, translation en "now"). The other 15 languages need a cited word each.

Reproduce

python -c "from datetime import datetime as D; from ovos_date_parser import nice_relative_time as n; t=D(2024,1,5,15,30); print(n(t,t,'de'))"

Ran on dev at c95b418 with chronologia 0.43.0a2: KeyError: 'now' for each of the 18 languages above; en, pt and fr return their word.

Where

ovos_date_parser/common.py, nice_relative_time_generic (the seconds < 1 branch, _translate_word("now", lang)) and _translate_word, which indexes words[keyword]. The same branch in dates_eu.py. The data fix is a "now" key in each of the 18 res/<code>/date_words.json files.

主要言語
Python
スター
0
フォーク
8
平均マージ
13時間 26分
マージ済み PR(30日)
77

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenVoiceOS/ovos-date-parser のほかの issue

OpenVoiceOS/ovos-date-parser の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。