flexicon.code.Lexicon package

Submodules

flexicon.code.Lexicon.AllomorphOperations module

class flexicon.code.Lexicon.AllomorphOperations.AllomorphOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing allomorphs in a FieldWorks project.

Allomorphs are variant forms of morphemes that appear in different phonological or morphological contexts. For example, the English plural morpheme has allomorphs “-s”, “-es”, and “-en” (ox/oxen).

Usage:

from flexlibs2 import FLExProject, AllomorphOperations

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

allomorphOps = AllomorphOperations(project)

# Get entry
entry = project.LexiconAllEntries()[0]

# Get all allomorphs for an entry
for allomorph in allomorphOps.GetAll(entry):
    form = allomorphOps.GetForm(allomorph)
    print(f"Allomorph: {form}")

# Create a new allomorph
morphType = project.lp.MorphTypesOA.PossibilitiesOS[0]
allomorph = allomorphOps.Create(entry, "walk", morphType)

# Set phonological environment
env = project.lp.PhonologicalDataOA.EnvironmentsOS[0]
allomorphOps.AddPhoneEnv(allomorph, env)

project.CloseProject()
GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

GetForm(*args, **kwargs)

Automatically instantiate and call the method.

SetForm(*args, **kwargs)

Automatically instantiate and call the method.

SetFormAudio(*args, **kwargs)

Automatically instantiate and call the method.

GetFormAudio(*args, **kwargs)

Automatically instantiate and call the method.

GetMorphType(*args, **kwargs)

Automatically instantiate and call the method.

SetMorphType(*args, **kwargs)

Automatically instantiate and call the method.

GetPhoneEnv(*args, **kwargs)

Automatically instantiate and call the method.

AddPhoneEnv(*args, **kwargs)

Automatically instantiate and call the method.

RemovePhoneEnv(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.EtymologyOperations module

class flexicon.code.Lexicon.EtymologyOperations.EtymologyOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing etymological information in a FieldWorks project.

Etymology tracking records the historical origin and development of lexical entries. Each etymology can specify the source language, etymological form, gloss, linguistic commentary, and bibliographic references.

This class supports historical linguistics workflows including etymology documentation, loan word tracking, and diachronic analysis.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

# Access via FLExProject.Etymology property (if configured)
# Or create directly:
from flexlibs2.code.EtymologyOperations import EtymologyOperations
etymOps = EtymologyOperations(project)

# Get an entry
entry = project.LexEntry.Find("computer")

# Create an etymology
etym = etymOps.Create(
    entry,
    source="English",
    form="compute",
    gloss="to calculate",
    ws="en"
)

# Set additional information
etymOps.SetComment(etym, "Borrowed in the 1980s", "en")
etymOps.SetBibliography(etym, "Smith 2020:145")

# Get all etymologies
for etym in etymOps.GetAll(entry):
    source = etymOps.GetSource(etym)
    form = etymOps.GetForm(etym)
    print(f"From {source}: {form}")

project.CloseProject()
GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

ApplySyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

Reorder(*args, **kwargs)

Automatically instantiate and call the method.

GetSource(*args, **kwargs)

Automatically instantiate and call the method.

SetSource(*args, **kwargs)

Automatically instantiate and call the method.

GetForm(*args, **kwargs)

Automatically instantiate and call the method.

SetForm(*args, **kwargs)

Automatically instantiate and call the method.

GetGloss(*args, **kwargs)

Automatically instantiate and call the method.

SetGloss(*args, **kwargs)

Automatically instantiate and call the method.

GetComment(*args, **kwargs)

Automatically instantiate and call the method.

SetComment(*args, **kwargs)

Automatically instantiate and call the method.

GetBibliography(*args, **kwargs)

Automatically instantiate and call the method.

SetBibliography(*args, **kwargs)

Automatically instantiate and call the method.

GetOwningEntry(*args, **kwargs)

Automatically instantiate and call the method.

GetGuid(*args, **kwargs)

Automatically instantiate and call the method.

GetLanguage(*args, **kwargs)

Automatically instantiate and call the method.

SetLanguage(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.ExampleOperations module

class flexicon.code.Lexicon.ExampleOperations.ExampleOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing example sentences in a FieldWorks project.

Example sentences illustrate the usage of lexical senses in context. Each example can have vernacular text, translations in multiple analysis languages, references to source texts, and associated media files.

Usage:

from flexlibs2 import FLExProject, ExampleOperations

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

exampleOps = ExampleOperations(project)

# Get first entry and sense
entry = project.LexiconAllEntries().__next__()
sense = entry.SensesOS[0] if entry.SensesOS.Count > 0 else None

# Get all examples for a sense
for example in exampleOps.GetAll(sense):
    text = exampleOps.GetExample(example)
    trans = exampleOps.GetTranslation(example)
    print(f"Example: {text}")
    print(f"Translation: {trans}")

# Create a new example
example = exampleOps.Create(sense, "The cat sat on the mat.")
exampleOps.SetTranslation(example, "Le chat s'est assis sur le tapis.")
exampleOps.SetReference(example, "Example Corpus 1.23")

project.CloseProject()
GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

ApplySyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

Reorder(*args, **kwargs)

Automatically instantiate and call the method.

GetExample(*args, **kwargs)

Automatically instantiate and call the method.

SetExample(*args, **kwargs)

Automatically instantiate and call the method.

GetTranslations(*args, **kwargs)

Automatically instantiate and call the method.

GetTranslation(*args, **kwargs)

Automatically instantiate and call the method.

SetTranslation(*args, **kwargs)

Automatically instantiate and call the method.

AddTranslation(*args, **kwargs)

Automatically instantiate and call the method.

RemoveTranslation(*args, **kwargs)

Automatically instantiate and call the method.

GetReference(*args, **kwargs)

Automatically instantiate and call the method.

SetReference(*args, **kwargs)

Automatically instantiate and call the method.

GetMediaFiles(*args, **kwargs)

Automatically instantiate and call the method.

GetMediaCount(*args, **kwargs)

Automatically instantiate and call the method.

AddMediaFile(*args, **kwargs)

Automatically instantiate and call the method.

RemoveMediaFile(*args, **kwargs)

Automatically instantiate and call the method.

MoveMediaFile(*args, **kwargs)

Automatically instantiate and call the method.

GetOwningSense(*args, **kwargs)

Automatically instantiate and call the method.

GetGuid(*args, **kwargs)

Automatically instantiate and call the method.

GetLiteralTranslation(*args, **kwargs)

Automatically instantiate and call the method.

SetLiteralTranslation(*args, **kwargs)

Automatically instantiate and call the method.

GetDoNotPublishIn(*args, **kwargs)

Automatically instantiate and call the method.

AddDoNotPublishIn(*args, **kwargs)

Automatically instantiate and call the method.

RemoveDoNotPublishIn(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.LexEntryOperations module

class flexicon.code.Lexicon.LexEntryOperations.LexEntryOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing lexical entries in a FieldWorks project.

Lexical entries are the fundamental units of the lexicon, representing words, morphemes, or other lexical items. Each entry has forms (lexeme, citation, alternate), senses (meanings), and various properties.

This class should be accessed via FLExProject.LexEntry property.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

# Get all entries
for entry in project.LexEntry.GetAll():
    headword = project.LexEntry.GetHeadword(entry)
    print(headword)

# Create a new entry
entry = project.LexEntry.Create("run", "stem")

# Add a sense
project.LexEntry.AddSense(entry, "to move rapidly on foot", "en")

# Set citation form
project.LexEntry.SetCitationForm(entry, "run")

project.CloseProject()
GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

ApplySyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

Exists(*args, **kwargs)

Automatically instantiate and call the method.

Find(*args, **kwargs)

Automatically instantiate and call the method.

GetHeadword(*args, **kwargs)

Automatically instantiate and call the method.

SetHeadword(*args, **kwargs)

Automatically instantiate and call the method.

GetLexemeForm(*args, **kwargs)

Automatically instantiate and call the method.

SetLexemeForm(*args, **kwargs)

Automatically instantiate and call the method.

GetCitationForm(*args, **kwargs)

Automatically instantiate and call the method.

SetCitationForm(*args, **kwargs)

Automatically instantiate and call the method.

GetBestVernacularAlternative(*args, **kwargs)

Automatically instantiate and call the method.

GetShortName(*args, **kwargs)

Automatically instantiate and call the method.

GetLongName(*args, **kwargs)

Automatically instantiate and call the method.

GetLIFTid(*args, **kwargs)

Automatically instantiate and call the method.

GetHomographNumber(*args, **kwargs)

Automatically instantiate and call the method.

SetHomographNumber(*args, **kwargs)

Automatically instantiate and call the method.

GetDateCreated(*args, **kwargs)

Automatically instantiate and call the method.

GetDateModified(*args, **kwargs)

Automatically instantiate and call the method.

GetMorphType(*args, **kwargs)

Automatically instantiate and call the method.

SetMorphType(*args, **kwargs)

Automatically instantiate and call the method.

GetAvailableMorphTypes(*args, **kwargs)

Automatically instantiate and call the method.

ValidateMorphType(*args, **kwargs)

Automatically instantiate and call the method.

GetAllByMorphType(*args, **kwargs)

Automatically instantiate and call the method.

GetSenses(*args, **kwargs)

Automatically instantiate and call the method.

GetSenseCount(*args, **kwargs)

Automatically instantiate and call the method.

AddSense(*args, **kwargs)

Automatically instantiate and call the method.

GetGuid(*args, **kwargs)

Automatically instantiate and call the method.

GetImportResidue(*args, **kwargs)

Automatically instantiate and call the method.

SetImportResidue(*args, **kwargs)

Automatically instantiate and call the method.

GetBibliography(*args, **kwargs)

Automatically instantiate and call the method.

SetBibliography(*args, **kwargs)

Automatically instantiate and call the method.

GetComment(*args, **kwargs)

Automatically instantiate and call the method.

SetComment(*args, **kwargs)

Automatically instantiate and call the method.

GetLiteralMeaning(*args, **kwargs)

Automatically instantiate and call the method.

SetLiteralMeaning(*args, **kwargs)

Automatically instantiate and call the method.

GetRestrictions(*args, **kwargs)

Automatically instantiate and call the method.

SetRestrictions(*args, **kwargs)

Automatically instantiate and call the method.

GetSummaryDefinition(*args, **kwargs)

Automatically instantiate and call the method.

SetSummaryDefinition(*args, **kwargs)

Automatically instantiate and call the method.

GetDoNotUseForParsing(*args, **kwargs)

Automatically instantiate and call the method.

SetDoNotUseForParsing(*args, **kwargs)

Automatically instantiate and call the method.

GetExcludeAsHeadword(*args, **kwargs)

Automatically instantiate and call the method.

SetExcludeAsHeadword(*args, **kwargs)

Automatically instantiate and call the method.

GetDoNotPublishIn(*args, **kwargs)

Automatically instantiate and call the method.

AddDoNotPublishIn(*args, **kwargs)

Automatically instantiate and call the method.

RemoveDoNotPublishIn(*args, **kwargs)

Automatically instantiate and call the method.

GetDoNotShowMainEntryIn(*args, **kwargs)

Automatically instantiate and call the method.

AddDoNotShowMainEntryIn(*args, **kwargs)

Automatically instantiate and call the method.

RemoveDoNotShowMainEntryIn(*args, **kwargs)

Automatically instantiate and call the method.

GetVisibleComplexFormBackRefs(*args, **kwargs)

Automatically instantiate and call the method.

GetComplexFormsNotSubentries(*args, **kwargs)

Automatically instantiate and call the method.

GetMinimalLexReferences(*args, **kwargs)

Automatically instantiate and call the method.

GetAllSenses(**kwargs)
AddComplexFormComponent(*args, **kwargs)

Automatically instantiate and call the method.

RemoveComplexFormComponent(*args, **kwargs)

Automatically instantiate and call the method.

GetComplexFormComponents(*args, **kwargs)

Automatically instantiate and call the method.

MergeObject(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.LexReferenceOperations module

class flexicon.code.Lexicon.LexReferenceOperations.LexRefMappingTypes[source]

Bases: object

Lexical reference mapping type constants.

These correspond to the LexRefTypeTags.MappingTypes enum in FLEx. The mapping type determines how the lexical relation behaves:

  • SYMMETRIC: Bidirectional equal relations (A ↔ B) Example: synonym, antonym

  • ASYMMETRIC: Directional relations with forward and reverse (A → B, B ← A) Example: hypernym/hyponym, part/whole

  • TREE: Tree/hierarchical relations with parent-child structure Example: taxonomic hierarchies, part-whole hierarchies

  • SEQUENCE: Ordered sequence relations (A → B → C) Example: temporal sequences, procedural steps

SYMMETRIC = 1
ASYMMETRIC = 2
TREE = 3
SEQUENCE = 4
class flexicon.code.Lexicon.LexReferenceOperations.LexReferenceOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing lexical references and cross-references in a FieldWorks project.

Lexical references connect entries or senses through various types of relations such as synonyms, antonyms, hypernyms, part-whole relationships, and complex form relationships. These relations help organize the lexicon semantically and structurally.

The class handles different mapping types: - Symmetric (e.g., synonym, antonym) - Asymmetric (e.g., hypernym/hyponym) - Tree (e.g., part-whole hierarchies) - Sequence (ordered relationships)

This class should be accessed via FLExProject.LexReferences property.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

# Get all relation types
for ref_type in project.LexReferences.GetAllTypes():
    name = project.LexReferences.GetTypeName(ref_type)
    mapping = project.LexReferences.GetMappingType(ref_type)
    print(f"{name}: {mapping}")

# Create a new relation type
synonym_type = project.LexReferences.CreateType(
    "Synonym",
    "Symmetric",
    reverse_name=None
)

# Create a reference between two senses
entry1 = project.LexEntry.Find("run")
entry2 = project.LexEntry.Find("jog")
if entry1 and entry2:
    sense1 = list(project.Senses.GetAll(entry1))[0]
    sense2 = list(project.Senses.GetAll(entry2))[0]
    ref = project.LexReferences.Create(synonym_type, [sense1, sense2])

# Get all references for a sense
for ref in project.LexReferences.GetAll(sense1):
    targets = project.LexReferences.GetTargets(ref)
    for target in targets:
        if target.ClassName == "LexSense":
            gloss = project.Senses.GetGloss(target)
            print(f"Related sense: {gloss}")

project.CloseProject()
GetAllTypes(*args, **kwargs)

Automatically instantiate and call the method.

CreateType(*args, **kwargs)

Automatically instantiate and call the method.

DeleteType(*args, **kwargs)

Automatically instantiate and call the method.

FindType(*args, **kwargs)

Automatically instantiate and call the method.

GetTypeName(*args, **kwargs)

Automatically instantiate and call the method.

SetTypeName(*args, **kwargs)

Automatically instantiate and call the method.

GetTypeReverseName(*args, **kwargs)

Automatically instantiate and call the method.

SetTypeReverseName(*args, **kwargs)

Automatically instantiate and call the method.

GetMappingType(*args, **kwargs)

Automatically instantiate and call the method.

GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

GetTargets(*args, **kwargs)

Automatically instantiate and call the method.

AddTarget(*args, **kwargs)

Automatically instantiate and call the method.

RemoveTarget(*args, **kwargs)

Automatically instantiate and call the method.

GetType(*args, **kwargs)

Automatically instantiate and call the method.

GetReferencesOfType(*args, **kwargs)

Automatically instantiate and call the method.

ShowComplexFormsIn(*args, **kwargs)

Automatically instantiate and call the method.

GetComplexFormEntries(*args, **kwargs)

Automatically instantiate and call the method.

GetComponentEntries(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.LexSenseOperations module

class flexicon.code.Lexicon.LexSenseOperations.LexSenseOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing lexical senses in a FieldWorks project.

Lexical senses represent the different meanings or uses of a lexical entry. Each sense can have glosses, definitions, grammatical information, semantic domains, example sentences, pictures, and more.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

# Access via FLExProject.Senses property (recommended)
entry = list(project.LexiconAllEntries())[0]

# Get all senses
for sense in project.Senses.GetAll(entry):
    gloss = project.Senses.GetGloss(sense)
    print(f"Sense: {gloss}")

# Create a new sense
sense = project.Senses.Create(entry, "to run", "en")

# Set definition
project.Senses.SetDefinition(sense, "To move swiftly on foot", "en")

# Add semantic domain
domains = project.GetAllSemanticDomains()
if domains:
    project.Senses.AddSemanticDomain(sense, domains[0])

project.CloseProject()
GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

ApplySyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

Reorder(*args, **kwargs)

Automatically instantiate and call the method.

Find(*args, **kwargs)

Automatically instantiate and call the method.

GetGloss(*args, **kwargs)

Automatically instantiate and call the method.

SetGloss(*args, **kwargs)

Automatically instantiate and call the method.

GetDefinition(*args, **kwargs)

Automatically instantiate and call the method.

SetDefinition(*args, **kwargs)

Automatically instantiate and call the method.

GetDefinitionOrGloss(*args, **kwargs)

Automatically instantiate and call the method.

GetPartOfSpeech(*args, **kwargs)

Automatically instantiate and call the method.

GetPartOfSpeechObject(*args, **kwargs)

Automatically instantiate and call the method.

SetPartOfSpeech(*args, **kwargs)

Automatically instantiate and call the method.

GetGrammaticalInfo(*args, **kwargs)

Automatically instantiate and call the method.

SetGrammaticalInfo(*args, **kwargs)

Automatically instantiate and call the method.

GetSemanticDomains(*args, **kwargs)

Automatically instantiate and call the method.

AddSemanticDomain(*args, **kwargs)

Automatically instantiate and call the method.

RemoveSemanticDomain(*args, **kwargs)

Automatically instantiate and call the method.

GetExamples(*args, **kwargs)

Automatically instantiate and call the method.

GetExampleCount(*args, **kwargs)

Automatically instantiate and call the method.

AddExample(*args, **kwargs)

Automatically instantiate and call the method.

GetSubsenses(*args, **kwargs)

Automatically instantiate and call the method.

CreateSubsense(*args, **kwargs)

Automatically instantiate and call the method.

GetParentSense(*args, **kwargs)

Automatically instantiate and call the method.

GetStatus(*args, **kwargs)

Automatically instantiate and call the method.

SetStatus(*args, **kwargs)

Automatically instantiate and call the method.

GetSenseType(*args, **kwargs)

Automatically instantiate and call the method.

SetSenseType(*args, **kwargs)

Automatically instantiate and call the method.

GetReversalEntries(*args, **kwargs)

Automatically instantiate and call the method.

GetReversalCount(*args, **kwargs)

Automatically instantiate and call the method.

GetPictures(*args, **kwargs)

Automatically instantiate and call the method.

GetPictureCount(*args, **kwargs)

Automatically instantiate and call the method.

AddPicture(*args, **kwargs)

Automatically instantiate and call the method.

RemovePicture(*args, **kwargs)

Automatically instantiate and call the method.

MovePicture(*args, **kwargs)

Automatically instantiate and call the method.

SetCaption(*args, **kwargs)

Automatically instantiate and call the method.

GetCaption(*args, **kwargs)

Automatically instantiate and call the method.

RenamePicture(*args, **kwargs)

Automatically instantiate and call the method.

GetGuid(*args, **kwargs)

Automatically instantiate and call the method.

GetOwningEntry(*args, **kwargs)

Automatically instantiate and call the method.

GetSenseNumber(*args, **kwargs)

Automatically instantiate and call the method.

GetAnalysesCount(*args, **kwargs)

Automatically instantiate and call the method.

GetBibliography(*args, **kwargs)

Automatically instantiate and call the method.

SetBibliography(*args, **kwargs)

Automatically instantiate and call the method.

GetGeneralNote(*args, **kwargs)

Automatically instantiate and call the method.

SetGeneralNote(*args, **kwargs)

Automatically instantiate and call the method.

GetDiscourseNote(*args, **kwargs)

Automatically instantiate and call the method.

SetDiscourseNote(*args, **kwargs)

Automatically instantiate and call the method.

GetEncyclopedicInfo(*args, **kwargs)

Automatically instantiate and call the method.

SetEncyclopedicInfo(*args, **kwargs)

Automatically instantiate and call the method.

GetGrammarNote(*args, **kwargs)

Automatically instantiate and call the method.

SetGrammarNote(*args, **kwargs)

Automatically instantiate and call the method.

GetPhonologyNote(*args, **kwargs)

Automatically instantiate and call the method.

SetPhonologyNote(*args, **kwargs)

Automatically instantiate and call the method.

GetSemanticsNote(*args, **kwargs)

Automatically instantiate and call the method.

SetSemanticsNote(*args, **kwargs)

Automatically instantiate and call the method.

GetSocioLinguisticsNote(*args, **kwargs)

Automatically instantiate and call the method.

SetSocioLinguisticsNote(*args, **kwargs)

Automatically instantiate and call the method.

GetAnthroNote(*args, **kwargs)

Automatically instantiate and call the method.

SetAnthroNote(*args, **kwargs)

Automatically instantiate and call the method.

GetRestrictions(*args, **kwargs)

Automatically instantiate and call the method.

SetRestrictions(*args, **kwargs)

Automatically instantiate and call the method.

GetSource(*args, **kwargs)

Automatically instantiate and call the method.

SetSource(*args, **kwargs)

Automatically instantiate and call the method.

GetScientificName(*args, **kwargs)

Automatically instantiate and call the method.

SetScientificName(*args, **kwargs)

Automatically instantiate and call the method.

GetImportResidue(*args, **kwargs)

Automatically instantiate and call the method.

SetImportResidue(*args, **kwargs)

Automatically instantiate and call the method.

GetUsageTypes(*args, **kwargs)

Automatically instantiate and call the method.

AddUsageType(*args, **kwargs)

Automatically instantiate and call the method.

RemoveUsageType(*args, **kwargs)

Automatically instantiate and call the method.

GetDomainTypes(*args, **kwargs)

Automatically instantiate and call the method.

AddDomainType(*args, **kwargs)

Automatically instantiate and call the method.

RemoveDomainType(*args, **kwargs)

Automatically instantiate and call the method.

GetAnthroCodes(*args, **kwargs)

Automatically instantiate and call the method.

AddAnthroCode(*args, **kwargs)

Automatically instantiate and call the method.

RemoveAnthroCode(*args, **kwargs)

Automatically instantiate and call the method.

GetVisibleComplexFormBackRefs(*args, **kwargs)

Automatically instantiate and call the method.

GetComplexFormsNotSubentries(*args, **kwargs)

Automatically instantiate and call the method.

GetMinimalLexReferences(*args, **kwargs)

Automatically instantiate and call the method.

GetAllSenses(**kwargs)
MergeObject(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.MSAOperations module

class flexicon.code.Lexicon.MSAOperations.MSAOperations(project)[source]

Bases: BaseOperations

Creation + attach operations for morphosyntactic analyses (MSAs).

A LexSense’s grammatical analysis lives in sense.MorphoSyntaxAnalysisRA, which is a reference to an MSA owned by sense.Entry.MorphoSyntaxAnalysesOC. LCM offers four concrete MSA subtypes that share IMoMorphSynAnalysis as base; each subtype has its own factory whose 2-arg Create overload takes an owner (the sense’s entry) and a SandboxGenericMSA descriptor.

This wrapper hides the ServiceLocator + SandboxGenericMSA dance and auto-attaches the new MSA to the sense, mirroring the read-side coverage in MorphosyntaxAnalysis.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

entry = list(project.LexiconAllEntries())[0]
sense = entry.SensesOS[0]

# Stem MSA (most common case): assign POS to a lexical entry.
verb_pos = project.GramCat.Find("Verb")
project.MSA.CreateStem(sense, verb_pos)

# Derivational affix: noun -> verb
n_pos = project.GramCat.Find("Noun")
v_pos = project.GramCat.Find("Verb")
project.MSA.CreateDerivAff(sense, from_pos=n_pos, to_pos=v_pos)

See also

morphosyntax_analysis.MorphosyntaxAnalysis (reading) msa_collection.MSACollection (iteration)

CreateStem(*args, **kwargs)

Automatically instantiate and call the method.

CreateDerivAff(*args, **kwargs)

Automatically instantiate and call the method.

CreateInflAff(*args, **kwargs)

Automatically instantiate and call the method.

CreateUnclassifiedAffix(*args, **kwargs)

Automatically instantiate and call the method.

SetStemMsaPos(*args, **kwargs)

Automatically instantiate and call the method.

SetDerivAffMsaPos(*args, **kwargs)

Automatically instantiate and call the method.

ChangeAffixVariant(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.PronunciationOperations module

class flexicon.code.Lexicon.PronunciationOperations.PronunciationOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing pronunciations in a FieldWorks project.

Pronunciations represent the phonetic representation of lexical entries, typically using IPA (International Phonetic Alphabet) notation. Each pronunciation can have forms in multiple writing systems (e.g., en-fonipa for IPA), associated audio files, and optional CV (consonant-vowel) pattern location information.

This class should be accessed via FLExProject.Pronunciations property.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

# Get all pronunciations for an entry
entry = list(project.LexiconAllEntries())[0]
for pron in project.Pronunciations.GetAll(entry):
    ipa = project.Pronunciations.GetForm(pron, "en-fonipa")
    print(f"IPA: {ipa}")

# Create a new pronunciation
pron = project.Pronunciations.Create(entry, "rʌn", "en-fonipa")

# Add audio file
project.Pronunciations.AddMediaFile(pron, "/path/to/audio.wav")

# Get media files
media = project.Pronunciations.GetMediaFiles(pron)
print(f"Audio files: {len(media)}")

project.CloseProject()
GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

Reorder(*args, **kwargs)

Automatically instantiate and call the method.

GetForm(*args, **kwargs)

Automatically instantiate and call the method.

SetForm(*args, **kwargs)

Automatically instantiate and call the method.

GetMediaFiles(*args, **kwargs)

Automatically instantiate and call the method.

GetMediaCount(*args, **kwargs)

Automatically instantiate and call the method.

AddMediaFile(*args, **kwargs)

Automatically instantiate and call the method.

RemoveMediaFile(*args, **kwargs)

Automatically instantiate and call the method.

MoveMediaFile(*args, **kwargs)

Automatically instantiate and call the method.

GetLocation(*args, **kwargs)

Automatically instantiate and call the method.

SetLocation(*args, **kwargs)

Automatically instantiate and call the method.

GetOwningEntry(*args, **kwargs)

Automatically instantiate and call the method.

GetGuid(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.SemanticDomainOperations module

class flexicon.code.Lexicon.SemanticDomainOperations.SemanticDomainOperations(project)[source]

Bases: BaseOperations, _LCMNativeCatalogImportMixin

This class provides operations for managing semantic domains in a FieldWorks project.

Semantic domains are hierarchical categorizations of word meanings used to organize the lexicon semantically. Most projects use predefined domain lists (e.g., from SIL), but custom domains can also be created.

This class should be accessed via FLExProject.SemanticDomains property.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

# Get all semantic domains (flat list)
for domain in project.SemanticDomains.GetAll():
    number = project.SemanticDomains.GetNumber(domain)
    name = project.SemanticDomains.GetName(domain)
    print(f"{number} - {name}")

# Find a specific domain by number
domain = project.SemanticDomains.Find("7.2.1")
if domain:
    name = project.SemanticDomains.GetName(domain)
    desc = project.SemanticDomains.GetDescription(domain)
    print(f"{name}: {desc}")

# Get all senses in a domain
senses = project.SemanticDomains.GetSensesInDomain(domain)
print(f"Found {len(senses)} senses in this domain")

project.CloseProject()
CATALOG_FILE = 'SemDom.xml'
CATALOG_SUBDIR = 'Templates'
LCM_FIELD_NAME = 'SemanticDomainList'
LANG_PROJECT_LIST_ATTR = 'SemanticDomainListOA'
DOMAIN_ITEM_LABEL_SINGULAR = 'domain'
DOMAIN_ITEM_LABEL_PLURAL = 'domains'
GetAll(**kwargs)
Find(*args, **kwargs)

Automatically instantiate and call the method.

FindByName(*args, **kwargs)

Automatically instantiate and call the method.

Exists(*args, **kwargs)

Automatically instantiate and call the method.

GetName(*args, **kwargs)

Automatically instantiate and call the method.

SetName(*args, **kwargs)

Automatically instantiate and call the method.

GetDescription(*args, **kwargs)

Automatically instantiate and call the method.

SetDescription(*args, **kwargs)

Automatically instantiate and call the method.

GetAbbreviation(*args, **kwargs)

Automatically instantiate and call the method.

GetNumber(*args, **kwargs)

Automatically instantiate and call the method.

GetQuestions(*args, **kwargs)

Automatically instantiate and call the method.

GetOcmCodes(*args, **kwargs)

Automatically instantiate and call the method.

GetSubdomains(*args, **kwargs)

Automatically instantiate and call the method.

GetParent(*args, **kwargs)

Automatically instantiate and call the method.

GetDepth(*args, **kwargs)

Automatically instantiate and call the method.

GetSensesInDomain(*args, **kwargs)

Automatically instantiate and call the method.

GetSenseCount(*args, **kwargs)

Automatically instantiate and call the method.

Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

ImportCatalog(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.VariantOperations module

class flexicon.code.Lexicon.VariantOperations.VariantOperations(project)[source]

Bases: BaseOperations

This class provides operations for managing variant forms in a FieldWorks project.

Variant forms represent alternative forms of lexical entries, including: - Spelling variants (e.g., “color” vs. “colour”) - Dialectal variants (e.g., regional pronunciations) - Irregularly inflected forms (e.g., “went” as past tense of “go”) - Free variants (e.g., “among” vs. “amongst”)

Variants are linked through ILexEntryRef objects which can connect entries as variants of each other or as components of complex forms.

This class should be accessed via FLExProject.Variants property.

Usage:

from flexlibs2 import FLExProject

project = FLExProject()
project.OpenProject("my project", writeEnabled=True)

# Get all variant types
for vtype in project.Variants.GetAllTypes():
    name = project.Variants.GetTypeName(vtype)
    print(f"Variant type: {name}")

# Find a specific variant type
spelling_type = project.Variants.FindType("Spelling Variant")

# Create a variant
entry = project.LexEntry.Find("color")
variant = project.Variants.Create(entry, "colour", spelling_type)

# Get all variants for an entry
for var in project.Variants.GetAll(entry):
    form = project.Variants.GetForm(var)
    vtype = project.Variants.GetType(var)
    print(f"Variant: {form} ({vtype})")

# For irregularly inflected forms
go_entry = project.LexEntry.Find("go")
went_entry = project.LexEntry.Find("went")
irregular_type = project.Variants.FindType("Irregularly Inflected Form")

# Create variant with component
variant_ref = project.Variants.Create(went_entry, "went", irregular_type)
project.Variants.AddComponentLexeme(variant_ref, go_entry)

project.CloseProject()
GetAllTypes(*args, **kwargs)

Automatically instantiate and call the method.

FindType(*args, **kwargs)

Automatically instantiate and call the method.

GetTypeName(*args, **kwargs)

Automatically instantiate and call the method.

GetTypeDescription(*args, **kwargs)

Automatically instantiate and call the method.

GetAll(**kwargs)
Create(*args, **kwargs)

Automatically instantiate and call the method.

Delete(*args, **kwargs)

Automatically instantiate and call the method.

Duplicate(*args, **kwargs)

Automatically instantiate and call the method.

GetSyncableProperties(*args, **kwargs)

Automatically instantiate and call the method.

CompareTo(*args, **kwargs)

Automatically instantiate and call the method.

GetForm(*args, **kwargs)

Automatically instantiate and call the method.

SetForm(*args, **kwargs)

Automatically instantiate and call the method.

GetType(*args, **kwargs)

Automatically instantiate and call the method.

SetType(*args, **kwargs)

Automatically instantiate and call the method.

GetComponentLexemes(*args, **kwargs)

Automatically instantiate and call the method.

AddComponentLexeme(*args, **kwargs)

Automatically instantiate and call the method.

RemoveComponentLexeme(*args, **kwargs)

Automatically instantiate and call the method.

GetOwningEntry(*args, **kwargs)

Automatically instantiate and call the method.

GetVariantCount(*args, **kwargs)

Automatically instantiate and call the method.

flexicon.code.Lexicon.allomorph module

Wrapper class for allomorph objects with unified interface.

This module provides Allomorph, a wrapper class that transparently handles the two concrete types of allomorphs: - MoStemAllomorph: Allomorphs of stems (StemName property) - MoAffixAllomorph: Allomorphs of affixes (AffixType property)

The wrapper exposes a unified interface for accessing common properties and provides convenience methods for checking type-specific capabilities without exposing the underlying ClassName or casting complexity.

Problem:

Allomorphs have different properties depending on their concrete type: - MoStemAllomorph has StemName property - MoAffixAllomorph has AffixType property

Both have Form (ITsString), PhEnvironmentRC, Gloss, etc.

Users working with mixed collections need to check ClassName and cast to access type-specific properties, which is error-prone and verbose.

Solution:

Allomorph wrapper provides: - Simple properties for common features (form, environment, gloss) - Capability check properties (is_stem_allomorph, is_affix_allomorph) - Property access that works across all types - Optional: Methods for advanced users who know C# types

Example:

from flexlibs2.code.Lexicon.allomorph import Allomorph

# Wrap an allomorph from GetAll()
allomorph = allomorphOps.GetAll(entry)[0]  # Typed as IMoForm
wrapped = Allomorph(allomorph)

# Access common properties
print(wrapped.form)  # Works for all allomorph types
print(wrapped.environment)

# Check capabilities
if wrapped.is_stem_allomorph:
    print("This is a stem allomorph")

# Optional: Advanced users can access concrete types
if wrapped.as_stem_allomorph():
    concrete = wrapped.as_stem_allomorph()
    # Use concrete interface for advanced operations
class flexicon.code.Lexicon.allomorph.Allomorph(lcm_allomorph)[source]

Bases: LCMObjectWrapper

Wrapper for allomorph objects providing unified interface access.

Handles the two concrete types of allomorphs (MoStemAllomorph, MoAffixAllomorph) transparently, providing common properties and capability checks without exposing ClassName or casting.

Variables:
  • _obj – The base interface object (IMoForm)

  • _concrete – The concrete type object (IMoStemAllomorph or IMoAffixAllomorph)

Example:

allomorph = allomorphOps.GetAll(entry)[0]
wrapped = Allomorph(allomorph)
print(wrapped.form)
print(wrapped.environment)
if wrapped.is_stem_allomorph:
    print("Stem allomorph")
property form: str

Get the form (text) of this allomorph.

Returns:

The allomorph form, normalized and stripped of FLEx null markers.

Return type:

str

Example:

print(f"Allomorph form: {wrapped.form}")
# Output: "walk" or "-ing"

Notes

  • Uses vernacular writing system by default

  • Empty string returned if form not set

  • FLEx null marker (***) is normalized to empty string

property gloss: str

Get the gloss of this allomorph.

Returns:

The allomorph gloss, or empty string if not set.

Return type:

str

Example:

if wrapped.gloss:
    print(f"Gloss: {wrapped.gloss}")

Notes

  • Gloss is typically empty for allomorphs (glosses go on senses)

  • This is included for completeness as allomorphs have Gloss field

property environment: list[object]

Get the phonological environments for this allomorph.

Returns:

List of IPhEnvironment objects defining where this allomorph occurs.

Empty list if no environments specified (appears in all contexts).

Return type:

list

Example:

for env in wrapped.environment:
    print(f"Environment: {env.Name}")

if not wrapped.environment:
    print("This allomorph appears in all contexts")

Notes

  • Multiple environments use OR logic

  • Empty list means allomorph appears in any context

  • Environments guide the parser in selecting the appropriate allomorph

property is_stem_allomorph

Check if this is a stem allomorph.

Returns:

True if this is a MoStemAllomorph, False otherwise.

Return type:

bool

Example:

if wrapped.is_stem_allomorph:
    print("This is a stem allomorph")
else:
    print("This is an affix allomorph")

Notes

  • MoStemAllomorph allomorphs are variants of stems/roots

  • MoAffixAllomorph allomorphs are variants of affixes

property is_affix_allomorph

Check if this is an affix allomorph.

Returns:

True if this is a MoAffixAllomorph, False otherwise.

Return type:

bool

Example:

if wrapped.is_affix_allomorph:
    print("This is an affix allomorph")
else:
    print("This is a stem allomorph")

Notes

  • MoAffixAllomorph allomorphs are variants of prefixes, suffixes, etc.

  • MoStemAllomorph allomorphs are variants of stems/roots

property stem_name

Get the stem name (only for stem allomorphs).

Returns:

The stem name if this is a MoStemAllomorph, empty string otherwise.

Return type:

str

Example:

if wrapped.is_stem_allomorph:
    print(f"Stem name: {wrapped.stem_name}")

Notes

  • Only available on MoStemAllomorph

  • Returns empty string for MoAffixAllomorph

  • StemName is a multistring property

property affix_type

Get the affix type (only for affix allomorphs).

Returns:

The affix type if this is a MoAffixAllomorph, None otherwise.

Return type:

IMoMorphType or None

Example:

if wrapped.is_affix_allomorph and wrapped.affix_type:
    print(f"Affix type: {wrapped.affix_type.Name}")

Notes

  • Only available on MoAffixAllomorph

  • Returns None for MoStemAllomorph

  • AffixType indicates prefix, suffix, infix, etc.

as_stem_allomorph()[source]

Cast to IMoStemAllomorph if this is a stem allomorph.

For advanced users who need direct access to the C# concrete interface. Returns None if this is not a MoStemAllomorph.

Returns:

The concrete interface if this is a

MoStemAllomorph, None otherwise.

Return type:

IMoStemAllomorph or None

Example:

if allomorph_obj.as_stem_allomorph():
    concrete = allomorph_obj.as_stem_allomorph()
    # Can now access IMoStemAllomorph-specific methods/properties
    stem_name = concrete.StemName
    # Advanced operations...

Notes

  • For users who know C# interfaces and want advanced control

  • Most users should use properties like is_stem_allomorph and stem_name instead

  • Only useful if you need to call methods or access properties that aren’t exposed through the wrapper

as_affix_allomorph()[source]

Cast to IMoAffixAllomorph if this is an affix allomorph.

For advanced users who need direct access to the C# concrete interface. Returns None if this is not a MoAffixAllomorph.

Returns:

The concrete interface if this is a

MoAffixAllomorph, None otherwise.

Return type:

IMoAffixAllomorph or None

Example:

if allomorph_obj.as_affix_allomorph():
    concrete = allomorph_obj.as_affix_allomorph()
    # Can now access IMoAffixAllomorph-specific methods/properties
    affix_type = concrete.AffixType
    # Advanced operations...

Notes

  • For users who know C# interfaces and want advanced control

  • Most users should use properties like is_affix_allomorph and affix_type instead

property concrete

Get the raw concrete interface object.

For advanced users who need to access the underlying C# interface directly without going through wrapper properties.

Returns:

The concrete interface object (IMoStemAllomorph or IMoAffixAllomorph depending on the allomorph’s actual type).

Example:

# Direct access to concrete interface
concrete = allomorph_obj.concrete
stem_name = concrete.StemName  # MoStemAllomorph property

Notes

  • For power users only

  • Bypasses the wrapper’s abstraction

  • Normal users should prefer wrapper properties like is_stem_allomorph, stem_name, etc.

flexicon.code.Lexicon.allomorph_collection module

Smart collection class for allomorphs.

This module provides AllomorphCollection, a smart collection that manages allomorphs while showing type diversity and supporting unified operations across the two concrete types: - MoStemAllomorph - MoAffixAllomorph

Problem:

GetAll() returns objects with multiple concrete implementations. Users need to: - See which types are in the collection - Filter by type if they want to - Work with all types together without manual casting - Filter by common properties that work across all types

Solution:

AllomorphCollection provides: - __str__() showing type breakdown - by_type() filtering to specific concrete types - filter() for common criteria (form_contains, environment, type) - Convenience methods (stem_allomorphs(), affix_allomorphs()) - Chainable filtering: allomorphs.stem_allomorphs().filter(form_contains=’ing’)

Example:

from flexlibs2.code.Lexicon.allomorph_collection import AllomorphCollection

# GetAll() now returns AllomorphCollection
allomorphs = allomorphOps.GetAll(entry)
print(allomorphs)  # Shows type breakdown
# AllomorphCollection (8 total)
#   MoStemAllomorph: 5 (62%)
#   MoAffixAllomorph: 3 (38%)

# Filter by type
stems = allomorphs.stem_allomorphs()
print(len(stems))  # 5

# Filter by form
ing_allomorphs = allomorphs.filter(form_contains='ing')

# Chain filters
ing_stems = allomorphs.stem_allomorphs().filter(form_contains='ing')

# Iterate
for allomorph in allomorphs:
    print(allomorph.form)
class flexicon.code.Lexicon.allomorph_collection.AllomorphCollection(items=None)[source]

Bases: SmartCollection

Smart collection for allomorphs with type-aware filtering.

Manages collections of allomorph (Allomorph wrapper objects) with type-aware display and filtering capabilities. Supports filtering by common properties (form, environment, type) and by concrete type.

Variables:

_items – List of Allomorph wrapper objects

Example:

allomorphs = allomorphOps.GetAll(entry)  # Returns AllomorphCollection
print(allomorphs)  # Shows type breakdown
stems = allomorphs.stem_allomorphs()  # Filter to MoStemAllomorph
ing = allomorphs.filter(form_contains='ing')  # Form filter
both = allomorphs.stem_allomorphs().filter(form_contains='ing')  # Chain
filter(form_contains=None, environment=None, where=None)[source]

Filter the collection by common allomorph properties.

Supports filtering by properties that work across all allomorph types (form, environment). For complex filtering, use where().

Parameters:
  • form_contains (str, optional) – Filter to allomorphs whose form contains this string (case-sensitive).

  • environment – Filter by environment object or GUID. Can be an IPhEnvironment object or the environment GUID as string.

  • where (callable, optional) – Custom predicate function. If provided, other criteria are ignored.

Returns:

New collection with filtered items.

Return type:

AllomorphCollection

Example:

# Filter by form
ing_allomorphs = allomorphs.filter(form_contains='ing')

# Filter by environment
env = project.lp.PhonologicalDataOA.EnvironmentsOS[0]
env_allomorphs = allomorphs.filter(environment=env)

# Custom filtering
long_forms = allomorphs.where(lambda a: len(a.form) > 3)

# Chain filters
ing_stems = allomorphs.filter(form_contains='ing').stem_allomorphs()

Notes

  • form_contains is case-sensitive

  • All criteria are AND-ed together unless only one is provided

  • where() takes precedence over other criteria

  • Returns new collection (doesn’t modify original)

  • Use where() for complex custom filtering

where(predicate)[source]

Filter using a custom predicate function.

For filtering by complex criteria or properties not supported by filter().

Parameters:

predicate (callable) – Function that takes an Allomorph and returns True to include it in the result.

Returns:

New collection with items matching the predicate.

Return type:

AllomorphCollection

Example:

# Complex predicate: allomorphs with form length > 3
long_forms = allomorphs.where(lambda a: len(a.form) > 3)

# Combining conditions
stem_with_env = allomorphs.where(
    lambda a: a.is_stem_allomorph and len(a.environment) > 0
)

# Type checking combined with other criteria
affix_only = allomorphs.where(lambda a: a.is_affix_allomorph)

Notes

  • Predicate receives each Allomorph object

  • Return True to include in result, False to exclude

  • For simple filters (form, environment), use filter() instead

stem_allomorphs()[source]

Get only the stem allomorphs from the collection.

Convenience method for filtering to MoStemAllomorph objects only.

Returns:

New collection with only MoStemAllomorph objects.

Return type:

AllomorphCollection

Example:

stems = allomorphs.stem_allomorphs()
print(f"Found {len(stems)} stem allomorphs")

# Chain with other filters
ing_stems = allomorphs.stem_allomorphs().filter(form_contains='ing')

Notes

  • Equivalent to by_type(‘MoStemAllomorph’)

  • Stem allomorphs are variants of stems/roots

  • Use is_stem_allomorph on individual allomorphs to check type

affix_allomorphs()[source]

Get only the affix allomorphs from the collection.

Convenience method for filtering to MoAffixAllomorph objects only.

Returns:

New collection with only MoAffixAllomorph objects.

Return type:

AllomorphCollection

Example:

affixes = allomorphs.affix_allomorphs()
print(f"Found {len(affixes)} affix allomorphs")

# Chain with other filters
ing_affixes = allomorphs.affix_allomorphs().filter(form_contains='ing')

Notes

  • Equivalent to by_type(‘MoAffixAllomorph’)

  • Affix allomorphs are variants of prefixes, suffixes, infixes, etc.

  • Use is_affix_allomorph on individual allomorphs to check type

flexicon.code.Lexicon.morphosyntax_analysis module

Wrapper class for morphosyntactic analysis (MSA) objects with unified interface.

This module provides MorphosyntaxAnalysis, a wrapper class that transparently handles the four concrete types of morphosyntactic analyses: - MoStemMsa: Stem (root) analysis with Part of Speech - MoDerivAffMsa: Derivational affix analysis with from/to Part of Speech - MoInflAffMsa: Inflectional affix analysis with Part of Speech and slots - MoUnclassifiedAffixMsa: Unclassified affix analysis

All share base interface IMoMorphSynAnalysis.

Problem:

MSAs have different properties depending on their concrete type:

  • All have PartOfSpeechRA or similar properties for grammatical category

  • MoDerivAffMsa has FromPartOfSpeechRA and ToPartOfSpeechRA (input/output POS)

  • MoInflAffMsa has PartOfSpeechRA and inflection class references

  • Users working with mixed collections need to check ClassName and cast to access type-specific properties, which is error-prone and verbose.

Solution:

MorphosyntaxAnalysis wrapper provides:

  • Simple properties for common features (pos_main, class_type)

  • Capability check properties (is_stem_msa, is_deriv_aff_msa, etc.)

  • Property access that works across all types

  • Optional: Methods for advanced users who know C# types

Example:

from flexlibs2.code.Lexicon.morphosyntax_analysis import MorphosyntaxAnalysis

# Wrap an MSA from entry.MorphoSyntaxAnalysesOC
msa = entry.MorphoSyntaxAnalysesOC[0]
wrapped = MorphosyntaxAnalysis(msa)

# Access common properties
if wrapped.is_stem_msa:
    print(f"Stem with POS: {wrapped.pos_main}")

if wrapped.is_deriv_aff_msa:
    from_pos = wrapped.pos_from
    to_pos = wrapped.pos_to
    print(f"Derives: {from_pos} -> {to_pos}")

# Check capabilities
if wrapped.has_from_pos:
    print(f"From POS: {wrapped.pos_from}")

# Optional: Advanced users can access concrete types
if wrapped.as_stem_msa():
    concrete = wrapped.as_stem_msa()
    # Use concrete interface for advanced operations
class flexicon.code.Lexicon.morphosyntax_analysis.MorphosyntaxAnalysis(lcm_msa)[source]

Bases: LCMObjectWrapper

Wrapper for morphosyntactic analysis objects providing unified interface access.

Handles the four concrete types of MSAs (MoStemMsa, MoDerivAffMsa, MoInflAffMsa, MoUnclassifiedAffixMsa) transparently, providing common properties and capability checks without exposing ClassName or casting.

Variables:
  • _obj – The base interface object (IMoMorphSynAnalysis)

  • _concrete – The concrete type object (IMoStemMsa, IMoDerivAffMsa, IMoInflAffMsa, or IMoUnclassifiedAffixMsa)

Example:

msa = entry.MorphoSyntaxAnalysesOC[0]
wrapped = MorphosyntaxAnalysis(msa)
print(wrapped.class_type)
if wrapped.is_stem_msa:
    print(wrapped.pos_main)
property is_stem_msa

Check if this is a stem MSA (MoStemMsa).

Returns:

True if this is a MoStemMsa object.

Return type:

bool

Example:

if wrapped.is_stem_msa:
    pos = wrapped.pos_main
    print(f"Stem POS: {pos}")
property is_deriv_aff_msa

Check if this is a derivational affix MSA (MoDerivAffMsa).

Returns:

True if this is a MoDerivAffMsa object.

Return type:

bool

Example:

if wrapped.is_deriv_aff_msa:
    from_pos = wrapped.pos_from
    to_pos = wrapped.pos_to
    print(f"Derives: {from_pos} -> {to_pos}")
property is_infl_aff_msa

Check if this is an inflectional affix MSA (MoInflAffMsa).

Returns:

True if this is a MoInflAffMsa object.

Return type:

bool

Example:

if wrapped.is_infl_aff_msa:
    pos = wrapped.pos_main
    print(f"Inflectional affix for POS: {pos}")
property is_unclassified_aff_msa

Check if this is an unclassified affix MSA (MoUnclassifiedAffixMsa).

Returns:

True if this is a MoUnclassifiedAffixMsa object.

Return type:

bool

Example:

if wrapped.is_unclassified_aff_msa:
    pos = wrapped.pos_main
    print(f"Unclassified affix with POS: {pos}")
property pos_main

Get the main Part of Speech for this MSA.

Returns the PartOfSpeechRA for stem and inflectional affixes, and ToPartOfSpeechRA for derivational affixes (output POS).

Returns:

The main POS reference, or None if not set.

Return type:

IPartOfSpeech or None

Example:

if wrapped.pos_main:
    pos_name = wrapped.pos_main.Name.BestAnalysisAlternative.Text
    print(f"POS: {pos_name}")

Notes

  • For MoStemMsa, MoInflAffMsa, MoUnclassifiedAffixMsa: PartOfSpeechRA

  • For MoDerivAffMsa: ToPartOfSpeechRA (output POS)

  • Use pos_from for derivational affix input POS

property has_from_pos

Check if this MSA has a “from” Part of Speech (input POS).

Only meaningful for derivational affixes, which show what POS something derives from. Returns False for all other MSA types.

Returns:

True if this is a MoDerivAffMsa with FromPartOfSpeechRA set.

Return type:

bool

Example:

if wrapped.has_from_pos:
    from_pos = wrapped.pos_from
    to_pos = wrapped.pos_to
    print(f"Derives: {from_pos} -> {to_pos}")

Notes

  • Only MoDerivAffMsa has FromPartOfSpeechRA

  • Always False for MoStemMsa, MoInflAffMsa, MoUnclassifiedAffixMsa

property pos_from

Get the “from” Part of Speech for derivational affixes.

Only meaningful for MoDerivAffMsa. Shows the POS before derivation. Returns None for all other MSA types.

Returns:

The input POS for derivational affixes,

or None if not a derivational affix or not set.

Return type:

IPartOfSpeech or None

Example:

if wrapped.has_from_pos:
    from_pos = wrapped.pos_from
    to_pos = wrapped.pos_to
    print(f"Derives {from_pos.Name} to {to_pos.Name}")

Notes

  • Only meaningful for MoDerivAffMsa

  • Returns None for MoStemMsa, MoInflAffMsa, MoUnclassifiedAffixMsa

  • Use pos_to to get the output POS

property pos_to

Get the “to” Part of Speech for derivational affixes.

For derivational affixes, this is the output POS (what you get after applying the derivation). For other MSA types, returns the same as pos_main.

Returns:

The output POS for derivational affixes,

or the main POS for other types, or None if not set.

Return type:

IPartOfSpeech or None

Example:

if wrapped.is_deriv_aff_msa:
    from_pos = wrapped.pos_from
    to_pos = wrapped.pos_to
    print(f"Change: {from_pos} -> {to_pos}")

Notes

  • For MoDerivAffMsa: ToPartOfSpeechRA (output after derivation)

  • For other types: Same as pos_main

as_stem_msa()[source]

Cast to IMoStemMsa if this is a stem MSA.

For advanced users who need direct access to the C# concrete interface. Returns None if this is not a MoStemMsa.

Returns:

The concrete interface if this is a

MoStemMsa, None otherwise.

Return type:

IMoStemMsa or None

Example:

if wrapped.as_stem_msa():
    concrete = wrapped.as_stem_msa()
    # Can now access IMoStemMsa-specific methods/properties
    # Advanced operations...

Notes

  • For users who know C# interfaces and want advanced control

  • Most users should use properties like pos_main instead

  • Only useful if you need to call methods or access properties that aren’t exposed through the wrapper

as_deriv_aff_msa()[source]

Cast to IMoDerivAffMsa if this is a derivational affix MSA.

For advanced users who need direct access to the C# concrete interface. Returns None if this is not a MoDerivAffMsa.

Returns:

The concrete interface if this is a

MoDerivAffMsa, None otherwise.

Return type:

IMoDerivAffMsa or None

Example:

if wrapped.as_deriv_aff_msa():
    concrete = wrapped.as_deriv_aff_msa()
    # Can now access IMoDerivAffMsa-specific methods/properties

Notes

  • For users who know C# interfaces and want advanced control

  • Most users should use properties like pos_from and pos_to instead

as_infl_aff_msa()[source]

Cast to IMoInflAffMsa if this is an inflectional affix MSA.

For advanced users who need direct access to the C# concrete interface. Returns None if this is not a MoInflAffMsa.

Returns:

The concrete interface if this is a

MoInflAffMsa, None otherwise.

Return type:

IMoInflAffMsa or None

Example:

if wrapped.as_infl_aff_msa():
    concrete = wrapped.as_infl_aff_msa()
    # Can now access IMoInflAffMsa-specific methods/properties

Notes

  • For users who know C# interfaces and want advanced control

  • Most users should use properties like pos_main instead

as_unclassified_aff_msa()[source]

Cast to IMoUnclassifiedAffixMsa if this is an unclassified affix MSA.

For advanced users who need direct access to the C# concrete interface. Returns None if this is not a MoUnclassifiedAffixMsa.

Returns:

The concrete interface if this is a

MoUnclassifiedAffixMsa, None otherwise.

Return type:

IMoUnclassifiedAffixMsa or None

Example:

if wrapped.as_unclassified_aff_msa():
    concrete = wrapped.as_unclassified_aff_msa()
    # Can now access IMoUnclassifiedAffixMsa-specific methods/properties

Notes

  • For users who know C# interfaces and want advanced control

  • Most users should use properties like pos_main instead

property concrete

Get the raw concrete interface object.

For advanced users who need to access the underlying C# interface directly without going through wrapper properties.

Returns:

The concrete interface object (IMoStemMsa, IMoDerivAffMsa, IMoInflAffMsa, or IMoUnclassifiedAffixMsa depending on the MSA’s actual type).

Example:

# Direct access to concrete interface
concrete = msa_obj.concrete
pos = concrete.PartOfSpeechRA  # MSA type-specific property

Notes

  • For power users only

  • Bypasses the wrapper’s abstraction

  • Normal users should prefer wrapper properties like is_stem_msa, pos_main, etc.

flexicon.code.Lexicon.msa_collection module

Smart collection class for morphosyntactic analyses.

This module provides MSACollection, a smart collection that manages morphosyntactic analyses while showing type diversity and supporting unified operations across the four concrete types: - MoStemMsa - MoDerivAffMsa - MoInflAffMsa - MoUnclassifiedAffixMsa

Problem:

entry.MorphoSyntaxAnalysesOC returns objects with multiple concrete implementations. Users need to:

  • See which types are in the collection

  • Filter by type if they want to

  • Work with all types together without manual casting

  • Filter by common properties that work across all types

Solution:

MSACollection provides:

  • __str__() showing type breakdown

  • by_type() filtering to specific concrete types

  • filter() for common criteria (pos_main, has_pos, where_predicate)

  • Convenience methods (stem_msas(), deriv_aff_msas(), infl_aff_msas(), unclassified_aff_msas())

  • Chainable filtering: msas.stem_msas().filter(pos_main=some_pos)

Example:

from flexlibs2.code.Lexicon.msa_collection import MSACollection

# entry.MorphoSyntaxAnalysesOC already wrapped by LexEntryOperations
msas = entry_ops.GetMorphoSyntaxAnalyses(entry)
print(msas)  # Shows type breakdown
# MSACollection (8 total)
#   MoStemMsa: 4 (50%)
#   MoDerivAffMsa: 2 (25%)
#   MoInflAffMsa: 2 (25%)

# Filter by type
stem_only = msas.stem_msas()
print(len(stem_only))  # 4

# Filter by POS
target_pos = ...
matching = msas.filter(pos_main=target_pos)

# Chain filters
stem_with_pos = msas.stem_msas().filter(pos_main=target_pos)

# Iterate
for msa in msas:
    print(msa.class_type)
class flexicon.code.Lexicon.msa_collection.MSACollection(items=None)[source]

Bases: SmartCollection

Smart collection for morphosyntactic analyses with type-aware filtering.

Manages collections of morphosyntactic analysis objects (MorphosyntaxAnalysis wrapper objects) with type-aware display and filtering capabilities. Supports filtering by common properties (POS, has_pos) and by concrete type.

Variables:

_items – List of MorphosyntaxAnalysis wrapper objects

Example:

msas = entry_ops.GetMorphoSyntaxAnalyses(entry)
print(msas)  # Shows type breakdown
stem = msas.stem_msas()  # Filter to MoStemMsa
with_pos = msas.filter(pos_main=target_pos)  # POS filter
both = msas.stem_msas().filter(pos_main=target_pos)  # Chain
filter(pos_main=None, has_pos=None, where=None)[source]

Filter the collection by common MSA properties.

Supports filtering by properties that work across all MSA types (pos_main, has_pos). For complex filtering, use where().

Parameters:
  • pos_main (IPartOfSpeech, optional) – Filter to MSAs with this Part of Speech (uses GUID comparison). For derivational affixes, this filters by ToPartOfSpeechRA.

  • has_pos (bool, optional) – If True, only include MSAs with a pos_main set. If False, only include MSAs without pos_main.

  • where (callable, optional) – Custom predicate function. If provided, other criteria are ignored.

Returns:

New collection with filtered items.

Return type:

MSACollection

Example:

# Filter by POS
target_pos = ...
matching = msas.filter(pos_main=target_pos)

# Filter by presence of POS
with_pos = msas.filter(has_pos=True)
without_pos = msas.filter(has_pos=False)

# Custom filtering
deriv_with_pos = msas.where(
    lambda m: m.is_deriv_aff_msa and m.has_from_pos
)

# Chain filters
stem_with_pos = msas.stem_msas().filter(pos_main=target_pos)

Notes

  • pos_main comparison uses GUID string comparison

  • has_pos and pos_main filters are AND-ed together

  • where() takes precedence over other criteria

  • Returns new collection (doesn’t modify original)

  • Use where() for complex custom filtering

where(predicate)[source]

Filter using a custom predicate function.

For filtering by complex criteria or properties not supported by filter().

Parameters:

predicate (callable) – Function that takes a MorphosyntaxAnalysis and returns True to include it in the result.

Returns:

New collection with items matching the predicate.

Return type:

MSACollection

Example:

# Complex predicate: derivational affixes with from/to POS
deriv_with_both = msas.where(
    lambda m: m.is_deriv_aff_msa and
              m.pos_from is not None and
              m.pos_to is not None
)

# Combining conditions
specific = msas.where(
    lambda m: m.is_stem_msa and m.pos_main is not None
)

# Type checking combined with other criteria
non_stem = msas.where(lambda m: not m.is_stem_msa)

Notes

  • Predicate receives each MorphosyntaxAnalysis object

  • Return True to include in result, False to exclude

  • For simple filters (pos_main, has_pos), use filter() instead

stem_msas()[source]

Get only the stem (MoStemMsa) MSAs from the collection.

Convenience method for filtering to MoStemMsa objects only.

Returns:

New collection with only MoStemMsa objects.

Return type:

MSACollection

Example:

stem = msas.stem_msas()
print(f"Found {len(stem)} stem MSAs")

# Chain with other filters
stem_with_pos = msas.stem_msas().filter(has_pos=True)

Notes

  • Equivalent to by_type(‘MoStemMsa’)

  • Stem MSAs have PartOfSpeechRA for the main POS

  • Use is_stem_msa on individual MSAs to check type

deriv_aff_msas()[source]

Get only the derivational affix (MoDerivAffMsa) MSAs from the collection.

Convenience method for filtering to MoDerivAffMsa objects only.

Returns:

New collection with only MoDerivAffMsa objects.

Return type:

MSACollection

Example:

deriv = msas.deriv_aff_msas()
print(f"Found {len(deriv)} derivational affix MSAs")

# Chain with other filters
deriv_with_from = msas.deriv_aff_msas().filter(has_pos=True)

Notes

  • Equivalent to by_type(‘MoDerivAffMsa’)

  • Derivational affixes have FromPartOfSpeechRA and ToPartOfSpeechRA

  • Use is_deriv_aff_msa on individual MSAs to check type

infl_aff_msas()[source]

Get only the inflectional affix (MoInflAffMsa) MSAs from the collection.

Convenience method for filtering to MoInflAffMsa objects only.

Returns:

New collection with only MoInflAffMsa objects.

Return type:

MSACollection

Example:

infl = msas.infl_aff_msas()
print(f"Found {len(infl)} inflectional affix MSAs")

# Chain with other filters
infl_with_pos = msas.infl_aff_msas().filter(has_pos=True)

Notes

  • Equivalent to by_type(‘MoInflAffMsa’)

  • Inflectional affixes have PartOfSpeechRA and slot references

  • Use is_infl_aff_msa on individual MSAs to check type

unclassified_aff_msas()[source]

Get only the unclassified affix (MoUnclassifiedAffixMsa) MSAs from the collection.

Convenience method for filtering to MoUnclassifiedAffixMsa objects only.

Returns:

New collection with only MoUnclassifiedAffixMsa objects.

Return type:

MSACollection

Example:

unclass = msas.unclassified_aff_msas()
print(f"Found {len(unclass)} unclassified affix MSAs")

# Chain with other filters
unclass_with_pos = msas.unclassified_aff_msas().filter(has_pos=True)

Notes

  • Equivalent to by_type(‘MoUnclassifiedAffixMsa’)

  • Unclassified affixes have PartOfSpeechRA

  • Use is_unclassified_aff_msa on individual MSAs to check type

Module contents