Fix/bug en zh (#391)
* [fix]The log retains genuine alerts and errors, while filtering out unnecessary noise. * [fix]Scenario English and Chinese, emotion specifications * [fix]Change the "no data" scenario from 0.0 to None * [fix]The emotional health indicators, emotional advice, and emotional distribution analysis are all linked together. * [fix]The emotional health indicators, emotional advice, and emotional distribution analysis are all linked together. * [fix]Separate expected errors from unexpected errors * [changes]Translation of emotion labels, and the list of hosts arranged in the order of creation * [changes]Translation of emotion labels, and the list of hosts arranged in the order of creation * [fix]The mainframe engineering supports Chinese verification. * [fix]The mainframe engineering supports Chinese verification.
This commit is contained in:
@@ -74,7 +74,7 @@ class OntologyClass(BaseModel):
|
|||||||
"""Validate that the class name follows PascalCase convention.
|
"""Validate that the class name follows PascalCase convention.
|
||||||
|
|
||||||
PascalCase rules:
|
PascalCase rules:
|
||||||
- Must start with an uppercase letter
|
- Must start with an uppercase letter (for English) or any character (for Chinese/Unicode)
|
||||||
- Cannot contain spaces
|
- Cannot contain spaces
|
||||||
- Should not contain special characters except underscores
|
- Should not contain special characters except underscores
|
||||||
|
|
||||||
@@ -90,7 +90,10 @@ class OntologyClass(BaseModel):
|
|||||||
if not v:
|
if not v:
|
||||||
raise ValueError("Class name cannot be empty")
|
raise ValueError("Class name cannot be empty")
|
||||||
|
|
||||||
if not v[0].isupper():
|
# For Chinese/Unicode characters, skip the uppercase check
|
||||||
|
# Only check uppercase for ASCII letters
|
||||||
|
first_char = v[0]
|
||||||
|
if first_char.isascii() and first_char.isalpha() and not first_char.isupper():
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Class name '{v}' must start with an uppercase letter (PascalCase)"
|
f"Class name '{v}' must start with an uppercase letter (PascalCase)"
|
||||||
)
|
)
|
||||||
@@ -100,11 +103,11 @@ class OntologyClass(BaseModel):
|
|||||||
f"Class name '{v}' cannot contain spaces (PascalCase)"
|
f"Class name '{v}' cannot contain spaces (PascalCase)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check for invalid characters (allow alphanumeric and underscore only)
|
# Check for invalid characters (allow alphanumeric, underscore, and Unicode characters)
|
||||||
if not all(c.isalnum() or c == '_' for c in v):
|
if not all(c.isalnum() or c == '_' or ord(c) > 127 for c in v):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Class name '{v}' contains invalid characters. "
|
f"Class name '{v}' contains invalid characters. "
|
||||||
"Only alphanumeric characters and underscores are allowed"
|
"Only alphanumeric characters, underscores, and Unicode characters are allowed"
|
||||||
)
|
)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|||||||
@@ -88,8 +88,10 @@ class OntologyValidator:
|
|||||||
logger.warning(f"Validation failed: {error_msg}")
|
logger.warning(f"Validation failed: {error_msg}")
|
||||||
return False, error_msg
|
return False, error_msg
|
||||||
|
|
||||||
# Check if starts with uppercase letter
|
# Check if starts with uppercase letter (only for ASCII letters)
|
||||||
if not name[0].isupper():
|
# For Chinese/Unicode characters, skip this check
|
||||||
|
first_char = name[0]
|
||||||
|
if first_char.isascii() and first_char.isalpha() and not first_char.isupper():
|
||||||
error_msg = f"Class name '{name}' must start with an uppercase letter (PascalCase)"
|
error_msg = f"Class name '{name}' must start with an uppercase letter (PascalCase)"
|
||||||
logger.warning(f"Validation failed: {error_msg}")
|
logger.warning(f"Validation failed: {error_msg}")
|
||||||
return False, error_msg
|
return False, error_msg
|
||||||
@@ -100,9 +102,9 @@ class OntologyValidator:
|
|||||||
logger.warning(f"Validation failed: {error_msg}")
|
logger.warning(f"Validation failed: {error_msg}")
|
||||||
return False, error_msg
|
return False, error_msg
|
||||||
|
|
||||||
# Check for invalid characters (only alphanumeric and underscore allowed)
|
# Check for invalid characters (allow alphanumeric, underscore, and Unicode characters)
|
||||||
if not re.match(r'^[A-Za-z0-9_]+$', name):
|
if not re.match(r'^[A-Za-z0-9_\u4e00-\u9fff]+$', name):
|
||||||
error_msg = f"Class name '{name}' contains invalid characters. Only alphanumeric characters and underscores are allowed"
|
error_msg = f"Class name '{name}' contains invalid characters. Only alphanumeric characters, underscores, and Chinese characters are allowed"
|
||||||
logger.warning(f"Validation failed: {error_msg}")
|
logger.warning(f"Validation failed: {error_msg}")
|
||||||
return False, error_msg
|
return False, error_msg
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user