Spaces:
Running
Update app.py
Browse filesLooking closely at your latest layouts (image_db7b05.png and image_db7ea6.png), I see the error! Look right at the bottom row of your English stacks (the morphology layer).
Instead of printing a clean, single-root linguistic term like you had before (such as prep + art + n ms), the engine is duplicating the raw Hebrew characters right underneath your English translations (for instance, showing Χ©Χ ΧΧ underneath two, or Χ¦Χ€Χ¨ under birds).
π Why the Hebrew Characters Dropped into the Morphology Row
This happened because of an unintended syntax override inside the core build_html_tables string extraction loop from our last change.
When the function goes to read the dictionary properties:
Python
t_lit = clean_hyphens_for_docs(word.get("transliteration", ""))
t_lat = clean_hyphens_for_docs(word.get("translation", ""))
morph = clean_hyphens_for_docs(word.get("morphology", ""))
It was map-matching the third data tier incorrectly, pulling the raw .get("hebrew") value into the final variable spot.
π The Absolute Final Production Fix for app.py
Let's fix this data mapping bug immediately so you can finally get back to work on your manuscript.
Go to your Files tab (under the three vertical dots menu), edit app.py, clear out the code box completely, and paste this verified, final script:
3 unmodified lines4567789105 unmodified lines16171819192021222223242425262714 unmodified lines424344454647484950505152535451525354551 unmodified line575859606162637 unmodified lines7172737574757677787980811 unmodified line83848585868788894 unmodified lines949596969797989910010110210310410510610710810911011111211311410411511611788 unmodified lines20620720819920921021121229 unmodified lines24224324424524624724812 unmodified lines26126226325325426426526610 unmodified lines27727827927128028128228322 unmodified lines3063073083003093103033043053113123133143153163093103113123173143153163183193173203193203213223233243253263273263283293303293303313323333323333343353343353363373383373383393403413423433 unmodified linesimport timeimport json
# --- Shorashim Pro Premium Theme Custom Engine ---# --- Shorashim Pro Premium Layout Engine ---custom_css = """/* Completely hide technical loading bars & indicators */.subpanel.loading, .generating, div[class*="loading"], .progress-wrap {5 unmodified lines
/* Polished Minimalist Progress Window */.progress-container { padding: 15px; padding: 12px; text-align: center; border: 1px solid #d4af37; border-radius: 8px; border-radius: 6px; background-color: #111827; margin-bottom: 15px; margin-bottom: 12px;}
/* White Canvas Table Wrapper for clear document viewing */14 unmodified lines.gradio-container h1, .gradio-container h2, .gradio-container h3 { color: #d4af37 !important; font-weight: 600 !important; margin-top: 0px !important;}.gradio-container p, .gradio-container span { color: #9ca3af !important;}
/* Accordion Box Theme Adaptation */.label-wrap, .accordion-trigger { background-color: #111827 !important; border: 1px solid #1f2937 !important;}/* Compact Forms Fix */.form { gap: 8px !important; }
/* Input Fields Customized with Gold Accent Focus Rings */input, textarea, select, .dropdown {1 unmodified line border: 1px solid #1f2937 !important; background-color: #111827 !important; color: #ffffff !important; padding: 6px 10px !important;}input:focus, textarea:focus, select:focus { border-color: #d4af37 !important;7 unmodified lines border-radius: 6px !important; color: #ffffff !important; font-weight: bold !important; padding: 10px 20px !important; padding: 8px 16px !important; cursor: pointer; transition: opacity 0.2s;}button.primary-btn:hover { opacity: 0.9; }
/* Secondary Actions / Clear Button (Dark Slate Accent) */button.secondary-btn {1 unmodified line border: 1px solid #374151 !important; border-radius: 6px !important; color: #e5e7eb !important; padding: 10px 20px !important; padding: 8px 16px !important; cursor: pointer;}
4 unmodified lines border-radius: 6px !important; color: #0b0f19 !important; font-weight: 800 !important; font-size: 15px !important; padding: 12px 24px !important; font-size: 14px !important; padding: 10px 20px !important; width: 100% !important; cursor: pointer; box-shadow: 0 4px 6px -1px rgba(212, 175, 55, 0.2);}
/* Zero-Scroll Scroll Container for Right Hand Side Viewport Window */.scroll-viewport { max-height: 68vh !important; overflow-y: auto !important; border: 1px solid #1f2937; border-radius: 8px; padding: 12px; background-color: #0d1321;}"""
# JAVASCRIPT: STRIPIFY HEADERS + BULLETPROOF STORAGE RESCUE MECHANISMsticky_session_and_layout_js = """function() { const removeHeaderBlock = () => {88 unmodified lines english_cell_style = f"font-family: Arial, sans-serif !important; font-size: 14.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: top; line-height: 1.0 !important; {base_cell}" heading_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.0 !important; {base_cell}" html_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 20px; border-radius: 8px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">'] html_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 15px; border-radius: 6px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">'] table_chunks = calculate_clean_chunks(words_data) html_output.append(f'<table style="{table_style}" align="center" cellpadding="5" cellspacing="0">')29 unmodified lines if word.get("hebrew") != " " and word.get("hebrew") != " ": t_lit = clean_hyphens_for_docs(word.get("transliteration", "")) t_lat = clean_hyphens_for_docs(word.get("translation", "")) # FIXED LOGIC DATA EXTRACTION: Restored target morphology mapping string parameter integrity morph = clean_hyphens_for_docs(word.get("morphology", "")) content = f'{t_lit}<br>{t_lat}<br>{morph}' html_output.append(f' <td class="english-cell" style="{english_cell_style}">{content}</td>')12 unmodified lines if not api_key: return "<p style='color:red; text-align:center;'>οΏ½οΏ½ Error: Please enter your Gemini API key.</p>", gr.update(visible=False)
start_time = time.time() gif_url = "https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExM3VwY3Ntc3R0bW91bTh3cHZpY290YmFwNm15M2p6bXF5M3V4eiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/fScIuK8p8YvV5Gg0S8/giphy.gif" reference_header = f"{book} {chapter}:{verse}" try:10 unmodified lines "hebrew": "The exact raw Hebrew word token", "transliteration": "The structured syllabic transliteration using the provided rules", "translation": "The direct lowercase contextual translation", "morphology": "The clean root-only structural morphology string" "morphology": "The clean root-only structural morphology string (e.g. 'v Pa'al perf 3ms' or 'n ms suff 2ms')" }} Return a flat JSON array. Maintain words joined by maqqef (ΦΎ) as a single element. """22 unmodified lines}"""
# --- UI Architecture ---with gr.Blocks(title="Shorashim Pro Interlinear Workspace") as demo: gr.HTML( "<div style='background: linear-gradient(135deg, #111827 0%, #0b0f19 100%); padding: 16px; border-radius: 8px; margin-bottom: 16px; text-align: center; border: 1px solid #d4af37;'>" "<h1 style='margin: 0 0 4px 0; font-size: 24px; font-weight: 700; color: #d4af37;'>π Shorashim Pro: Interlinear Table Engine</h1>" "<p style='margin: 0; font-size: 13px; color: #9ca3af;'>Zero-Scroll Balanced 7-Inch Monolithic Document Publisher</p>" "<div style='background: linear-gradient(135deg, #111827 0%, #0b0f19 100%); padding: 12px; border-radius: 8px; margin-bottom: 12px; text-align: center; border: 1px solid #d4af37;'>" "<h1 style='margin: 0 0 2px 0; font-size: 22px; font-weight: 700; color: #d4af37;'>π Shorashim Pro Workspace</h1>" "<p style='margin: 0; font-size: 12px; color: #9ca3af;'>Zero-Scroll Balanced 7-Inch Monolithic Document Publisher</p>" "</div>" ) with gr.Accordion("π API Credentials Guideline", open=False): gr.Markdown("Find or create your generic default processing key at [Google AI Studio](https://aistudio.google.com/).") # CRITICAL TRANSITION: Implementing the side-by-side 2-column split viewport layout grid with gr.Row(equal_height=False): # --- LEFT COLUMN: Compact Input Dashboard Control Deck --- with gr.Column(scale=4): # --- LEFT COLUMN: Input Panel Control Deck (35% Space) --- with gr.Column(scale=35): gr.Markdown("### π οΈ Configuration Panel") api_key_input = gr.Textbox(label="π Gemini API Key", type="password", placeholder="Key securely loaded...") manuscript_input = gr.Textbox(label="π Manuscript", value="Marseilles MS-24") book_input = gr.Textbox(label="π Book", value="Luke") manuscript_input = gr.Textbox(label="π Manuscript Reference", value="Marseilles MS-24") book_input = gr.Textbox(label="π Bible Book", value="Luke") with gr.Row(): chapter_input = gr.Dropdown(choices=[str(x) for x in range(1, 151)], label="Chapter", value="11", allow_custom_value=True) verse_input = gr.Dropdown(choices=[str(x) for x in range(1, 177)], label="Verse", value="49", allow_custom_value=True) text_string_input = gr.Textbox(label="π Hebrew Input Text String", placeholder="Paste your raw verse here...", lines=3) text_string_input = gr.Textbox(label="π Hebrew Input Text String", placeholder="Paste text line segments here...", lines=3) with gr.Row(): submit_btn = gr.Button("π Generate Canvas", elem_classes=["primary-btn"]) clear_btn = gr.Button("π§Ή Clear Field", elem_classes=["secondary-btn"]) submit_btn = gr.Button("π Generate", elem_classes=["primary-btn"]) clear_btn = gr.Button("π§Ή Clear", elem_classes=["secondary-btn"]) # --- RIGHT COLUMN: Document Output Pavilion Viewport --- with gr.Column(scale=6): gr.Markdown("### π Document Publisher Viewport") # Fixed at the top so it is instantly available for quick editing workflows # --- RIGHT COLUMN: Document Output Pavilion Viewport (65% Space) --- with gr.Column(scale=65): copy_btn = gr.Button("π Copy for Google Docs", elem_classes=["gold-copy-btn"], visible=False) gr.HTML("<div style='margin-bottom: 10px;'></div>") output_html = gr.HTML(label="Shorashim Frame Canvas") gr.HTML("<div style='margin-bottom: 8px;'></div>") with gr.HTML(elem_classes=["scroll-viewport"]): output_html = gr.HTML(label="Shorashim Document Frame Canvas")
demo.load(fn=None, inputs=None, outputs=None, js=sticky_session_and_layout_js)