""" Inline Text Editing / Post-Edit Layout Annotators directly edit displayed text, with the system tracking insertions, deletions, and substitutions as a structured diff. Used for MT post-editing, grammar correction, text simplification, and paraphrase generation. Research: WMT post-editing shared tasks; MQM-APE (COLING 2025). """ import logging from .identifier_utils import ( safe_generate_layout, generate_element_identifier, generate_validation_attribute, escape_html_content, generate_layout_attributes ) logger = logging.getLogger(__name__) def generate_text_edit_layout(annotation_scheme): """ Generate HTML for an Inline Text Editing interface. Args: annotation_scheme (dict): Configuration including: - name: Schema identifier - description: Display description - source_field: Field in data containing text to edit - show_diff: Whether to show real-time diff highlighting - show_edit_distance: Whether to show edit distance counter - allow_reset: Whether to show "Reset to original" button Returns: tuple: (html_string, key_bindings) """ return safe_generate_layout(annotation_scheme, _generate_text_edit_layout_internal) def _generate_text_edit_layout_internal(annotation_scheme): schema_name = annotation_scheme['name'] description = annotation_scheme['description'] source_field = annotation_scheme.get('source_field', '') show_diff = annotation_scheme.get('show_diff', True) show_edit_distance = annotation_scheme.get('show_edit_distance', True) allow_reset = annotation_scheme.get('allow_reset', True) layout_attrs = generate_layout_attributes(annotation_scheme) validation = generate_validation_attribute(annotation_scheme) identifiers = generate_element_identifier(schema_name, schema_name, "hidden") reset_btn = "" if allow_reset: reset_btn = f""" """ diff_display = "" if show_diff: diff_display = f"""