train.py 425 B

12345678910111213141516
  1. import random
  2. import spacy
  3. TRAIN_DATA = [
  4. ("Uber blew through $1 million a week", {'entities': [(0, 4, 'ORG')]}),
  5. ("Google rebrands its business apps", {'entities': [(0, 6, "ORG")]})]
  6. nlp = spacy.blank('fr')
  7. optimizer = nlp.begin_training()
  8. for i in range(20):
  9. random.shuffle(TRAIN_DATA)
  10. for text, annotations in TRAIN_DATA:
  11. nlp.update([text], [annotations], sgd=optimizer)
  12. nlp.to_disk('/model')