Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,17 +18,36 @@ def find_strings_with_ending_conditions(text):
|
|
18 |
matches = re.finditer(pattern, text)
|
19 |
return [match.group() for match in matches]
|
20 |
|
|
|
|
|
21 |
|
22 |
-
# Test string
|
23 |
test_string = "LOINC,Detailed_description,exercise,questions of ,216 Exercise activity & pain severity panel 10591 Exercise stress test study 18280 D-Lactate^1st specimen post exercise 18281 D-Lactate^2nd specimen post exercise 18282 D-Lactate^3rd specimen post exercise 18283 D-Lactate^4th specimen post exercise 18284 D-Lactate^5th specimen post exercise 18285 D-Lactate^6th specimen post exercise 18286 D-lactate^pre exercise 24690 Time^post exercise 34256 Breaths^post exercise 34257 Heart rate^post exercise 34262 Gas delivery source^post exercise 34264 Gas flow.oxygen^post exercise 34266 Oxygen saturation^post exercise 34417 Heart beat^pre exercise 34418 Heart rate^post exercise 34420 Oxygen^post exercise 34421 Oxygen saturation^pre exercise 34422 Oxyhemoglobin/Hemoglobin.total^post exercise 37279..."
|
24 |
|
25 |
|
26 |
st.title("String Ending Conditions Matcher")
|
27 |
-
|
28 |
input_text = st.text_area("Enter your text:", value=test_string)
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
if results:
|
33 |
st.write("Matched strings:")
|
34 |
for result in results:
|
|
|
18 |
matches = re.finditer(pattern, text)
|
19 |
return [match.group() for match in matches]
|
20 |
|
21 |
+
def split_at_contiguous_spaces(text):
|
22 |
+
return re.split(r'\s{2,}', text)
|
23 |
|
24 |
+
# Test string - LOINC Panels for Exercise
|
25 |
test_string = "LOINC,Detailed_description,exercise,questions of ,216 Exercise activity & pain severity panel 10591 Exercise stress test study 18280 D-Lactate^1st specimen post exercise 18281 D-Lactate^2nd specimen post exercise 18282 D-Lactate^3rd specimen post exercise 18283 D-Lactate^4th specimen post exercise 18284 D-Lactate^5th specimen post exercise 18285 D-Lactate^6th specimen post exercise 18286 D-lactate^pre exercise 24690 Time^post exercise 34256 Breaths^post exercise 34257 Heart rate^post exercise 34262 Gas delivery source^post exercise 34264 Gas flow.oxygen^post exercise 34266 Oxygen saturation^post exercise 34417 Heart beat^pre exercise 34418 Heart rate^post exercise 34420 Oxygen^post exercise 34421 Oxygen saturation^pre exercise 34422 Oxyhemoglobin/Hemoglobin.total^post exercise 37279..."
|
26 |
|
27 |
|
28 |
st.title("String Ending Conditions Matcher")
|
|
|
29 |
input_text = st.text_area("Enter your text:", value=test_string)
|
30 |
+
|
31 |
+
records = split_at_contiguous_spaces(input_text)
|
32 |
+
|
33 |
+
if records:
|
34 |
+
st.write("Split records:")
|
35 |
+
for record in records:
|
36 |
+
st.write(f"- {record}")
|
37 |
+
else:
|
38 |
+
st.write("No records found.")
|
39 |
+
This code will split the input text wherever there are two or more contiguous spaces and display the split records in the Streamlit app.
|
40 |
+
|
41 |
+
|
42 |
|
43 |
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
results = find_strings_with_ending_conditions(input_text)
|
51 |
if results:
|
52 |
st.write("Matched strings:")
|
53 |
for result in results:
|