Индексы объектов инструмента аннотации Spacy

String a = new String("foo");
String b = new String("foo");
System.out.println(a == b); // prints false
System.out.println(a.equals(b)); // prints true

Убедитесь, что вы понимаете, почему. Это потому, что сравнение == сравнивает только ссылки; equals() метод сопоставляет содержимое по символу.

Когда вы вызываете new для a и b, каждый получает новую ссылку, указывающую на "foo" в таблице строк. Ссылки разные, но контент один и тот же.

2
задан Pikachu the Watermelon Wizard 10 March 2019 в 01:03
поделиться

1 ответ

Обучение Json: - [{ "text": "This Labor-Contract ('CONTRACT'), effective as of May 12, 2017 (“Effective Date”), is made by and between Client-ABC, Inc. ('Client-ABC'), having its principal place of business at 1030 Client-ABC Street, Atlanta, GA 30318, USA and Supplier-ABC (“Supplier”), having a place of business at 100 Park Avenue, Miami, 10178, USA (hereinafter referred to individually as “Party” and collectively as “Parties”).", "entities": [ [ 50, 62, "EFFECTIVE_DATE" ], [ 106, 116, "VENDOR_NAME" ], [ 181, 203, "VENDOR_ADDRESS" ], [ 205, 212, "VENDOR_CITY" ], [ 214, 216, "VENDOR_STATE" ], [ 217, 222, "VENDOR_POSTAL_CODE" ], [ 224, 227, "VENDOR_COUNTRY" ] ] },{second training data}]

Код для обучения на заказ: -

training_pickel_file = "training_pickel_file.json"
with open(training_pickel_file) as input:
TRAIN_DATA = json.load(input)
for annotations in TRAIN_DATA:
   for ent in annotations["entities"]:
      ner.add_label(ent[2])
other_pipes = [pipe for pipe in nlp.pipe_names if pipe != 'ner']
with nlp.disable_pipes(*other_pipes):  # only train NER
    optimizer = nlp.begin_training()
    for itn in range(n_iter):
        random.shuffle(TRAIN_DATA)
        losses = {}
        for a in TRAIN_DATA:
            doc = nlp.make_doc(a["text"])
            gold = GoldParse(doc, entities = a["entities"])
            nlp.update([doc], [gold], drop =0.5, sgd=optimizer, losses = losses)
        print('Losses', losses)
0
ответ дан Chandan Gupta 10 March 2019 в 01:03
поделиться
Другие вопросы по тегам:

Похожие вопросы: