Comments (3)
With the warning, we are able to see the characters that may need to be preprocessed but it is not always mandatory / necessary. The idea is to log this information to alert the user (we display the ascii conversion made during regexpmatcher operation) but it may be not blocking if these characters are not used in the rules.
If you want to make the conversion yourself to have more control or because your rules are based on some specific characters, you can preprocess the text before using regexpmatcher. In your example, quotes and degree may be managed in a preprocessing step..
Here is a code example with the preprocessing in medkit:
from medkit.core.text import TextDocument
from spacy import displacy
from medkit.text.spacy.displacy_utils import medkit_doc_to_displacy
import json
f = open('trainset.json')
data = json.load(f)
from medkit.text.ner import RegexpMatcher, RegexpMatcherRule
regexp_rules = [
RegexpMatcherRule(regexp=r"\binsuffisance r.nale\b", label="phenotype"),
]
regexp_matcher = RegexpMatcher(rules=regexp_rules)
from medkit.text.preprocessing import Normalizer, NormalizerRule, QUOTATION_RULES
preprocessing_rules = QUOTATION_RULES
preprocessing_rules.append(NormalizerRule("Ā°", "deg"))
preprocessing_op = Normalizer(output_label="clean_segment", rules=preprocessing_rules)
colors = {'phenotype': "#85C1E9"}
options = {"ents": ['phenotype'], "colors": colors}
for i in range(0, len(data)):
s = ' '.join(data[i]['token'])
#s = str(s).encode(encoding = 'ascii', errors = 'replace')
#s = str(s)
doc = TextDocument(text=s)
normalized_segments = preprocessing_op.run([doc.raw_segment])
entities = regexp_matcher.run(normalized_segments)
if(len(entities)>0):
for entity in entities:
doc.add_annotation(entity)
displacy_data = medkit_doc_to_displacy(doc)
displacy.render(displacy_data, manual=True, style="ent", options=options)
break
The quotes are already proposed / managed in medkit with QUOTATION_RULES but degree has not been integrated because it is the same character as number (nĀ°).
If you have suggestion on how it can be more managed in medkit, we are open to improvements.
from medkit.
Thank you @khuynh11 , this is a great solution !
from medkit.
Thanks for your feedback, I close the issue.
from medkit.
Related Issues (7)
- Create first Github issues templates
- Define a workflow for the software development
- Add IAMsystemMatcher (NER) HOT 11
- 'Exclusion_regexp' failed when combined with section segmentation HOT 2
- DucklingMatcher does not seem to work with empty "dims" HOT 1
- iamsystem_matcher n'a pas de propagation d'attribut "is_negated" "is_family" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from medkit.