File size: 752 Bytes
ed6bec6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# generator/meaning_model.py

from dataclasses import dataclass, asdict
from typing import Optional, List, Dict, Any


@dataclass
class Emotion:
    type: str
    intensity: float


@dataclass
class Context:
    time: Optional[str] = None
    place: Optional[str] = None
    social: Optional[str] = None
    sensory: Optional[str] = None
    activity: Optional[str] = None


@dataclass
class StructuredMeaning:
    actor: Optional[str]
    action: Optional[str]
    object: Optional[str]
    modifiers: List[str]
    emotion: Optional[Emotion]
    context: Context
    intent: str
    meta: Dict[str, Any]

    def to_dict(self) -> Dict[str, Any]:
        d = asdict(self)
        # Flatten Emotion and Context dataclasses into dicts
        return d