Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,30 @@ def extract_sentence_parts(text):
|
|
12 |
|
13 |
return long_matches
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Test string
|
16 |
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..."
|
17 |
|
18 |
-
|
19 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
return long_matches
|
14 |
|
15 |
+
|
16 |
+
def find_strings_with_ending_conditions(text):
|
17 |
+
pattern = r'([A-Z][\w\s,;:()-]*[.!?](?=\s|$))|([A-Z][\w\s,;:()-]* {5}(?=\s|$))|([A-Z][\w\s,;:()-]*:(?=\s|$))'
|
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 |
+
results = find_strings_with_ending_conditions(input_text)
|
30 |
+
|
31 |
+
|
32 |
+
if results:
|
33 |
+
st.write("Matched strings:")
|
34 |
+
for result in results:
|
35 |
+
st.write(f"- {result}")
|
36 |
+
else:
|
37 |
+
st.write("No strings with the specified ending conditions were found.")
|
38 |
+
|
39 |
+
|
40 |
+
#result = extract_sentence_parts(test_string)
|
41 |
+
#st.write(result)
|