-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
54 lines (41 loc) · 1.03 KB
/
models.py
File metadata and controls
54 lines (41 loc) · 1.03 KB
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
from dataclasses import dataclass
from enum import Enum
from typing import Optional
class FieldType(Enum):
LITERAL = "literal"
URI = "uri"
EITHER = "either"
LITERAL_NO_LANG = "nolanguage_literal"
@dataclass
class SkosFieldInfo:
name: str
field_type: FieldType
multivalued: bool = True
lang_dependent: bool = True
@dataclass
class TripleQueryParam:
uri: Optional[str] = None
skos_field: Optional[str] = None
value: Optional[str] = None
lang: Optional[str] = None
is_concept_query: bool = False
@dataclass
class TriplePattern:
def __init__(self, s=None, p=None, o=None):
self.s = s
self.p = p
self.o = o
@property
def subject(self):
return self.s
@property
def predicates(self):
# support single or list
if self.p is None:
return None
if isinstance(self.p, list):
return self.p
return [self.p]
@property
def object(self):
return self.o