API e modules

API Basic - Mòde d'emplec

L'API Basic que permet de recercar, a partir d'un mot en francés o en occitan, ua entrada deu Basic, lo diccionari deu Congrès.

L'URL d'entrada

L'URL de basa de l'aplicacion qu'ei http://api.locongres.org/basic.php. Que i cau ajustar los paramètres obligatòris e que s'i pòt ajustar un paramètre facultatiu. Si ne sabetz pas ajustar paramètres a un URL, que'vs remandam a aqueth tutoriau.

Los paramètres obligatòris

Que cau obligatòriament indicar los paramètres seguents :

  • La vòsta clau API : tà utilizar las API deu Congrès, que cau indicar ua clau API personau qui'vs podem balhar sus la pagina dedicada. Que la cau marcar dab lo paramètre "key".
  • La lenga : marcar en quau lenga anatz balhar lo mot a cercar dab lo paramètre "lang". Qu'accèpta las valors "fr" (tau francés) e "oc" (tà l'occitan).
  • Lo mot : marcar lo mot qui voletz cercar dab lo paramètre "term".

Per exemple, que's pòt cercar las reviradas en occitan deu mot "parler" dab l'URL http://api.locongres.org/basic.php?key=[la_vòsta_clau_API]&lang=fr&term=parler. Qu'avetz lo resultat seguent :

{
    "query": [
        {
            "id": 0,
            "forms": [
                {
                    "orth": "parler",
                    "PoS": [
                        "V000050000000"
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "parlar",
                    "PoS": [
                        "V000050000000"
                    ]
                }
            ]
        }
    ]
}

que's pòt cercar quau ei la traduccion en francés deu mot "aimable" dab l'URL http://api.locongres.org/basic.php?key=[la_vòsta_clau_API]&term=aimable&lang=oc. Qu'avetz lo resultat seguent :

{
    "query": [
        {
            "id": 0,
            "forms": [
                {
                    "orth": "affable",
                    "PoS": [
                        "AJ0110",
                        "AJ0210"
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "aimable",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "aimabla",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                },
                {
                    "var": "com",
                    "orth": "agradiu",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "agradiva",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "id": 0,
            "forms": [
                {
                    "orth": "aimable",
                    "PoS": [
                        "AJ0110",
                        "AJ0210"
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "aimable",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "aimabla",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                },
                {
                    "var": "com",
                    "orth": "amist\u00f3s",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "amistosa",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "id": 0,
            "forms": [
                {
                    "orth": "gentil",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "orth": "gentille",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "brave",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "brava",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                },
                {
                    "var": "com",
                    "orth": "aimable",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "aimabla",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "id": 0,
            "forms": [
                {
                    "orth": "sympathique",
                    "PoS": [
                        "AJ0110",
                        "AJ0210"
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "simpatic",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "simpatica",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                },
                {
                    "var": "com",
                    "orth": "aimable",
                    "PoS": [
                        "AJ0110"
                    ],
                    "flexions": [
                        {
                            "var": "com",
                            "orth": "aimabla",
                            "PoS": [
                                "AJ0210"
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

Lo paramètre facultatiu

Tà afichar sonque los mots occitans en ua varietat, o tà cercar un mot en occitan en ua varietat particulara, que's pòt utilizar lo paramètre "var" qui pren com valor, peu moment : "gasc" (formas en occitan gascon), "leng" (formas en occitan lengadocian) o "com" (formas comunas a las duas varietats).

Per exemple, si voletz afichar las reviradas en occitan gascon deu mot francés "partir", que's pòt utilizar l'URL http://api.locongres.org/basic.php?key=[la_vòsta_clau_API]&lang=fr&term=partir&var=gasc. Qu'avetz lo resultat seguent :

{
    "query": [
        {
            "id": 0,
            "forms": [
                {
                    "orth": "partir",
                    "PoS": [
                        "V000050000000"
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "partir",
                    "PoS": [
                        "V000050000000"
                    ]
                },
                {
                    "var": "gasc",
                    "orth": "anar-se'n",
                    "PoS": [
                        "V000050000000"
                    ]
                }
            ]
        }
    ]
}

Tà cercar la revirada en francés deu mot en occitan lengadocian "cencha", que's pòt utilizar l'URL http://api.locongres.org/basic.php?key=[la_vòsta_clau_API]&lang=oc&term=cencha&var=leng. Qu'avetz lo resultat seguent :

{
    "query": [
        {
            "id": 0,
            "forms": [
                {
                    "orth": "ceinture",
                    "PoS": [
                        "N1210"
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "cinta",
                    "PoS": [
                        "N1210"
                    ]
                },
                {
                    "var": "leng",
                    "orth": "cencha",
                    "PoS": [
                        "N1210"
                    ]
                }
            ]
        },
        {
            "id": 0,
            "forms": [
                {
                    "orth": "taille",
                    "PoS": [
                        "N1210"
                    ]
                }
            ],
            "trads": [
                {
                    "var": "com",
                    "orth": "talha",
                    "PoS": [
                        "N1210"
                    ]
                },
                {
                    "var": "com",
                    "orth": "cinta",
                    "PoS": [
                        "N1210"
                    ]
                },
                {
                    "var": "leng",
                    "orth": "cencha",
                    "PoS": [
                        "N1210"
                    ]
                },
                {
                    "var": "com",
                    "orth": "talha",
                    "PoS": [
                        "N1210"
                    ]
                },
                {
                    "var": "com",
                    "orth": "mesura",
                    "PoS": [
                        "N1210"
                    ]
                },
                {
                    "var": "leng",
                    "orth": "pag\u00e8la",
                    "PoS": [
                        "N1210"
                    ]
                }
            ]
        }
    ]
}

Lo format de sortida

Per defaut, lo format de sortida qu'ei JSON. Mes que's pòt obtiéner ua sortida au format XML en ajustant "format=xml" a l'URL.

Per exemple, tà afichar las reviradas deu mot francés "toujours" au format XML, que's pòt utilizar l'URL http://api.locongres.org/basic.php?key=[la_vòsta_clau_API]&lang=fr&term=toujours&format=xml. Qu'avetz lo resultat seguent :

<query>
    <entry id="12787">
        <form>
            <orth>toujours</orth>
            <PoS>AV0000</PoS>
        </form>
        <trad>
            <var>gasc</var>
            <orth>tostemps</orth>
            <PoS>AV0000</PoS>
        </trad>
        <trad>
            <var>leng</var>
            <orth>totjorn</orth>
            <PoS>AV0000</PoS>
        </trad>
    </entry>
</query>

Las errors

Si i a errors dens l'URL picada o que la requèsta ne torna pas nada entrada, l'API que torna ua error dab un còdi e un tèxte d'error en anglés. Qu'avetz ací-devath, tà cada còdi d'error, la revirada deu son tèxte en occitan :

  • 1 : Que cau indicar ua clau API
  • 2 : Clau API invalida
  • 3 : Format incorrècte ("json" e "xml" permés)
  • 4 : Que cau indicar un mot a cercar
  • 5 : Que cau indicar ua lenga de recèrca
  • 6 : Lenga incorrècta ("fr" e "oc" permés)
  • 7 : Varietat incorrècta ("com", "gasc" e "leng" permés)
  • 8 : N'avem pas trobat nada entrada dab las vòstas especificacions

Las informacions en sortida

En sortida, que i a ua lista d'entradas dab un identificant unic. Per cadua que son balhadas :

  • La(s) forma(s) en francés : dab ua ortografia e ua o mantua categoria grammaticau
  • La(s) revirada(s) en occitan : dab la varietat, ua ortografia e ua o mantua categoria grammaticau

Las categorias grammaticaus que son indicadas dab la nòrma Eagles. Qu'avetz un explic de quin Lo Congrès utiliza la nòrma Eagles au capítol 5 d'aqueth document.

JSON schema

{
    "type": "object",
    "properties": {
        "error": {
            "type": "object",
            "properties": {
                "code": {
                    "description": "The unique identifier for an error",
                    "type": "integer"
                },
                "text": {
                    "description": "A description of the error",
                    "type": "string"
                }
            },
            "required": ["code", "text"]
        },
        "query": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "forms": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "orth": {
                                    "type": "string",
                                },
                                "PoS": {
                                    "type": "array",
                                    "items": {
                                        "type":"string"
                                    },
                                    "minItems": 1
                                },
                                "flexions": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "orth": {
                                                "type": "string",
                                            },
                                            "PoS": {
                                                "type": "array",
                                                "items": {
                                                    "type":"string"
                                                },
                                                "minItems": 1
                                            }
                                        },
                                        "required": ["orth", "PoS"]
                                    }
                                }
                            },
                            "required": ["orth", "PoS"]
                        },
                        "minItems": 1
                    },
                    "trads": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "orth": {
                                    "type": "string",
                                },
                                "PoS": {
                                    "type": "array",
                                    "items": {
                                        "type":"string"
                                    },
                                    "minItems": 1
                                },
                                "flexions": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "orth": {
                                                "type": "string",
                                            },
                                            "PoS": {
                                                "type": "array",
                                                "items": {
                                                    "type":"string"
                                                },
                                                "minItems": 1
                                            }
                                        },
                                        "required": ["orth", "PoS"]
                                    }
                                }
                            },
                            "required": ["orth", "PoS"]
                        },
                        "minItems": 1
                    },
                    
                },
                "required": ["id", "forms", "trads"]
            },
            "minItems": 1
        }
    }
}

DTD XML

<! ELEMENT query (entry) >

<! ELEMENT error (#PCDATA) >
<! ATTLIST error code ID #REQUIRED >

<! ELEMENT entry (form+ | trad*) >
<! ATTLIST entry id ID #REQUIRED >

<! ELEMENT form (orth | PoS+) >

<! ELEMENT orth (#PCDATA) >

<! ELEMENT PoS (#PCDATA) >

<! ELEMENT trad (orth | PoS+ | var) >

<! ELEMENT var (#PCDATA) >

© Lo Congrès Permanent de la Lenga Occitana, 2017, tots los drets reservats - Contactar Lo Congrès