Skip to content

Instantly share code, notes, and snippets.

View izuna385's full-sized avatar
🏠
Any feedback would be appreciated!

izuna385 izuna385

🏠
Any feedback would be appreciated!
View GitHub Profile
@izuna385
izuna385 / ne_visualize.py
Created July 13, 2020 12:05
How to visualize ne as soon as possible?
import spacy
from spacy import displacy
doc2 = {
"text": "But Google is starting from behind.",
"ents": [{"start": 4, "end": 10, "label": "ORG"}],
"title": None
}
displacy.render(doc2, style="ent", manual=True)
class TypingPredictor:
def __init__(self, typing_model, vocab, args):
self.gpu = args.gpu
self.model = typing_model
self.cuda_device = args.cuda_device
self.sequence_iterator = BasicIterator(batch_size=args.batch_size)
self.sequence_iterator.index_with(vocab)
def tonp(self,tsr):
import spacy # version 2.1.4
import scispacy
nlp = spacy.load('en_core_sci_md')
def prevent_sentence_boundaries(doc):
for i, token in enumerate(doc):
if not can_be_sentence_start(token, doc):
token.is_sent_start = False
return doc
This file has been truncated, but you can view the full file.
dataset umls
dropout 0.5
train 1
bag_size 10
encoder position_cnn
struct_weight 0.5
typing_weight 0
multilabel_linking 0
parent_sample_size 100
bilinear_l2 0.0005