Conditions | 2 |
Total Lines | 24 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
40 | @staticmethod |
||
41 | def mentions_from_JSON(jdict): |
||
42 | """ |
||
43 | Loads `processors.odin.Mention` from a dictionary of JSON data (`jdict`). |
||
44 | |||
45 | Parameters |
||
46 | ---------- |
||
47 | jdict : dict |
||
48 | A dictionary of JSON data encoding a list of `Mention`s and their corresponding `Document`s. |
||
49 | |||
50 | Returns |
||
51 | ------- |
||
52 | [processors.odin.Mention] |
||
53 | A list of `processors.odin.Mention` |
||
54 | """ |
||
55 | # build map of documents |
||
56 | docs_dict = {doc_id:Document.load_from_JSON(djson) for (doc_id, djson) in jdict["documents"].items()} |
||
57 | # deserialize mentions |
||
58 | mns_json = jdict["mentions"] |
||
59 | mentions = [] |
||
60 | for mjson in mns_json: |
||
61 | m = Mention.load_from_JSON(mjson, docs_dict) |
||
62 | mentions.append(m) |
||
63 | return mentions |
||
64 |