sentence = "MH Diagnosis: General anxiety disorder Current MH Medications: Client takes Zoloft 25mg that he just started taking. The criteria do not include level of care recommendations for a primary diagnosis of gambling, caffeine, or nicotine disorders."
diagnosis_keywords: ["Diagnosis:", "primary diagnosis of"]
extraction keywords: ["General anxiety disorder", "gambling, caffeine, or nicotine disorders.", "accident after 12 hours"]
for i in diagnosis_keywords:
if i in sentence:
# How to check whether the "General anxiety disorder" present after "Diagnosis:" keyword in sentence if True then print Diagnosis: General anxiety disorder
Required solution: Diagnosis: General anxiety disorder, Diagnosis: Gambling, caffeine, or nicotine disorders.
有什么辦法可以找出診斷關鍵字后是否存在提取關鍵字。如果是真的,我需要以格式提取解決方案,例如:“診斷:一般焦慮癥”
我需要檢查在任何診斷關鍵字之后出現的一般焦慮癥:[“診斷:”,“初步診斷”]。如果真列印 診斷:一般性焦慮癥。
uj5u.com熱心網友回復:
- 如果您不需要高性能,這里有一個簡單的解決方案:
示例代碼:
sentence = "MH Diagnosis: General anxiety disorder Current MH Medications: Client takes Zoloft 25mg that he just started taking. The criteria do not include level of care recommendations for a primary diagnosis of gambling, caffeine, or nicotine disorders."
diagnosis_keywords = ["Diagnosis:", "primary diagnosis"]
extraction_keywords = ["General anxiety disorder", "of gambling, caffeine, or nicotine disorders.", "accident after 12 hours"]
for dia_word in diagnosis_keywords:
for extra_word in extraction_keywords:
if (dia_word " " extra_word) in sentence:
print(dia_word " " extra_word)
結果:
Diagnosis: General anxiety disorder
primary diagnosis of gambling, caffeine, or nicotine disorders.
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/326716.html
標籤:蟒蛇-3.x
上一篇:按列合并csv檔案
