Description
Sets a Part-Of-Speech tag to each word within a sentence.
How to use
...
pos = PerceptronModel.pretrained("pos_clinical","en","clinical/models")\
.setInputCols(["token","sentence"])\
.setOutputCol("pos")
pos_pipeline = Pipeline(stages=[document_assembler, sentence_detector, tokenizer, pos])
light_pipeline = LightPipeline(pos_pipeline.fit(spark.createDataFrame([[""]]).toDF("text")))
result = light_pipeline.fullAnnotate("""He was given boluses of MS04 with some effect, he has since been placed on a PCA - he take 80mg of oxycontin at home, his PCA dose is ~ 2 the morphine dose of the oxycontin, he has also received ativan for anxiety.""")
val pos = PerceptronModel.pretrained("pos_clinical","en","clinical/models")
.setInputCols("token","sentence")
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, pos))
val data = Seq("He was given boluses of MS04 with some effect, he has since been placed on a PCA - he take 80mg of oxycontin at home, his PCA dose is ~ 2 the morphine dose of the oxycontin, he has also received ativan for anxiety.").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("en.pos.clinical").predict("""He was given boluses of MS04 with some effect, he has since been placed on a PCA - he take 80mg of oxycontin at home, his PCA dose is ~ 2 the morphine dose of the oxycontin, he has also received ativan for anxiety.""")
Results
[Annotation(pos, 0, 1, NN, {'word': 'He'}),
Annotation(pos, 3, 5, VBD, {'word': 'was'}),
Annotation(pos, 7, 11, VVN, {'word': 'given'}),
Annotation(pos, 13, 19, NNS, {'word': 'boluses'}),
Annotation(pos, 21, 22, II, {'word': 'of'}),
...]
Model Information
Name: | pos_clinical |
Type: | PerceptronModel |
Compatibility: | Spark NLP 2.0.2+ |
License: | Licensed |
Edition: | Official |
Input labels: | [token, sentence] |
Output labels: | [pos] |
Language: | en |
Dependencies: | embeddings_clinical |
Data Source
Trained with MedPost dataset.
NEXTDeidentify RB