88
99from typing import Dict , List , Tuple
1010
11- from inclusivewriting .configuration import (
12- get_all_language_resource_config_file ,
13- get_all_language_resources ,
14- )
11+ from inclusivewriting .configuration import get_all_language_resource_config_file
1512from inclusivewriting .rulepacks import load_rulepack
13+ from inclusivewriting .schema_utils import normalize_string_list
1614from inclusivewriting .rules import RuleEngine , RuleMatch
1715
1816
@@ -114,20 +112,14 @@ def __str__(self):
114112 )
115113
116114
117- def _normalize_link_list (field_name : str , value ) -> List [str ]:
118- """
119- Normalize a link-like field to a list of strings.
120- """
121- if value is None :
122- return []
123- if isinstance (value , str ):
124- return [value ]
125- if isinstance (value , list ) and all (isinstance (item , str ) for item in value ):
126- return value
127- raise ValueError (
128- f'Invalid "{ field_name } " format: expected string or list of strings'
115+ def get_all_language_resources (config_file : str = None ):
116+ """Backward-compatible re-export from configuration module."""
117+ from inclusivewriting .configuration import (
118+ get_all_language_resources as _configuration_language_resources ,
129119 )
130120
121+ return _configuration_language_resources (config_file )
122+
131123
132124def _validate_and_build_suggestion (key : str , value : dict ) -> Suggestion :
133125 """
@@ -148,7 +140,7 @@ def _validate_and_build_suggestion(key: str, value: dict) -> Suggestion:
148140 f'Invalid suggestion "{ key } ": "replacement" must be an object'
149141 )
150142
151- lexeme = Lexeme (key , _normalize_link_list ("lexeme" , value .get ("lexeme" )))
143+ lexeme = Lexeme (key , normalize_string_list ("lexeme" , value .get ("lexeme" )))
152144 replacements = []
153145 for replacement_word , replacement_data in value ["replacement" ].items ():
154146 if not isinstance (replacement_data , dict ):
@@ -158,9 +150,9 @@ def _validate_and_build_suggestion(key: str, value: dict) -> Suggestion:
158150
159151 replacement_lexeme = Lexeme (
160152 replacement_word ,
161- _normalize_link_list ("replacement.lexeme" , replacement_data .get ("lexeme" )),
153+ normalize_string_list ("replacement.lexeme" , replacement_data .get ("lexeme" )),
162154 )
163- references = _normalize_link_list (
155+ references = normalize_string_list (
164156 "replacement.references" , replacement_data .get ("references" )
165157 )
166158 replacements .append (Replacement (replacement_lexeme , references ))
0 commit comments