Skip to main content

gcn_knowledge/
taxonomy.rs

1// Copyright 2026 Michel Tendeng
2// SPDX-License-Identifier: Apache-2.0
3
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Taxonomy {
9    pub taxonomy: String,
10    pub version: String,
11    pub description: String,
12    pub classes: HashMap<String, TaxonomyClass>,
13    #[serde(default)]
14    pub compositional_rules: Option<Vec<CompositionalRule>>,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct TaxonomyClass {
19    #[serde(default)]
20    pub description: Option<String>,
21    #[serde(default)]
22    pub role: Option<String>,
23    // Valeurs textuelles (ex: "maintien", "production") — Phase 2 mappera vers CausalDirection enum.
24    #[serde(default)]
25    pub causal_direction: Option<String>,
26    #[serde(default)]
27    pub causal_effect: Option<String>,
28    #[serde(default)]
29    pub dimension: Option<String>,
30    #[serde(default)]
31    pub relation_type: Option<String>,
32    #[serde(default)]
33    pub signals_gap: Option<bool>,
34    #[serde(default)]
35    pub scope: Option<String>,
36    #[serde(default)]
37    pub formal: Option<String>,
38    #[serde(default)]
39    pub position: Option<String>,
40    #[serde(default)]
41    pub examples_fr: Option<Vec<LexicalEntry>>,
42    /// Entrées lexicales langage-agnostique (utilisé par les frontends non-français).
43    #[serde(default)]
44    pub examples: Option<Vec<LexicalEntry>>,
45    #[serde(default)]
46    pub subtypes: Option<HashMap<String, SubType>>,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct LexicalEntry {
51    pub lemma: String,
52    #[serde(default)]
53    pub note: Option<String>,
54    #[serde(default)]
55    pub value: Option<f32>,
56    #[serde(default)]
57    pub kind: Option<String>,
58    #[serde(default)]
59    pub anchor: Option<String>,
60    #[serde(default)]
61    pub scope: Option<String>,
62    #[serde(default)]
63    pub total: Option<bool>,
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct SubType {
68    pub description: String,
69    #[serde(default)]
70    pub examples_fr: Option<Vec<String>>,
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct CompositionalRule {
75    pub pattern: String,
76    pub result: String,
77    pub description: String,
78}