.. index:: single: language_detector_protocol
.. _language_detector_protocol/0:

.. rst-class:: right

**protocol**

``language_detector_protocol``
==============================

Language detection protocol.

| **Availability:** 
|    ``logtalk_load(language_detection(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-09-08

| **Compilation flags:**
|    ``static``


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: detect/2
.. _language_detector_protocol/0::detect/2:

``detect/2``
^^^^^^^^^^^^

Detects the most likely language and returns its ISO 639-1 code.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``detect(Text,Language)``
| **Mode and number of proofs:**
|    ``detect(+text,-atom)`` - ``zero_or_one_or_error``

| **Exceptions:**
|    The ``Representation`` parameter is a variable:
|        ``instantiation_error``
|    The ``Representation`` parameter neither a variable nor ``atom``, ``chars``, or ``codes``:
|        ``domain_error(text_representation,Representation)``
|    The ``Strategy`` parameter is a variable:
|        ``instantiation_error``
|    The ``Strategy`` parameter neither a variable nor an object identifier:
|        ``type_error(object_identifier,Strategy)``
|    The ``Strategy`` parameter is an object identifier but not an object conforming to ``language_detection_strategy_protocol``:
|        ``domain_error(language_detection_strategy_protocol,Strategy)``


------------

.. index:: detect/3
.. _language_detector_protocol/0::detect/3:

``detect/3``
^^^^^^^^^^^^

Detects the most likely language and returns its ISO 639-1 code and relative detection score.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``detect(Text,Language,Score)``
| **Mode and number of proofs:**
|    ``detect(+text,-atom,-float)`` - ``zero_or_one_or_error``

| **Exceptions:**
|    The ``Representation`` parameter is a variable:
|        ``instantiation_error``
|    The ``Representation`` parameter neither a variable nor ``atom``, ``chars``, or ``codes``:
|        ``domain_error(text_representation,Representation)``
|    The ``Strategy`` parameter is a variable:
|        ``instantiation_error``
|    The ``Strategy`` parameter neither a variable nor an object identifier:
|        ``type_error(object_identifier,Strategy)``
|    The ``Strategy`` parameter is an object identifier but not an object conforming to ``language_detection_strategy_protocol``:
|        ``domain_error(language_detection_strategy_protocol,Strategy)``


------------

.. index:: detect/4
.. _language_detector_protocol/0::detect/4:

``detect/4``
^^^^^^^^^^^^

Detects the most likely language using the given options and returns its ISO 639-1 code and relative detection score.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``detect(Text,Language,Score,Options)``
| **Mode and number of proofs:**
|    ``detect(+text,-atom,-float,+list(compound))`` - ``zero_or_one_or_error``

| **Exceptions:**
|    The ``Representation`` parameter is a variable:
|        ``instantiation_error``
|    The ``Representation`` parameter neither a variable nor ``atom``, ``chars``, or ``codes``:
|        ``domain_error(text_representation,Representation)``
|    The ``Strategy`` parameter is a variable:
|        ``instantiation_error``
|    The ``Strategy`` parameter neither a variable nor an object identifier:
|        ``type_error(object_identifier,Strategy)``
|    The ``Strategy`` parameter is an object identifier but not an object conforming to ``language_detection_strategy_protocol``:
|        ``domain_error(language_detection_strategy_protocol,Strategy)``
|    ``Options`` is a variable:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    An element ``Option`` of the list ``Options`` is a variable:
|        ``instantiation_error``
|    An element ``Option`` of the list ``Options`` is neither a variable nor a compound term:
|        ``type_error(compound,Option)``
|    An element ``Option`` of the list ``Options`` is a compound term but not a valid option:
|        ``domain_error(option,Option)``


------------

.. index:: detect_all/2
.. _language_detector_protocol/0::detect_all/2:

``detect_all/2``
^^^^^^^^^^^^^^^^

Returns candidate languages ranked by descending relative detection score or an empty list when there is insufficient evidence.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``detect_all(Text,ScoredLanguages)``
| **Mode and number of proofs:**
|    ``detect_all(+text,-list(pair(atom,float)))`` - ``one_or_error``

| **Exceptions:**
|    The ``Representation`` parameter is a variable:
|        ``instantiation_error``
|    The ``Representation`` parameter neither a variable nor ``atom``, ``chars``, or ``codes``:
|        ``domain_error(text_representation,Representation)``
|    The ``Strategy`` parameter is a variable:
|        ``instantiation_error``
|    The ``Strategy`` parameter neither a variable nor an object identifier:
|        ``type_error(object_identifier,Strategy)``
|    The ``Strategy`` parameter is an object identifier but not an object conforming to ``language_detection_strategy_protocol``:
|        ``domain_error(language_detection_strategy_protocol,Strategy)``


------------

.. index:: detect_all/3
.. _language_detector_protocol/0::detect_all/3:

``detect_all/3``
^^^^^^^^^^^^^^^^

Returns candidate languages ranked by descending relative detection score using the given options or an empty list when there is insufficient evidence.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``detect_all(Text,ScoredLanguages,Options)``
| **Mode and number of proofs:**
|    ``detect_all(+text,-list(pair(atom,float)),+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    The ``Representation`` parameter is a variable:
|        ``instantiation_error``
|    The ``Representation`` parameter neither a variable nor ``atom``, ``chars``, or ``codes``:
|        ``domain_error(text_representation,Representation)``
|    The ``Strategy`` parameter is a variable:
|        ``instantiation_error``
|    The ``Strategy`` parameter neither a variable nor an object identifier:
|        ``type_error(object_identifier,Strategy)``
|    The ``Strategy`` parameter is an object identifier but not an object conforming to ``language_detection_strategy_protocol``:
|        ``domain_error(language_detection_strategy_protocol,Strategy)``
|    ``Options`` is a variable:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    An element ``Option`` of the list ``Options`` is a variable:
|        ``instantiation_error``
|    An element ``Option`` of the list ``Options`` is neither a variable nor a compound term:
|        ``type_error(compound,Option)``
|    An element ``Option`` of the list ``Options`` is a compound term but not a valid option:
|        ``domain_error(option,Option)``


------------

Protected predicates
--------------------

(none)

Private predicates
------------------

(none)

Operators
---------

(none)

.. seealso::

   :ref:`language_detection_strategy_protocol <language_detection_strategy_protocol/0>`

