Skip to content

Commit

Permalink
hdp-spec (#16), i18n+l10n (#15): hxlm.core.localization.translation m…
Browse files Browse the repository at this point in the history
…odule draft
  • Loading branch information
fititnt committed Mar 20, 2021
1 parent 549f196 commit e8c9a1f
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 2 deletions.
9 changes: 9 additions & 0 deletions hxlm/core/localization/hdp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""hxlm.core.localization.hdp is an draft
Copyleft 🄯 2021, Emerson Rocha (Etica.AI) <[email protected]>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
"""

# TODO: move vocabulary conversions from hxlm.core.schema.vocab to here
# (Emerson Rocha, 2021-03-20 03:01 UTC)
13 changes: 13 additions & 0 deletions hxlm/core/localization/translation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""hxlm.core.localization.translation is an draft
Copyleft 🄯 2021, Emerson Rocha (Etica.AI) <[email protected]>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
"""

# Suggested import:
# import hxlm.core.localization.translation as localization

import hxlm.core.localization.translation.interactive as IMT # noqa
import hxlm.core.localization.translation.machine as MT # noqa
import hxlm.core.localization.translation.memory as TM # noqa
30 changes: 30 additions & 0 deletions hxlm/core/localization/translation/interactive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""hxlm.core.localization.translation.interactive is an draft
Copyleft 🄯 2021, Emerson Rocha (Etica.AI) <[email protected]>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
"""


def about_interactive_machine_translation():
"""this entire module is an draft"""
print('''\
See https://en.wikipedia.org/wiki/Interactive_machine_translation.
"Interactive machine translation (IMT), is a specific sub-field of
computer-aided translation. Under this translation paradigm, the computer
software that assists the human translator attempts to predict the
text the user is going to input by taking into account all the
information it has available. Whenever such prediction is wrong and
the user provides feedback to the system, a new prediction is performed
considering the new information available. Such process is repeated
until the translation provided matches the user's
expectations.
Interactive machine translation is specially interesting when
translating texts in domains where it is not admissible to output a
translation containing errors, hence requiring a human user to amend
the translations provided by the system. In such cases,
interactive machine translation has been proved to provide benefit
to potential users.[1][2]" -- Wikipedia
''', end='')
19 changes: 19 additions & 0 deletions hxlm/core/localization/translation/machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""hxlm.core.localization.translation.machine is an draft
Copyleft 🄯 2021, Emerson Rocha (Etica.AI) <[email protected]>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
"""


def about_machine_translation():
"""this entire module is an draft"""
print('''\
See https://en.wikipedia.org/wiki/Machine_translation.
"Machine translation, sometimes referred to by the abbreviation MT[1]
(not to be confused with computer-aided translation, machine-aided
human translation or interactive translation), is a sub-field of
computational linguistics that investigates the use of software to
translate text or speech from one language to another." -- Wikipedia
''', end='')
18 changes: 18 additions & 0 deletions hxlm/core/localization/translation/memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""hxlm.core.localization.translation.memory is an draft
Copyleft 🄯 2021, Emerson Rocha (Etica.AI) <[email protected]>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
"""


def about_translation_memory():
"""this entire module is an draft"""
print('''\
See https://en.wikipedia.org/wiki/Translation_memory.
"A translation memory (TM) is a database that stores "segments", which can
be sentences, paragraphs or sentence-like units (headings, titles or
elements in a list) that have previously been translated, in order to aid
human translators." -- Wikipedia
''', end='')
15 changes: 13 additions & 2 deletions hxlm/core/model/hdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import json
import yaml

import hxlm.core.localization as l10n

from hxlm.core.schema.vocab import (
# HXLM_CORE_SCHEMA_CORE_VOCAB,
ItemHVocab,
Expand Down Expand Up @@ -270,8 +272,8 @@ def _get_filtered(self, hdp_filters: dict = None,
filtered = self._hdp

if self._debug:
print('HDP._get_filtered hdp_filters',
hdp_filters, objectivum_linguam)
print('HDP._get_filtered started')
print(' hdp_filters', hdp_filters, objectivum_linguam)

if 'verum_urn' in hdp_filters:
filtered = self._get_filtered_urn(
Expand All @@ -291,6 +293,15 @@ def _get_filtered(self, hdp_filters: dict = None,
if objectivum_linguam:
filtered = self._get_translated(
filtered, objectivum_linguam=objectivum_linguam)
else:
objectivum_linguam = l10n.get_language_preferred()

if self._debug:
print(' implicit get_language_preferred', objectivum_linguam)

if objectivum_linguam['lang']:
filtered = self._get_translated(
filtered, objectivum_linguam=objectivum_linguam['lang'])

return filtered

Expand Down

0 comments on commit e8c9a1f

Please sign in to comment.