string - Splitting paragraphs using python -
string - Splitting paragraphs using python -
how can separate total paragraph in orderly manner? example: right below string
"'objective: estimate prevalence of post-traumatic stress disorders (ptsd) among adults in field practise areas of authorities medical college, srinagar, india. methodology: nowadays study cross-sectional in nature , conducted in field practice areas of authorities medical college srinagar. 3 blocks of field practise areas of authorities medical college, srinagar comprising of various villages selected. farther 10 per cent of these villages selected method of randomization sampling , 10 per cent of household taken 1 time again systemic random sampling. in selected household adult population (18 years , above) selected , screened using general health questionnaires(ghq). patients screened positive ptsd (post-traumatic stress disorders) assessed , diagnosed. line listing positive cases, prevalence rates calculated. results: of total 3400 subjects (age>/=18 years), prevalence of posttraumatic stress disorders among general population found 3.76%. prevalence found more in females (chi-square test=2.086, p>0.05 (insignificant). of cases found in age grouping 0-40 years. of cases unmarried, illiterate , belong lower socioeconomic class. death of near 1 comprised major traumatic event. acute onset posttraumatic stress disorder commonest type, previous history of psychiatric illness found in 12 % of patients , drug abuse nowadays in 22.6%. conclusion: our findings indicates posttraumatic stress disorders (ptsd) prevalent disorder in developing world, in disaster prone regions , in areas of political unrest. resilience various traumatic events in kashmir has developed on years , might explains lower prevalence of post-traumatic disorder (ptsd) in our study.'"
using python, want accomplish result above few paragraphs these...
"'objective: estimate prevalence of post-traumatic stress disorders (ptsd) among adults in field practise areas of authorities medical college, srinagar, india.
methodology: nowadays study cross-sectional in nature , conducted in field practice areas of authorities medical college srinagar. 3 blocks of field practise areas of authorities medical college, srinagar comprising of various villages selected. farther 10 per cent of these villages selected method of randomization sampling , 10 per cent of household taken 1 time again systemic random sampling. in selected household adult population (18 years , above) selected , screened using general health questionnaires(ghq). patients screened positive ptsd (post-traumatic stress disorders) assessed , diagnosed. line listing positive cases, prevalence rates calculated.
results: of total 3400 subjects (age>/=18 years), prevalence of posttraumatic stress disorders among general population found 3.76%. prevalence found more in females (chi-square test=2.086, p>0.05 (insignificant). of cases found in age grouping 0-40 years. of cases unmarried, illiterate , belong lower socioeconomic class. death of near 1 comprised major traumatic event. acute onset posttraumatic stress disorder commonest type, previous history of psychiatric illness found in 12 % of patients , drug abuse nowadays in 22.6%.
conclusion: our findings indicates posttraumatic stress disorders (ptsd) prevalent disorder in developing world, in disaster prone regions , in areas of political unrest. resilience various traumatic events in kashmir has developed on years , might explains lower prevalence of post-traumatic disorder (ptsd) in our study.'"
lastly, want store each paragraphs string obj, method, result , conclusion. how can that?
this code used:
content = repr(content).replace(".", ".\n") but these, percentage in text such 22.6% split line.
edited: if string belongs object in list?
content = record.get("ab") content = re.split(r"\b\s(?=[^\s:]+:)", content)
is working?
you split on whitespace follows non-word character (e. g. punctuation) , followed single word, followed colon:
obj, method, result, conclusion = re.split(r"\b\s(?=[^\s:]+:)", subject) that work if there 4 substrings obey these rules.
however, appears more specific approach might better:
>>> regex = re.compile(r"""objective:\s(.*?)methodology:\s(.*?) ... results:\s(.*?)conclusion:\s(.*)""", re.s|re.x) >>> obj, method, result, conclusion = regex.match(subject).groups() (where subject contains input string).
python string replace split paragraph
Comments
Post a Comment