From 1c28023bc6e7dcf210fe5fe5e9194115e271b88f Mon Sep 17 00:00:00 2001 From: Mehdi Boutayeb Date: Sun, 13 Sep 2026 12:46:02 +0200 Subject: [PATCH] Escape backslashes in coe.py and text.py string literals cornac/models/coe/coe.py (a `\s`) and cornac/data/text.py (a `\]`) contain invalid escape sequences in non-raw strings, which raise `SyntaxWarning: invalid escape sequence` on Python 3.12+. Cornac's CI runs 3.10 through 3.13. Escaping the backslashes preserves the values. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_014HBQNzAf5C2E3MiJC48HQw --- cornac/data/text.py | 2 +- cornac/models/coe/coe.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cornac/data/text.py b/cornac/data/text.py index 8545206cb..75c168431 100644 --- a/cornac/data/text.py +++ b/cornac/data/text.py @@ -132,7 +132,7 @@ def rm_numeric(t: str) -> str: def rm_punctuation(t: str) -> str: """ - Remove "!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~" from t. + Remove "!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" from t. """ return t.translate(str.maketrans('', '', string.punctuation)) diff --git a/cornac/models/coe/coe.py b/cornac/models/coe/coe.py index 82cc4b0f0..0d2a008f1 100644 --- a/cornac/models/coe/coe.py +++ b/cornac/models/coe/coe.py @@ -18,7 +18,7 @@ import numpy as np import torch -"""Firstly, we define a helper function to generate\sample training ordinal triplets: +"""Firstly, we define a helper function to generate\\sample training ordinal triplets: Step 1: given rated item i, randomly choose item j and check whether rating of j is lower than i, if not randomly sample another item.