Skip to content

Port transductive alignment model - #466

Open
pmachapman wants to merge 1 commit into
masterfrom
transductive-model
Open

Port transductive alignment model#466
pmachapman wants to merge 1 commit into
masterfrom
transductive-model

Conversation

@pmachapman

@pmachapman pmachapman commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes #455.

Port of sillsdev/machine.py#327

@ddaspit I am unsure whether my implementations of ThotSymmetrizedWordAlignmentModel.TrainingAlignmentCount and ThotWordAlignmentModel.GetTrainingAlignment() are correct. I wrote them based on what I understood the underlying logic in thot to be doing, as SymmetrizedAlignmentModel is not exposed via the C API.

If they are not right, I will update thot to expose the methods from SymmetrizedAlignmentModel in the C API that are exposed in thot's module.cc and used by the machine.py implementation.


This change is Reviewable

@pmachapman
pmachapman requested review from Enkidu93 and ddaspit August 3, 2026 03:17

@ddaspit ddaspit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddaspit reviewed 9 files and all commit messages, and made 3 comments.
Reviewable status: 9 of 10 files reviewed, 3 unresolved discussions (waiting on Enkidu93 and pmachapman).


src/SIL.Machine/Corpora/CorporaExtensions.cs line 1135 at r1 (raw file):

        }

        public static IParallelTextCorpus WordAlign(

I think there are too many pitfalls with trying to implement this operation. Instead, we should add a similar IParallelTextCorpus extension method in SIL.Machine.Translation.Thot that trains and aligns a corpus using a Thot model. The method should accept a ThotWordAlignmentModelType parameter. You can have overloads that accept a ThotWordAlignmentModel or ThotSymmetrizedWordAlignmentModel as well. It would mimic the word_align_corpus function in Machine.py. If the passed in model is not configured to emit training alignments, then it should fall back to inductive alignment.


src/SIL.Machine.Translation.Thot/ThotWordAlignmentModel.cs line 169 at r1 (raw file):

        {
            CheckDisposed();
            IntPtr nativeMatrix = Thot.AllocNativeMatrix(_sourceWords.Count, _targetWords.Count);

To get the size of the matrix, you can call swAlignModel_getTrainingAlignment with a null buffer.


src/SIL.Machine.Translation.Thot/ThotWordAlignmentModelTrainer.cs line 24 at r1 (raw file):

        private readonly bool _isEflomal;

        public ThotWordAlignmentModelTrainer(

You forgot emitTrainingAlignments here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port 'Add support for transductive alignment models'

2 participants