【发布时间】:2011-04-30 00:26:30
【问题描述】:
我是一名护士,我知道 python,但我不是专家,只是用它来处理 DNA 序列
我们得到了用人类语言编写的医院记录,我应该将这些数据插入到数据库或 csv 文件中,但它们超过 5000 行,这太难了。所有数据都以一致的格式写入让我给你看一个例子
11/11/2010 - 09:00am : He got nausea, vomiting and died 4 hours later
我应该得到以下数据
Sex: Male
Symptoms: Nausea
Vomiting
Death: True
Death Time: 11/11/2010 - 01:00pm
另一个例子
11/11/2010 - 09:00am : She got heart burn, vomiting of blood and died 1 hours later in the operation room
我得到了
Sex: Female
Symptoms: Heart burn
Vomiting of blood
Death: True
Death Time: 11/11/2010 - 10:00am
当我说 in 时,顺序不一致......所以 in 是一个关键字,之后的所有文本都是一个地方,直到我找到另一个关键字
在开始时,他或她确定性别,得到........接下来是一组症状,我应该根据分隔符拆分,可以是逗号、连字符或其他任何东西,但对于同一行是一致的
死了.....几个小时后也应该得到多少小时,有时病人还活着出院....等
也就是说,我们有很多约定,我认为如果我可以使用关键字和模式对文本进行标记,我就可以完成工作。所以,如果你知道一个有用的函数/模块/教程/工具,最好在 python 中执行此操作(如果不是 python,那么 gui 工具会很好)
一些信息:
there are a lot of rules to express various medical data but here are few examples
- Start with the same date/time format followed by a space followd by a colon followed by a space followed by He/She followed space followed by rules separated by and
- Rules:
* got <symptoms>,<symptoms>,....
* investigations were done <investigation>,<investigation>,<investigation>,......
* received <drug or procedure>,<drug or procedure>,.....
* discharged <digit> (hour|hours) later
* kept under observation
* died <digit> (hour|hours) later
* died <digit> (hour|hours) later in <place>
other rules do exist but they follow the same idea
【问题讨论】:
-
如果你能提供更多的例子,包括有不同命令的例子,或者病人生活/出院的例子,这可能会有所帮助。
-
是否有有效症状的关键字列表?所有记录都会以“他”或“她”开头吗?所有记录都以相同格式的日期/时间开头吗?如果患者出院,记录中是否总是会出现“出院”字样以及“x 小时后”字样?
-
好的,我在问题的底部添加了一些信息。
-
我建议,无论您使用哪种方法,都不要让错误被忽视。处理数据并存储所有明确且清晰解析的内容,同时单独存储其他所有内容。浏览错误,增强解析器,再试一次。最后,如果还有一些记录很难在不破坏解析器的情况下解析,请自己解释它们。
标签: python parsing machine-learning nlp information-extraction