Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -974,174 +974,101 @@ def format_markdown_results(results: Dict[str, DocumentCheckResult], doc_type: s
|
|
974 |
return "\n".join(output)
|
975 |
|
976 |
def create_interface():
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
max-width: 900px;
|
1000 |
-
margin: auto;
|
1001 |
-
}
|
1002 |
-
.alert {
|
1003 |
-
padding: 1rem;
|
1004 |
-
margin-bottom: 1rem;
|
1005 |
-
border-radius: 0.5rem;
|
1006 |
-
background-color: #f8f9fa;
|
1007 |
-
border: 1px solid #dee2e6;
|
1008 |
-
}
|
1009 |
-
.results-panel {
|
1010 |
-
max-height: 800px;
|
1011 |
-
overflow-y: auto;
|
1012 |
-
padding: 1rem;
|
1013 |
-
background-color: #ffffff;
|
1014 |
-
border-radius: 0.5rem;
|
1015 |
-
border: 1px solid #e9ecef;
|
1016 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
1017 |
-
}
|
1018 |
-
.info-box {
|
1019 |
-
background-color: #e7f3ff;
|
1020 |
-
padding: 1rem;
|
1021 |
-
border-radius: 0.5rem;
|
1022 |
-
margin: 1rem 0;
|
1023 |
-
}
|
1024 |
-
.warning-box {
|
1025 |
-
background-color: #fff3cd;
|
1026 |
-
padding: 1rem;
|
1027 |
-
border-radius: 0.5rem;
|
1028 |
-
margin: 1rem 0;
|
1029 |
-
}
|
1030 |
-
"""
|
1031 |
-
|
1032 |
-
with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
1033 |
-
gr.Markdown(
|
1034 |
-
"""
|
1035 |
-
# π Document Checker Tool
|
1036 |
-
|
1037 |
-
### Purpose
|
1038 |
-
This tool checks Word documents for compliance with U.S. federal documentation standards.
|
1039 |
-
|
1040 |
-
### Features
|
1041 |
-
- β Heading format and structure checks
|
1042 |
-
- β Terminology and style verification
|
1043 |
-
- β Figure and table caption validation
|
1044 |
-
- β Section symbol and abbreviation usage
|
1045 |
-
- β Date format standardization
|
1046 |
-
|
1047 |
-
### Supported Document Types
|
1048 |
-
- Advisory Circulars
|
1049 |
-
- Orders
|
1050 |
-
- Policy Statements
|
1051 |
-
- Federal Register Notices
|
1052 |
-
- Technical Standard Orders
|
1053 |
-
- And more...
|
1054 |
-
"""
|
1055 |
-
)
|
1056 |
-
|
1057 |
-
with gr.Row():
|
1058 |
-
with gr.Column(scale=1):
|
1059 |
-
with gr.Group():
|
1060 |
-
file_input = gr.File(
|
1061 |
-
label="π Upload Word Document (.docx)",
|
1062 |
-
file_types=[".docx"],
|
1063 |
-
type="binary",
|
1064 |
-
elem_classes="file-input"
|
1065 |
-
)
|
1066 |
-
|
1067 |
-
doc_type = gr.Dropdown(
|
1068 |
-
choices=document_types,
|
1069 |
-
label="π Document Type",
|
1070 |
-
value="Advisory Circular",
|
1071 |
-
info="Select the type of document you're checking",
|
1072 |
-
elem_classes="doc-type-select"
|
1073 |
-
)
|
1074 |
-
|
1075 |
-
template_type = gr.Radio(
|
1076 |
-
choices=template_types,
|
1077 |
-
label="π Template Type",
|
1078 |
-
visible=False,
|
1079 |
-
info="Only applicable for Advisory Circulars",
|
1080 |
-
elem_classes="template-type-select"
|
1081 |
-
)
|
1082 |
-
|
1083 |
-
submit_btn = gr.Button(
|
1084 |
-
"π Check Document",
|
1085 |
-
variant="primary",
|
1086 |
-
elem_classes="submit-button"
|
1087 |
-
)
|
1088 |
-
|
1089 |
-
with gr.Group():
|
1090 |
-
gr.Markdown(
|
1091 |
-
"""
|
1092 |
-
### π Quick Tips
|
1093 |
-
1. Ensure document is clean (no track changes)
|
1094 |
-
2. Save any pending changes before upload
|
1095 |
-
3. Check document type selection
|
1096 |
-
4. Review results in priority order
|
1097 |
-
""",
|
1098 |
-
elem_classes="tips-section"
|
1099 |
-
)
|
1100 |
-
|
1101 |
-
with gr.Column(scale=2):
|
1102 |
-
results = gr.Markdown(
|
1103 |
-
label="Check Results",
|
1104 |
-
value="Results will appear here after processing...",
|
1105 |
-
elem_classes=["results-panel"]
|
1106 |
-
)
|
1107 |
-
|
1108 |
-
def update_template_visibility(doc_type):
|
1109 |
-
return gr.update(visible=doc_type == "Advisory Circular")
|
1110 |
|
1111 |
-
|
1112 |
-
|
1113 |
-
inputs=[doc_type],
|
1114 |
-
outputs=[template_type]
|
1115 |
-
)
|
1116 |
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
)
|
1122 |
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
|
|
|
|
|
|
|
|
|
|
1129 |
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
|
|
1135 |
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1143 |
|
1144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1145 |
|
1146 |
# Initialize and launch the interface
|
1147 |
if __name__ == "__main__":
|
|
|
974 |
return "\n".join(output)
|
975 |
|
976 |
def create_interface():
|
977 |
+
"""Create and configure the Gradio interface."""
|
978 |
+
|
979 |
+
document_types = [
|
980 |
+
"Advisory Circular",
|
981 |
+
"Airworthiness Criteria",
|
982 |
+
"Deviation Memo",
|
983 |
+
"Exemption",
|
984 |
+
"Federal Register Notice",
|
985 |
+
"Order",
|
986 |
+
"Policy Statement",
|
987 |
+
"Rule",
|
988 |
+
"Special Condition",
|
989 |
+
"Technical Standard Order",
|
990 |
+
"Other"
|
991 |
+
]
|
992 |
+
|
993 |
+
template_types = ["Short AC template AC", "Long AC template AC"]
|
994 |
+
|
995 |
+
with gr.Blocks() as demo:
|
996 |
+
gr.Markdown(
|
997 |
+
"""
|
998 |
+
# π Document Checker Tool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
999 |
|
1000 |
+
### Purpose
|
1001 |
+
This tool checks Word documents for compliance with U.S. federal documentation standards.
|
|
|
|
|
|
|
1002 |
|
1003 |
+
### How to Use
|
1004 |
+
1. Upload your Word document (.docx format)
|
1005 |
+
2. Select the document type
|
1006 |
+
3. Click "Check Document"
|
|
|
1007 |
|
1008 |
+
> **Note:** Please ensure your document is clean (no track changes or comments)
|
1009 |
+
"""
|
1010 |
+
)
|
1011 |
+
|
1012 |
+
with gr.Row():
|
1013 |
+
with gr.Column(scale=1):
|
1014 |
+
file_input = gr.File(
|
1015 |
+
label="π Upload Word Document (.docx)",
|
1016 |
+
file_types=[".docx"],
|
1017 |
+
type="binary"
|
1018 |
+
)
|
1019 |
|
1020 |
+
doc_type = gr.Dropdown(
|
1021 |
+
choices=document_types,
|
1022 |
+
label="π Document Type",
|
1023 |
+
value="Advisory Circular",
|
1024 |
+
info="Select the type of document you're checking"
|
1025 |
+
)
|
1026 |
|
1027 |
+
template_type = gr.Radio(
|
1028 |
+
choices=template_types,
|
1029 |
+
label="π Template Type",
|
1030 |
+
visible=False,
|
1031 |
+
info="Only applicable for Advisory Circulars"
|
1032 |
+
)
|
1033 |
+
|
1034 |
+
submit_btn = gr.Button(
|
1035 |
+
"π Check Document",
|
1036 |
+
variant="primary"
|
1037 |
+
)
|
1038 |
+
|
1039 |
+
with gr.Column(scale=2):
|
1040 |
+
results = gr.Component("DocumentCheckerResults",
|
1041 |
+
value=None,
|
1042 |
+
render=False
|
1043 |
+
)
|
1044 |
+
|
1045 |
+
# Update template type visibility based on document type
|
1046 |
+
def update_template_visibility(doc_type):
|
1047 |
+
return gr.update(visible=doc_type == "Advisory Circular")
|
1048 |
+
|
1049 |
+
doc_type.change(
|
1050 |
+
fn=update_template_visibility,
|
1051 |
+
inputs=[doc_type],
|
1052 |
+
outputs=[template_type]
|
1053 |
+
)
|
1054 |
+
|
1055 |
+
# Handle document processing
|
1056 |
+
submit_btn.click(
|
1057 |
+
fn=process_document,
|
1058 |
+
inputs=[file_input, doc_type, template_type],
|
1059 |
+
outputs=[results]
|
1060 |
+
)
|
1061 |
|
1062 |
+
gr.Markdown(
|
1063 |
+
"""
|
1064 |
+
### π Important Notes
|
1065 |
+
- This tool is in development; you may encounter false positives
|
1066 |
+
- For questions or feedback, contact Eric Putnam
|
1067 |
+
- Results are not stored or saved
|
1068 |
+
"""
|
1069 |
+
)
|
1070 |
+
|
1071 |
+
return demo
|
1072 |
|
1073 |
# Initialize and launch the interface
|
1074 |
if __name__ == "__main__":
|