Update app.py
Browse files
app.py
CHANGED
|
@@ -22,17 +22,33 @@ st.markdown("""
|
|
| 22 |
</style>
|
| 23 |
""", unsafe_allow_html=True)
|
| 24 |
|
| 25 |
-
# Define allowed characters
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
def parse_voynich_word(word):
|
| 29 |
-
"""Parse a Voynich word into individual characters -
|
| 30 |
if not word or word.strip() == '':
|
| 31 |
return None, None
|
| 32 |
|
| 33 |
word = word.strip()
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# If no valid characters remain, return None
|
| 38 |
if not chars:
|
|
@@ -179,7 +195,6 @@ def get_download_link_csv(df, filename):
|
|
| 179 |
|
| 180 |
st.title("Voynich Manuscript Analyzer")
|
| 181 |
st.write("Upload your CSV file.")
|
| 182 |
-
st.info(f"**Filtered Character Set:** {' '.join(sorted(ALLOWED_CHARS))}")
|
| 183 |
|
| 184 |
# Upload eva legend to sidebar
|
| 185 |
floating_image_file = st.sidebar.file_uploader("Upload an image",
|
|
|
|
| 22 |
</style>
|
| 23 |
""", unsafe_allow_html=True)
|
| 24 |
|
| 25 |
+
# Define allowed characters (single characters and multi-character tokens)
|
| 26 |
+
ALLOWED_SINGLE_CHARS = set('4O892ERSZPBFVQWXYACIGH1TU0DNM3JKL567')
|
| 27 |
+
ALLOWED_MULTI_CHARS = ['(n)', '(v)']
|
| 28 |
|
| 29 |
def parse_voynich_word(word):
|
| 30 |
+
"""Parse a Voynich word into individual characters - treating (n) and (v) as single units"""
|
| 31 |
if not word or word.strip() == '':
|
| 32 |
return None, None
|
| 33 |
|
| 34 |
word = word.strip()
|
| 35 |
+
chars = []
|
| 36 |
+
i = 0
|
| 37 |
+
|
| 38 |
+
while i < len(word):
|
| 39 |
+
# Check for multi-character tokens first
|
| 40 |
+
if i + 2 < len(word):
|
| 41 |
+
three_char = word[i:i+3]
|
| 42 |
+
if three_char in ALLOWED_MULTI_CHARS:
|
| 43 |
+
chars.append(three_char)
|
| 44 |
+
i += 3
|
| 45 |
+
continue
|
| 46 |
+
|
| 47 |
+
# Otherwise check single character
|
| 48 |
+
if word[i] in ALLOWED_SINGLE_CHARS:
|
| 49 |
+
chars.append(word[i])
|
| 50 |
+
|
| 51 |
+
i += 1
|
| 52 |
|
| 53 |
# If no valid characters remain, return None
|
| 54 |
if not chars:
|
|
|
|
| 195 |
|
| 196 |
st.title("Voynich Manuscript Analyzer")
|
| 197 |
st.write("Upload your CSV file.")
|
|
|
|
| 198 |
|
| 199 |
# Upload eva legend to sidebar
|
| 200 |
floating_image_file = st.sidebar.file_uploader("Upload an image",
|