Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2355,10 +2355,11 @@ def create_interface():
|
|
2355 |
issues_count_match = re.search(r'Found (\d+) categories', header)
|
2356 |
issues_count = issues_count_match.group(1) if issues_count_match else len(issues)
|
2357 |
|
2358 |
-
# Format header
|
2359 |
header_html = f"""
|
2360 |
<div class="max-w-4xl mx-auto p-4 bg-white rounded-lg shadow-sm mb-6">
|
2361 |
-
<
|
|
|
2362 |
Found {issues_count} categories of issues that need attention:
|
2363 |
</div>
|
2364 |
</div>
|
@@ -2370,7 +2371,6 @@ def create_interface():
|
|
2370 |
if not section.strip():
|
2371 |
continue
|
2372 |
|
2373 |
-
# Split the section into title and content
|
2374 |
parts = section.strip().split('\n', 1)
|
2375 |
if len(parts) < 2:
|
2376 |
continue
|
@@ -2381,31 +2381,29 @@ def create_interface():
|
|
2381 |
# Extract description and solution
|
2382 |
description_parts = content.split('How to fix:', 1)
|
2383 |
description = description_parts[0].strip()
|
2384 |
-
solution = description_parts[1].split('
|
2385 |
|
2386 |
# Extract examples and issues
|
2387 |
-
examples_match = re.search(r'
|
2388 |
examples_html = ""
|
2389 |
if examples_match:
|
2390 |
examples_text = examples_match.group(0)
|
2391 |
-
incorrect = re.search(r'β\s*([^β]+)', examples_text)
|
2392 |
-
correct = re.search(r'β\s*([^β’\n]+)', examples_text)
|
2393 |
|
2394 |
if incorrect and correct:
|
2395 |
examples_html = f"""
|
2396 |
<div class="mb-4">
|
2397 |
-
<h3 class="font-medium text-gray-800 mb-2">
|
2398 |
<div class="space-y-2 ml-4">
|
2399 |
<div class="text-red-600">
|
2400 |
-
|
2401 |
-
Incorrect:
|
2402 |
</div>
|
2403 |
<div class="text-red-600 ml-8">
|
2404 |
{incorrect.group(1).strip()}
|
2405 |
</div>
|
2406 |
-
<div class="text-green-600">
|
2407 |
-
|
2408 |
-
Correct:
|
2409 |
</div>
|
2410 |
<div class="text-green-600 ml-8">
|
2411 |
{correct.group(1).strip()}
|
@@ -2421,21 +2419,17 @@ def create_interface():
|
|
2421 |
issues_html_section = """
|
2422 |
<div class="mt-4">
|
2423 |
<h3 class="font-medium text-gray-800 mb-2">Issues found in your document:</h3>
|
2424 |
-
<
|
2425 |
"""
|
2426 |
-
for
|
2427 |
issues_html_section += f"""
|
2428 |
-
<
|
2429 |
-
β’ {issue.strip()}
|
2430 |
-
</div>
|
2431 |
"""
|
2432 |
if len(issues_match) > 3:
|
2433 |
issues_html_section += f"""
|
2434 |
-
<
|
2435 |
-
...and {len(issues_match) - 3} more similar issues
|
2436 |
-
</div>
|
2437 |
"""
|
2438 |
-
issues_html_section += "</
|
2439 |
|
2440 |
# Combine the section
|
2441 |
issues_html += f"""
|
@@ -2466,7 +2460,7 @@ def create_interface():
|
|
2466 |
full_html = f"""
|
2467 |
<div class="mx-auto p-4" style="font-family: system-ui, -apple-system, sans-serif;">
|
2468 |
<style>
|
2469 |
-
.text-2xl {{ font-size: 1.5rem; }}
|
2470 |
.text-lg {{ font-size: 1.125rem; }}
|
2471 |
.font-bold {{ font-weight: 700; }}
|
2472 |
.font-semibold {{ font-weight: 600; }}
|
@@ -2487,7 +2481,9 @@ def create_interface():
|
|
2487 |
.mb-4 {{ margin-bottom: 1rem; }}
|
2488 |
.mb-2 {{ margin-bottom: 0.5rem; }}
|
2489 |
.ml-4 {{ margin-left: 1rem; }}
|
|
|
2490 |
.mt-2 {{ margin-top: 0.5rem; }}
|
|
|
2491 |
.p-4 {{ padding: 1rem; }}
|
2492 |
.px-6 {{ padding-left: 1.5rem; padding-right: 1.5rem; }}
|
2493 |
.py-4 {{ padding-top: 1rem; padding-bottom: 1rem; }}
|
@@ -2495,6 +2491,7 @@ def create_interface():
|
|
2495 |
.italic {{ font-style: italic; }}
|
2496 |
.border-b {{ border-bottom: 1px solid #e5e7eb; }}
|
2497 |
.overflow-hidden {{ overflow: hidden; }}
|
|
|
2498 |
</style>
|
2499 |
{header_html}
|
2500 |
{issues_html}
|
@@ -2506,9 +2503,9 @@ def create_interface():
|
|
2506 |
with gr.Blocks() as demo:
|
2507 |
gr.Markdown(
|
2508 |
"""
|
2509 |
-
#
|
2510 |
|
2511 |
-
|
2512 |
This tool checks Word documents for compliance with U.S. federal documentation standards and guidelines, including:
|
2513 |
|
2514 |
- GPO Style Manual requirements
|
@@ -2516,7 +2513,7 @@ def create_interface():
|
|
2516 |
- FAA Orders:
|
2517 |
- Plain Language Guidelines per Plain Writing Act of 2010
|
2518 |
|
2519 |
-
|
2520 |
- Required heading structure and organization
|
2521 |
- Standard terminology usage
|
2522 |
- Proper acronym definitions and usage
|
@@ -2527,7 +2524,7 @@ def create_interface():
|
|
2527 |
- Spacing and punctuation
|
2528 |
- Placeholder content detection
|
2529 |
|
2530 |
-
|
2531 |
1. Upload your Word document (.docx format)
|
2532 |
2. Select the document type
|
2533 |
3. Click "Check Document"
|
|
|
2355 |
issues_count_match = re.search(r'Found (\d+) categories', header)
|
2356 |
issues_count = issues_count_match.group(1) if issues_count_match else len(issues)
|
2357 |
|
2358 |
+
# Format header with title
|
2359 |
header_html = f"""
|
2360 |
<div class="max-w-4xl mx-auto p-4 bg-white rounded-lg shadow-sm mb-6">
|
2361 |
+
<h1 class="text-2xl font-bold mb-4">Document Check Results Summary</h1>
|
2362 |
+
<div class="text-lg text-amber-600">
|
2363 |
Found {issues_count} categories of issues that need attention:
|
2364 |
</div>
|
2365 |
</div>
|
|
|
2371 |
if not section.strip():
|
2372 |
continue
|
2373 |
|
|
|
2374 |
parts = section.strip().split('\n', 1)
|
2375 |
if len(parts) < 2:
|
2376 |
continue
|
|
|
2381 |
# Extract description and solution
|
2382 |
description_parts = content.split('How to fix:', 1)
|
2383 |
description = description_parts[0].strip()
|
2384 |
+
solution = description_parts[1].split('Example Fix:', 1)[0].strip() if len(description_parts) > 1 else ""
|
2385 |
|
2386 |
# Extract examples and issues
|
2387 |
+
examples_match = re.search(r'Example Fix:\s*β[^β]+β[^β’]+', content, re.MULTILINE | re.DOTALL)
|
2388 |
examples_html = ""
|
2389 |
if examples_match:
|
2390 |
examples_text = examples_match.group(0)
|
2391 |
+
incorrect = re.search(r'β\s*Incorrect:\s*([^β]+)', examples_text)
|
2392 |
+
correct = re.search(r'β\s*Correct:\s*([^β’\n]+)', examples_text)
|
2393 |
|
2394 |
if incorrect and correct:
|
2395 |
examples_html = f"""
|
2396 |
<div class="mb-4">
|
2397 |
+
<h3 class="font-medium text-gray-800 mb-2">Example Fix:</h3>
|
2398 |
<div class="space-y-2 ml-4">
|
2399 |
<div class="text-red-600">
|
2400 |
+
β Incorrect:
|
|
|
2401 |
</div>
|
2402 |
<div class="text-red-600 ml-8">
|
2403 |
{incorrect.group(1).strip()}
|
2404 |
</div>
|
2405 |
+
<div class="text-green-600 mt-2">
|
2406 |
+
β Correct:
|
|
|
2407 |
</div>
|
2408 |
<div class="text-green-600 ml-8">
|
2409 |
{correct.group(1).strip()}
|
|
|
2419 |
issues_html_section = """
|
2420 |
<div class="mt-4">
|
2421 |
<h3 class="font-medium text-gray-800 mb-2">Issues found in your document:</h3>
|
2422 |
+
<ul class="list-none space-y-2">
|
2423 |
"""
|
2424 |
+
for issue in issues_match[:3]:
|
2425 |
issues_html_section += f"""
|
2426 |
+
<li class="text-gray-600 ml-4">β’ {issue.strip()}</li>
|
|
|
|
|
2427 |
"""
|
2428 |
if len(issues_match) > 3:
|
2429 |
issues_html_section += f"""
|
2430 |
+
<li class="text-gray-500 italic ml-4">...and {len(issues_match) - 3} more similar issues</li>
|
|
|
|
|
2431 |
"""
|
2432 |
+
issues_html_section += "</ul></div>"
|
2433 |
|
2434 |
# Combine the section
|
2435 |
issues_html += f"""
|
|
|
2460 |
full_html = f"""
|
2461 |
<div class="mx-auto p-4" style="font-family: system-ui, -apple-system, sans-serif;">
|
2462 |
<style>
|
2463 |
+
.text-2xl {{ font-size: 1.5rem; line-height: 2rem; }}
|
2464 |
.text-lg {{ font-size: 1.125rem; }}
|
2465 |
.font-bold {{ font-weight: 700; }}
|
2466 |
.font-semibold {{ font-weight: 600; }}
|
|
|
2481 |
.mb-4 {{ margin-bottom: 1rem; }}
|
2482 |
.mb-2 {{ margin-bottom: 0.5rem; }}
|
2483 |
.ml-4 {{ margin-left: 1rem; }}
|
2484 |
+
.ml-8 {{ margin-left: 2rem; }}
|
2485 |
.mt-2 {{ margin-top: 0.5rem; }}
|
2486 |
+
.mt-4 {{ margin-top: 1rem; }}
|
2487 |
.p-4 {{ padding: 1rem; }}
|
2488 |
.px-6 {{ padding-left: 1.5rem; padding-right: 1.5rem; }}
|
2489 |
.py-4 {{ padding-top: 1rem; padding-bottom: 1rem; }}
|
|
|
2491 |
.italic {{ font-style: italic; }}
|
2492 |
.border-b {{ border-bottom: 1px solid #e5e7eb; }}
|
2493 |
.overflow-hidden {{ overflow: hidden; }}
|
2494 |
+
.list-none {{ list-style-type: none; }}
|
2495 |
</style>
|
2496 |
{header_html}
|
2497 |
{issues_html}
|
|
|
2503 |
with gr.Blocks() as demo:
|
2504 |
gr.Markdown(
|
2505 |
"""
|
2506 |
+
<h1 style="color: #ea580c; font-size: 1.5rem; font-weight: bold; margin-bottom: 1rem;">π FAA Document Checker Tool</h1>
|
2507 |
|
2508 |
+
<h2 style="color: #ea580c; font-size: 1.25rem; font-weight: 600; margin-top: 1rem;">Purpose</h2>
|
2509 |
This tool checks Word documents for compliance with U.S. federal documentation standards and guidelines, including:
|
2510 |
|
2511 |
- GPO Style Manual requirements
|
|
|
2513 |
- FAA Orders:
|
2514 |
- Plain Language Guidelines per Plain Writing Act of 2010
|
2515 |
|
2516 |
+
<h2 style="color: #ea580c; font-size: 1.25rem; font-weight: 600; margin-top: 1rem;">Validation Checks Include:</h2>
|
2517 |
- Required heading structure and organization
|
2518 |
- Standard terminology usage
|
2519 |
- Proper acronym definitions and usage
|
|
|
2524 |
- Spacing and punctuation
|
2525 |
- Placeholder content detection
|
2526 |
|
2527 |
+
<h2 style="color: #ea580c; font-size: 1.25rem; font-weight: 600; margin-top: 1rem;">How to Use</h2>
|
2528 |
1. Upload your Word document (.docx format)
|
2529 |
2. Select the document type
|
2530 |
3. Click "Check Document"
|