Skip to content

Commit 4766507

Browse files
Teach L4 only changed rejection words
1 parent 8f6bc2f commit 4766507

8 files changed

Lines changed: 33 additions & 27 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lay"
3-
version = "0.2.212"
3+
version = "0.2.213"
44
edition = "2021"
55
description = "Alpha Double Shift RU/EN layout rescue for Linux desktops"
66
license-file = "LICENSE"

VERSIONING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ number from `git rev-list`.
1313

1414
Current publication branch version:
1515

16-
- `0.2.212`
16+
- `0.2.213`
1717

1818
Do not rely on commit counts. Before publishing or pushing, run the bump script
1919
or verify the version fields manually.

extension/lay@radislabus-star.github.io/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"uuid": "lay@radislabus-star.github.io",
33
"name": "Lay Layout Switcher",
4-
"version": 212,
5-
"version-name": "0.2.212",
4+
"version": 213,
5+
"version-name": "0.2.213",
66
"description": "Alpha GNOME Shell extension для lay-daemon. Показывает EN/RU в трее, переключает раскладку по клику. Минимальный DBus bridge для layout activation и fallback text insert.",
77
"shell-version": ["45", "46", "47", "50"],
88
"url": "https://github.com/radislabus-star/lay-public"

extension/lay@radislabus-star.github.io/prefs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Gtk from 'gi://Gtk';
66
import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
77

88
const CONFIG_PATH = GLib.get_home_dir() + '/.config/lay/config.json';
9-
const APP_VERSION = '0.2.212';
9+
const APP_VERSION = '0.2.213';
1010
const APP_RELEASE_DATE = '2026-07-12';
1111
const APP_URL = 'https://github.com/radislabus-star/lay-public';
1212
const APP_ICON_NAME = 'input-keyboard-symbolic';

extension/lay@radislabus-star.github.io/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import GLib from 'gi://GLib';
44
import Gtk from 'gi://Gtk';
55

66
const CONFIG_PATH = GLib.get_home_dir() + '/.config/lay/config.json';
7-
const APP_VERSION = '0.2.212';
7+
const APP_VERSION = '0.2.213';
88
const APP_RELEASE_DATE = '2026-07-12';
99
const APP_URL = 'https://github.com/radislabus-star/lay-public';
1010
const APP_ICON_NAME = 'input-keyboard-symbolic';

extension/lay@radislabus-star.github.io/tray_support.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const RECENT_ACTIONS_PATH = GLib.get_home_dir() + '/.local/share/lay/rece
77
export const USAGE_COUNTS_PATH = GLib.get_home_dir() + '/.local/share/lay/nanda_wave/word_usage_counts.json';
88
export const PROJECT_DIR = GLib.get_home_dir() + '/projects/lay';
99
export const UPDATE_LOG_PATH = GLib.get_home_dir() + '/.local/state/lay/update.log';
10-
export const APP_VERSION = '0.2.212';
10+
export const APP_VERSION = '0.2.213';
1111
export const APP_DESCRIPTION = 'Альфа: RU/EN-переключатель по двойному Shift и помощь при наборе';
1212
export const APP_RELEASE_DATE = '2026-07-12';
1313
export const APP_LICENSE = 'Non-Commercial';

src/bin/lay_nanda_wave_eval/dirty_log_collect.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,20 +1239,21 @@ fn rejected_usage_events(pair: &DirtyLogPair) -> Vec<Value> {
12391239
if rejected_words.is_empty() {
12401240
return Vec::new();
12411241
}
1242-
let context = previous_context_words(&pair.original);
1243-
rejected_words
1242+
let original_words = normalized_words(&pair.original);
1243+
changed_word_indexes(&original_words, &rejected_words)
12441244
.into_iter()
1245-
.map(|word| {
1246-
json!({
1245+
.filter_map(|index| {
1246+
let word = rejected_words.get(index)?;
1247+
Some(json!({
12471248
"ts": pair.ts,
12481249
"kind": "rejected_candidate",
12491250
"word": word,
1250-
"context": context,
1251+
"context": words_before_index(&original_words, index.min(original_words.len())),
12511252
"from": pair.original.trim(),
12521253
"to": pair.expected.trim(),
12531254
"source": pair.source_id,
12541255
"operation": pair.operation
1255-
})
1256+
}))
12561257
})
12571258
.collect()
12581259
}
@@ -1282,19 +1283,6 @@ fn words_before_index(words: &[String], index: usize) -> Vec<String> {
12821283
.collect()
12831284
}
12841285

1285-
fn previous_context_words(text: &str) -> Vec<String> {
1286-
let mut words = normalized_words(text);
1287-
words.pop();
1288-
words
1289-
.into_iter()
1290-
.rev()
1291-
.take(5)
1292-
.collect::<Vec<_>>()
1293-
.into_iter()
1294-
.rev()
1295-
.collect()
1296-
}
1297-
12981286
fn normalized_words(text: &str) -> Vec<String> {
12991287
text.split_whitespace().filter_map(normalize_word).collect()
13001288
}
@@ -1649,4 +1637,22 @@ mod tests {
16491637
assert_eq!(latest[0].train_role, "positive");
16501638
assert_eq!(latest[0].ts, 2);
16511639
}
1640+
1641+
#[test]
1642+
fn rejected_usage_records_only_the_changed_candidate_word() {
1643+
let value = serde_json::json!({
1644+
"ts": 3,
1645+
"lay_kind": "typing-assist",
1646+
"lay_from": "как попусы ",
1647+
"lay_to": "как опусы "
1648+
});
1649+
let pair = pair_from_correction(&value, "user_rejected_lay_output", "lay_from", "lay_to")
1650+
.expect("negative pair");
1651+
1652+
let events = rejected_usage_events(&pair);
1653+
1654+
assert_eq!(events.len(), 1);
1655+
assert_eq!(events[0]["word"], "опусы");
1656+
assert_eq!(events[0]["context"], serde_json::json!(["как"]));
1657+
}
16521658
}

0 commit comments

Comments
 (0)