import os
import re
from typing import Dict
import jsonlines
from tqdm import tqdm
TARGET = ".data/dialekt_v2_ort.vert"
def process_vert_format(vert_content: str) -> Dict[str, str]:
# Pattern to match document boundaries and extract metadata
doc_pattern = re.compile(r']*>.*?', re.DOTALL)
metadata_pattern = re.compile(
r']*id="([^"]*)"[^>]*prezdivka="([^"]*)"\s*[^>]*>(.*?)', re.DOTALL)
# Pattern to remove whitespace before punctuation
ws_before_punct = re.compile(r'\s+([.,!?])')
# Find all documents
documents = re.findall(doc_pattern, vert_content)
processed_documents = {}
for doc in tqdm(documents):
# Extract metadata
metadata_match = re.search(metadata_pattern, doc)
if metadata_match:
# r'