1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

""" 

:Author: Daniel Mohr 

:Email: daniel.mohr@dlr.de 

:Date: 2021-03-19 (last change). 

:License: GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007. 

""" 

 

import json 

 

from .get_property import get_property 

from .ispending import ispending 

 

 

def add_property_to_object( 

schemaorg_data, item, 

domain_includes, word, properties, missing_words): 

""" 

:Author: Daniel Mohr 

:Date: 2021-03-16 

""" 

# pylint: disable=too-many-arguments 

22 ↛ 23line 22 didn't jump to line 23, because the condition on line 22 was never true if "@id" not in domain_includes: 

raise NotImplementedError(json.dumps(item, indent=2)) 

if domain_includes["@id"] == "schema:" + word: 

25 ↛ 26line 25 didn't jump to line 26, because the condition on line 25 was never true if "@id" not in item: 

raise NotImplementedError(json.dumps(item, indent=2)) 

prop_name = item["@id"].split('schema:')[1] # e. g.: additionalName 

get_property(schemaorg_data, properties, prop_name, missing_words) 

# if item["@type"] == "rdf:Property": 

# pass 

 

 

def add_properties_to_object(schemaorg_data, word, properties, missing_words): 

""" 

:Author: Daniel Mohr 

:Date: 2021-03-16 

 

item: 

 

{ 

"@id": "schema:additionalName", 

"@type": "rdf:Property", 

"rdfs:comment": "An additional name for a Person, 

can be used for a middle name.", 

"rdfs:label": "additionalName", 

"schema:domainIncludes": { 

"@id": "schema:Person" 

}, 

"schema:rangeIncludes": { 

"@id": "schema:Text" 

} 

}, 

""" 

for item in schemaorg_data['@graph']: 

if (("schema:domainIncludes" in item) and (not ispending(item))): 

if isinstance(item["schema:domainIncludes"], dict): 

add_property_to_object( 

schemaorg_data, item, item["schema:domainIncludes"], 

word, properties, missing_words) 

60 ↛ 66line 60 didn't jump to line 66, because the condition on line 60 was never false elif isinstance(item["schema:domainIncludes"], list): 

for subitem in item["schema:domainIncludes"]: 

add_property_to_object( 

schemaorg_data, item, subitem, word, properties, 

missing_words) 

else: 

raise NotImplementedError(json.dumps(item, indent=2)) 

# and (item["@id"] == "schema:" + word):