{"action":"created","issue":{"url":"https://api.github.com/repos/explosion/spaCy/issues/2711","repository_url":"https://api.github.com/repos/explosion/spaCy","labels_url":"https://api.github.com/repos/explosion/spaCy/issues/2711/labels{/name}","comments_url":"https://api.github.com/repos/explosion/spaCy/issues/2711/comments","events_url":"https://api.github.com/repos/explosion/spaCy/issues/2711/events","html_url":"https://github.com/explosion/spaCy/issues/2711","id":354349602,"node_id":"MDU6SXNzdWUzNTQzNDk2MDI=","number":2711,"title":"KeyError when training the tagger","user":{"login":"ashwinbiyani","id":32535085,"node_id":"MDQ6VXNlcjMyNTM1MDg1","avatar_url":"https://avatars1.githubusercontent.com/u/32535085?v=4","gravatar_id":"","url":"https://api.github.com/users/ashwinbiyani","html_url":"https://github.com/ashwinbiyani","followers_url":"https://api.github.com/users/ashwinbiyani/followers","following_url":"https://api.github.com/users/ashwinbiyani/following{/other_user}","gists_url":"https://api.github.com/users/ashwinbiyani/gists{/gist_id}","starred_url":"https://api.github.com/users/ashwinbiyani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashwinbiyani/subscriptions","organizations_url":"https://api.github.com/users/ashwinbiyani/orgs","repos_url":"https://api.github.com/users/ashwinbiyani/repos","events_url":"https://api.github.com/users/ashwinbiyani/events{/privacy}","received_events_url":"https://api.github.com/users/ashwinbiyani/received_events","type":"User","site_admin":false},"labels":[{"id":514704814,"node_id":"MDU6TGFiZWw1MTQ3MDQ4MTQ=","url":"https://api.github.com/repos/explosion/spaCy/labels/examples","name":"examples","color":"087EA6","default":false},{"id":881665874,"node_id":"MDU6TGFiZWw4ODE2NjU4NzQ=","url":"https://api.github.com/repos/explosion/spaCy/labels/feat%20/%20tagger","name":"feat / tagger","color":"ddfc74","default":false},{"id":111380490,"node_id":"MDU6TGFiZWwxMTEzODA0OTA=","url":"https://api.github.com/repos/explosion/spaCy/labels/usage","name":"usage","color":"087EA6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-27T14:46:11Z","updated_at":"2018-09-28T10:02:07Z","closed_at":"2018-08-29T09:36:11Z","author_association":"NONE","body":"<!-- Describe your issue here. Please keep in mind that the GitHub issue tracker is mostly intended for reports related to the spaCy code base and source, and for bugs and feature requests. If you're looking for help with your code, consider posting a question on StackOverflow instead: http://stackoverflow.com/questions/tagged/spacy -->\r\n\r\n## Your Environment\r\n<!-- Include details of your environment. If you're using spaCy 1.7+, you can also type `python -m spacy info --markdown` and copy-paste the result here.-->\r\n* Operating System:\r\n* Python Version Used:\r\n* spaCy Version Used:\r\n* Environment Information:\r\n\r\n##  Requirement:\r\nTrying to train an existing model with general purpose data available as part of model and specific domain data. need both the data set in the new model created.\r\n\r\n##  Code: \r\n!/usr/bin/env python\r\ncoding: utf8\r\n\r\nfrom __future__ import unicode_literals, print_function\r\n\r\nimport plac\r\nimport random\r\nfrom pathlib import Path\r\nimport spacy\r\n\r\n\r\n\r\nTAG_MAP = {\r\n    'N': {'pos': 'NOUN'},\r\n    'V': {'pos': 'VERB'},\r\n    'J': {'pos': 'ADJ'}\r\n}\r\n\r\n\r\nTRAIN_DATA = [\r\n    (\"I like green eggs\", {'tags': ['N', 'V', 'J', 'N']}),\r\n    (\"Eat blue ham\", {'tags': ['V', 'J', 'N']})\r\n]\r\n\r\n\r\n@plac.annotations(\r\n    lang=(\"ISO Code of language to use\", \"option\", \"l\", str),\r\n    output_dir=(\"Optional output directory\", \"option\", \"o\", Path),\r\n    n_iter=(\"Number of training iterations\", \"option\", \"n\", int))\r\ndef main(lang='en', output_dir=None, n_iter=25):\r\n   \r\n    nlp = spacy.load('en_core_web_sm')\r\n \r\n    nlp.disable_pipes()\r\n    optimizer = nlp.begin_training()\r\n    for i in range(n_iter):\r\n        random.shuffle(TRAIN_DATA)\r\n        losses = {}\r\n        for text, annotations in TRAIN_DATA:\r\n            nlp.update([text], [annotations], sgd=optimizer, losses=losses)\r\n        print(losses)\r\n\r\n\r\n    test_text = \"I like blue eggs\"\r\n    doc = nlp(test_text)\r\n    print('Tags', [(t.text, t.tag_, t.pos_) for t in doc])\r\n\r\n    \r\n    if output_dir is not None:\r\n        output_dir = Path(output_dir)\r\n        if not output_dir.exists():\r\n            output_dir.mkdir()\r\n        nlp.to_disk(output_dir)\r\n        print(\"Saved model to\", output_dir)\r\n\r\n     \r\n        print(\"Loading from\", output_dir)\r\n        nlp2 = spacy.load(output_dir)\r\n        doc = nlp2(test_text)\r\n        print('Tags', [(t.text, t.tag_, t.pos_) for t in doc])\r\n\r\n\r\nif __name__ == '__main__':\r\n    plac.call(main)\r\n\r\n\r\n##  Error:\r\nbase) E:\\projects\\spacy>python train2.py -l en -o E:\\projects\\spacy\\\r\nWarning: Unnamed vectors -- this won't allow multiple vectors models to be loaded. (Shape: (0, 0))\r\nTraceback (most recent call last):\r\n  File \"train2.py\", line 88, in <module>\r\n    plac.call(main)\r\n  File \"E:\\Softwares\\anaconda3\\lib\\site-packages\\plac_core.py\", line 328, in call\r\n    cmd, result = parser.consume(arglist)\r\n  File \"E:\\Softwares\\anaconda3\\lib\\site-packages\\plac_core.py\", line 207, in consume\r\n    return cmd, self.func(*(args + varargs + extraopts), **kwargs)\r\n  File \"train2.py\", line 64, in main\r\n    nlp.update([text], [annotations], sgd=optimizer, losses=losses)\r\n  File \"E:\\Softwares\\anaconda3\\lib\\site-packages\\spacy\\language.py\", line 427, in update\r\n    proc.update(docs, golds, drop=drop, sgd=get_grads, losses=losses)\r\n  File \"pipeline.pyx\", line 480, in spacy.pipeline.Tagger.update\r\n  File \"pipeline.pyx\", line 497, in spacy.pipeline.Tagger.get_loss\r\nKeyError: 'N'\r\n"},"comment":{"url":"https://api.github.com/repos/explosion/spaCy/issues/comments/425387563","html_url":"https://github.com/explosion/spaCy/issues/2711#issuecomment-425387563","issue_url":"https://api.github.com/repos/explosion/spaCy/issues/2711","id":425387563,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTM4NzU2Mw==","user":{"login":"lock[bot]","id":33595554,"node_id":"MDM6Qm90MzM1OTU1NTQ=","avatar_url":"https://avatars1.githubusercontent.com/in/6672?v=4","gravatar_id":"","url":"https://api.github.com/users/lock%5Bbot%5D","html_url":"https://github.com/apps/lock","followers_url":"https://api.github.com/users/lock%5Bbot%5D/followers","following_url":"https://api.github.com/users/lock%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/lock%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/lock%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lock%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/lock%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/lock%5Bbot%5D/repos","events_url":"https://api.github.com/users/lock%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/lock%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2018-09-28T10:02:07Z","updated_at":"2018-09-28T10:02:07Z","author_association":"NONE","body":"This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.\n"}}
{"actor":{"display_login":"lock"}}