
텍스트의 개념을 부정하기위한 스파이 파이프 라인 개체. Negex 알고리즘을 기반으로합니다.
NEGEX- 퇴원 요약에서 부정적인 결과와 질병을 식별하기위한 간단한 알고리즘 Chapman, Bridewell, Hanbury, Cooper, Buchanan https://doi.org/10.1006/jbin.2001.1029
버전 1.0은 파이프 라인 구성 요소 추가를위한 Spacy 3.0의 새로운 인터페이스를 지원하는 주요 버전 업데이트입니다. 결과적으로 이전 버전의 Negspacy와 호환되지 않습니다.
프로젝트가 Spacy 2.3.5 이하를 사용하는 경우 버전 0.1.9를 사용해야합니다. 보관 된 readme를 참조하십시오.
라이브러리를 설치하십시오.
pip install negspacy수입 도서관 및 스파이.
import spacy
from negspacy . negation import Negex스파이어 언어 모델을로드하십시오. Negspacy 파이프 라인 객체를 추가하십시오. 엔티티 유형의 필터링은 선택 사항입니다.
nlp = spacy . load ( "en_core_web_sm" )
nlp . add_pipe ( "negex" , config = { "ent_types" :[ "PERSON" , "ORG" ]})부정을 봅니다.
doc = nlp ( "She does not like Steve Jobs but likes Apple products." )
for e in doc . ents :
print ( e . text , e . _ . negex ) Steve Jobs True
Apple False텍스트 및 프로세스 부정에서 UMLS 개념을 찾으려면 scispacy와 짝을 이루는 것을 고려하십시오.
사용하려면 termset을 지정하면 en_clinical 기본적으로 사용됩니다.
en = 일반 영어 텍스트에 대한 문구en_clinical DEFAULT = 일반 영어에 임상 영역에 특정한 문구를 추가합니다.en_clinical_sensitive = 역사적이고 관련없는 실체를 배제하는 데 도움이되는 추가 문구가 추가됩니다.설정하려면 :
from negspacy . negation import Negex
from negspacy . termsets import termset
ts = termset ( "en" )
nlp = spacy . load ( "en_core_web_sm" )
nlp . add_pipe (
"negex" ,
config = {
"neg_termset" : ts . get_patterns ()
}
)모든 패턴을 자신의 세트로 교체하십시오
nlp = spacy . load ( "en_core_web_sm" )
nlp . add_pipe (
"negex" ,
config = {
"neg_termset" :{
"pseudo_negations" : [ "might not" ],
"preceding_negations" : [ "not" ],
"following_negations" :[ "declined" ],
"termination" : [ "but" , "however" ]
}
}
)내장 된 이용물에서 즉시 개별 패턴을 추가 및 제거하십시오.
from negspacy . termsets import termset
ts = termset ( "en" )
ts . add_patterns ({
"pseudo_negations" : [ "my favorite pattern" ],
"termination" : [ "these are" , "great patterns" , "but" ],
"preceding_negations" : [ "wow a negation" ],
"following_negations" : [ "extra negation" ],
})
#OR
ts . remove_patterns (
{
"termination" : [ "these are" , "great patterns" ],
"pseudo_negations" : [ "my favorite pattern" ],
"preceding_negations" : [ "denied" , "wow a negation" ],
"following_negations" : [ "unlikely" , "extra negation" ],
}
)사용중인 패턴을 봅니다
from negspacy . termsets import termset
ts = termset ( "en_clinical" )
print ( ts . get_patterns ())사용중인 명명 된 엔티티 인식 모델에 따라 명사와 "함께"부정적인 상태가있을 수 있습니다. 예를 들어:
nlp = spacy . load ( "en_core_sci_sm" )
doc = nlp ( "There is no headache." )
for e in doc . ents :
print ( e . text )
# no headache 이로 인해 Negex 알고리즘이 이전 부정을 놓치게됩니다. 이를 설명하려면 chunk_prefix 추가 할 수 있습니다.
nlp = spacy . load ( "en_core_sci_sm" )
ts = termset ( "en_clinical" )
nlp . add_pipe (
"negex" ,
config = {
"chunk_prefix" : [ "no" ],
},
last = True ,
)
doc = nlp ( "There is no headache." )
for e in doc . ents :
print ( e . text , e . _ . negex )
# no headache True 기여
특허
이 라이브러리는 스파이 유니버스에 실 렸습니다. 다른 유용한 라이브러리와 영감을 확인하십시오.
지명 된 엔티티 (예 : 생년월일, 계정 번호 또는 실험실 결과)에 해당하는 값을 추출하여 추출을 살펴보기 위해 Spacy 파이프 라인 객체를 찾고 있다면 추출하십시오.
