Hoctar77 commited on
Commit
1cc41a9
Β·
verified Β·
1 Parent(s): c48e66f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +89 -162
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
- """Create and configure the Gradio interface."""
978
- document_types = [
979
- "Advisory Circular",
980
- "Airworthiness Criteria",
981
- "Deviation Memo",
982
- "Exemption",
983
- "Federal Register Notice",
984
- "Order",
985
- "Policy Statement",
986
- "Rule",
987
- "Special Condition",
988
- "Technical Standard Order",
989
- "Other"
990
- ]
991
-
992
- template_types = ["Short AC template AC", "Long AC template AC"]
993
-
994
- custom_css = """
995
- .gradio-container {
996
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
997
- }
998
- .container {
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
- doc_type.change(
1112
- fn=update_template_visibility,
1113
- inputs=[doc_type],
1114
- outputs=[template_type]
1115
- )
1116
 
1117
- submit_btn.click(
1118
- fn=process_document,
1119
- inputs=[file_input, doc_type, template_type],
1120
- outputs=[results]
1121
- )
1122
 
1123
- gr.Markdown(
1124
- """
1125
- ### πŸ“Œ Important Notes
1126
- - This tool is in development; you may encounter false positives
1127
- - For questions or feedback, contact Eric Putnam
1128
- - Results are not stored or saved
 
 
 
 
 
1129
 
1130
- ### πŸ”‘ Key Benefits
1131
- - Saves time on manual document review
1132
- - Ensures consistency across documents
1133
- - Helps maintain compliance with standards
1134
- - Identifies common issues early
 
1135
 
1136
- ### πŸ’‘ Tips for Best Results
1137
- 1. Address high-priority issues first
1138
- 2. Use search/replace for consistent fixes
1139
- 3. Re-run checks after making changes
1140
- 4. Keep your document templates updated
1141
- """
1142
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
 
1144
- return demo
 
 
 
 
 
 
 
 
 
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__":