More fixes to lexical scan

This commit is contained in:
2024-05-06 10:05:43 +01:00
parent 228a42ed60
commit a5f8e153a2
12 changed files with 152 additions and 105 deletions

View File

@@ -1,5 +1,4 @@
import json5
#import pandas as pd
import sys
import argparse
from chameleon import PageTemplateFile,PageTemplate
@@ -11,6 +10,12 @@ import pkg_resources
from datetime import datetime
import xml.etree.ElementTree as ET
#
#To Do
# 1. Get routing working
# 2. Deal with ? and ! as sentence ends in text-format
# 3. Make lexical scan work with double or single quotes (if possible)
SME2Gen_version = '0.7'
json5_dict: dict = {}
json5_html_list: list = []
@@ -440,13 +445,13 @@ if __name__ == "__main__":
left_str = hl('prefix')+"_"+lex_message
right_str = lex_message
right_str = right_str.replace("_"," ")
print(f"Right:{right_str}")
right_str = format_text(right_str)
left_str = left_str.replace(" ","_")
words = left_str.split('_')[:6]
left_str = "_".join(words)
next_lex_str = {"orig":original_str,"left":left_str,"right":right_str}
string_lib.append(next_lex_str)
#print(string_lib)
#And write it to lex file
# Now process them one by one into the lexical file
lex_all = "";
@@ -466,7 +471,7 @@ if __name__ == "__main__":
left_str = item["left"]
right_str = item["right"]
# Replace all occurrences of original string with left string in 'contents'
file_content = file_content.replace(original_str, left_str)
file_content = file_content.replace("l('"+original_str+"')", "l('"+left_str+"')")
# and write it back
with open(filename, 'w') as file:
file.write(file_content)