I'm trying to extract multiple groups of sentences based on the following logic:
- the first sentence must contain a certain word with alternatives
- keep collecting the following sentences until you you reach a sentence with a specific word with alternatives
Input (made up example):
There is a finding on T2 of spine. The finding is most likely fracture. Additionally, patient seems tired. In L2, patient has there is a circumferential disc bulge with Central disc herniation. In L5, patient seems to have another fracture. In the cervical spine, patient has any degeneration. Patient is may also have fever. L3, endplate edema is also found. In L5, patient may have bruise.
Regex:
[^.]*(cervi(c|x)|C[1-7]|T[1-6]).*\.(?=[^.]*L[1-5][^.]*\.)
Expected Output:
There is a finding on T2 of spine. The finding is most likely fracture. Additionally, patient seems tired.
In the cervical spine, patient has any degeneration. Patient is may also have fever.
Actual Output:
There is a finding on T2 of spine. The finding is most likely fracture. Additionally, patient seems tired. In L2, patient has there is a circumferential disc bulge with Central disc herniation. In L5, patient seems to have another fracture. In the cervical spine, patient has any degeneration. Patient is may also have fever. L3, endplate edema is also found.