flexicon.code.TextsWords package¶
Submodules¶
flexicon.code.TextsWords.DiscourseOperations module¶
- class flexicon.code.TextsWords.DiscourseOperations.DiscourseOperations(project)[source]¶
Bases:
BaseOperationsDiscourse and constituent chart management operations for FLEx projects.
This class provides methods for creating and managing discourse charts and constituent charts. Charts provide a visual analysis of text structure, showing relationships between clauses, participants, and discourse features.
Note
Charts are complex UI-heavy features. This class focuses on data access and basic chart structure management. Full chart editing capabilities typically require the FLEx UI.
Usage:
from flexlibs2 import FLExProject, DiscourseOperations project = FLExProject() project.OpenProject("my project", writeEnabled=True) discourse_ops = DiscourseOperations(project) # Get a text text = list(project.Texts.GetAll())[0] # Get all charts for the text charts = list(discourse_ops.GetAllCharts(text)) print(f"Text has {len(charts)} charts") # Create a new constituent chart chart = discourse_ops.CreateChart(text, "Main Chart", "constituent") chart_name = discourse_ops.GetChartName(chart) print(f"Created chart: {chart_name}") # Add rows to the chart row1 = discourse_ops.AddRow(chart) row2 = discourse_ops.AddRow(chart) row_count = discourse_ops.GetRowCount(chart) print(f"Chart has {row_count} rows") # Get chart rows rows = discourse_ops.GetRows(chart) for i, row in enumerate(rows, 1): print(f"Row {i}") project.CloseProject()
- GetAllCharts(*args, **kwargs)¶
Automatically instantiate and call the method.
- CreateChart(*args, **kwargs)¶
Automatically instantiate and call the method.
- DeleteChart(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetChartName(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetChartName(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetChartType(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetRows(**kwargs)¶
- GetRowCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddRow(*args, **kwargs)¶
Automatically instantiate and call the method.
- DeleteRow(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetCells(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetCellContent(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetCellContent(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetOwningText(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetGuid(*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.
flexicon.code.TextsWords.ParagraphOperations module¶
- class flexicon.code.TextsWords.ParagraphOperations.ParagraphOperations(project)[source]¶
Bases:
BaseOperationsParagraph CRUD operations for managing FLEx paragraph objects.
This class provides methods for creating, reading, updating, and deleting paragraphs within texts in a FieldWorks Language Explorer project.
- Usage:
project = FLExProject() project.OpenProject(“MyProject”, writeEnabled=True)
# Access through the Paragraphs property para_ops = ParagraphOperations(project)
# Or if integrated into FLExProject: # text = project.Texts.Create(“Genesis”) # para = project.Paragraphs.Create(text, “In the beginning…”)
- 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.
- GetAll(**kwargs)¶
- GetText(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetText(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetSegments(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetSegmentCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- InsertAt(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.TextsWords.SegmentOperations module¶
- class flexicon.code.TextsWords.SegmentOperations.SegmentOperations(project)[source]¶
Bases:
BaseOperationsThis class provides operations for managing segments in a FieldWorks project.
Segments represent the units of text analysis in FLEx, typically sentences or clauses within paragraphs. Each segment can have baseline text, analyses, translations (free and literal), and notes.
The write path follows the LCM idiom:
Edit IStTxtPara.Contents (via TsStringBuilder) first.
Assign builder.GetString() to para.Contents - this fires ContentsSideEffects which triggers AnalysisAdjuster to reconcile segment offsets automatically.
Then update SegmentsOS (Add/Insert/Remove) as needed.
Usage:
from flexlibs2 import FLExProject project = FLExProject() project.OpenProject("my project", writeEnabled=True) # Get all segments in a paragraph para = project.Object(para_hvo) for segment in project.Segments.GetAll(para): baseline = project.Segments.GetBaselineText(segment) print(baseline) # Append a new sentence to a paragraph new_seg = project.Segments.AppendSentence(para, "A new sentence.") # Split a segment at a character offset within that segment seg1, seg2 = project.Segments.SplitSegment(new_seg, 5) # Merge two adjacent segments (migrates translations by default) merged = project.Segments.MergeSegments(seg1, seg2) # Set translations on a segment project.Segments.SetFreeTranslation(merged, "In the beginning...") project.Segments.SetLiteralTranslation(merged, "In-the beginning...") # Reparse a paragraph from its Contents (use only to repair corruption) project.Segments.ReparseParagraph(para) project.CloseProject()
- GetAll(**kwargs)¶
- GetAnalyses(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetBaselineText(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetBaselineText(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetFreeTranslation(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetFreeTranslation(*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.
- GetNotes(*args, **kwargs)¶
Automatically instantiate and call the method.
- AppendSentence(*args, **kwargs)¶
Automatically instantiate and call the method.
- Delete(*args, **kwargs)¶
Automatically instantiate and call the method.
- SplitSegment(*args, **kwargs)¶
Automatically instantiate and call the method.
- MergeSegments(*args, **kwargs)¶
Automatically instantiate and call the method.
- ReparseParagraph(*args, **kwargs)¶
Automatically instantiate and call the method.
- Exists(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetBeginOffset(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetEndOffset(*args, **kwargs)¶
Automatically instantiate and call the method.
- IsLabel(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetIsLabel(*args, **kwargs)¶
Automatically instantiate and call the method.
- ValidateSegments(*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.TextsWords.TextOperations module¶
- class flexicon.code.TextsWords.TextOperations.TextOperations(project)[source]¶
Bases:
BaseOperationsText operations for managing FLEx Text objects.
This class provides methods for creating, reading, updating, and deleting texts in a FieldWorks Language Explorer project.
- Usage:
project = FLExProject() project.OpenProject(“MyProject”, writeEnabled=True)
# Access through the Texts property text_ops = TextOperations(project)
# Or if integrated into FLExProject: # new_text = project.Texts.Create(“Story 1”)
- 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.
- Exists(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAll(**kwargs)¶
- Find(*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.
- GetGenre(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetGenre(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetContents(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetParagraphs(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetParagraphCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetMediaFiles(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddMediaFile(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAbbreviation(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetIsTranslated(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetIsTranslated(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.TextsWords.WfiAnalysisOperations module¶
- class flexicon.code.TextsWords.WfiAnalysisOperations.ApprovalStatusTypes(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnumApproval status values for wordform analyses.
IntEnum so existing callers that compared by the underlying integer keep working:
ApprovalStatusTypes.APPROVED == 2is still True, andint(ApprovalStatusTypes.APPROVED) == 2for explicit coercion. New callers can also passTrue/False/Nonedirectly toSetApprovalStatus()(more user-centric per CLAUDE.md). (issue #59)- DISAPPROVED = 0¶
- UNAPPROVED = 1¶
- APPROVED = 2¶
- class flexicon.code.TextsWords.WfiAnalysisOperations.WfiAnalysisOperations(project)[source]¶
Bases:
BaseOperationsProvides operations for managing wordform analyses in a FLEx project.
Wordform analyses represent linguistic analyses of wordforms, including morphological breakdowns, glosses, grammatical categories, and approval status. Each wordform can have multiple analyses representing different possible interpretations.
This class should be accessed via FLExProject.WfiAnalyses property.
Example
>>> project = FLExProject() >>> project.OpenProject("MyProject", writeEnabled=True) >>> # Get wordform and its analyses >>> wf = project.Wordforms.Find("running") >>> analyses = project.WfiAnalyses.GetAll(wf) >>> for analysis in analyses: ... glosses = project.WfiAnalyses.GetGlosses(analysis) ... print(f"Analysis: {glosses}") >>> # Create new analysis >>> new_analysis = project.WfiAnalyses.Create(wf) >>> # Add gloss >>> project.WfiAnalyses.AddGloss(new_analysis, "running", "en") >>> # Approve analysis >>> project.WfiAnalyses.ApproveAnalysis(new_analysis)
- GetAll(**kwargs)¶
- Create(*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.
- Delete(*args, **kwargs)¶
Automatically instantiate and call the method.
- Duplicate(*args, **kwargs)¶
Automatically instantiate and call the method.
- Exists(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetApprovalStatus(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetApprovalStatus(*args, **kwargs)¶
Automatically instantiate and call the method.
- IsHumanApproved(*args, **kwargs)¶
Automatically instantiate and call the method.
- IsComputerApproved(*args, **kwargs)¶
Automatically instantiate and call the method.
- ApproveAnalysis(*args, **kwargs)¶
Automatically instantiate and call the method.
- RejectAnalysis(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetGlosses(**kwargs)¶
- GetGlossCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddGloss(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetMorphBundles(**kwargs)¶
- GetMorphBundleCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetCategory(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetCategory(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAgentEvaluation(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetHumanEvaluation(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetEvaluations(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetOwningWordform(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetGuid(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.TextsWords.WfiGlossOperations module¶
- class flexicon.code.TextsWords.WfiGlossOperations.WfiGlossOperations(project)[source]¶
Bases:
BaseOperationsProvides operations for managing wordform glosses (WfiGloss) in a FLEx project.
WfiGloss objects represent glosses (meanings/translations) for wordform analyses. Each WfiAnalysis can have multiple glosses in different writing systems. Glosses provide the semantic interpretation of an analyzed wordform.
This class should be accessed via FLExProject.WfiGlosses property.
Example
>>> project = FLExProject() >>> project.OpenProject("MyProject", writeEnabled=True) >>> # Get a wordform and its first analysis >>> wf = project.Wordforms.Find("running") >>> analyses = project.Wordforms.GetAnalyses(wf) >>> if analyses: ... analysis = analyses[0] ... # Get all glosses for the analysis ... for gloss in project.WfiGlosses.GetAll(analysis): ... form = project.WfiGlosses.GetForm(gloss) ... print(f"Gloss: {form}") ... # Create a new gloss ... new_gloss = project.WfiGlosses.Create(analysis, "running", "en") ... # Update gloss form ... project.WfiGlosses.SetForm(new_gloss, "to run", "en") >>> project.CloseProject()
- GetAll(**kwargs)¶
- Create(*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.
- Delete(*args, **kwargs)¶
Automatically instantiate and call the method.
- Duplicate(*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.
- GetAllForms(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetOwningAnalysis(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetGuid(*args, **kwargs)¶
Automatically instantiate and call the method.
- Find(*args, **kwargs)¶
Automatically instantiate and call the method.
- Exists(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetBestForm(*args, **kwargs)¶
Automatically instantiate and call the method.
- CopyGloss(*args, **kwargs)¶
Automatically instantiate and call the method.
- ClearForm(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.TextsWords.WfiMorphBundleOperations module¶
- class flexicon.code.TextsWords.WfiMorphBundleOperations.WfiMorphBundleOperations(project)[source]¶
Bases:
BaseOperationsThis class provides operations for managing morpheme bundles in a FieldWorks project.
Morpheme bundles (IWfiMorphBundle) represent individual morphemes within a wordform analysis. Each bundle contains the morpheme’s form, gloss, and links to lexical information (sense, MSA, morph type, inflection class).
In FLEx’s interlinear text system, a wordform analysis consists of multiple morph bundles that break down the word into its constituent morphemes. For example, the word “running” might have two bundles: “run” (stem) + “-ing” (suffix).
Usage:
from flexlibs2 import FLExProject project = FLExProject() project.OpenProject("my project", writeEnabled=True) # Get a wordform and its analysis wordform = project.Wordforms.Find("running") analyses = project.Wordforms.GetAnalyses(wordform) if analyses: analysis = analyses[0] # Get all morph bundles for the analysis bundles = project.MorphBundles.GetAll(analysis) for bundle in bundles: form = project.MorphBundles.GetForm(bundle) gloss = project.MorphBundles.GetGloss(bundle) print(f"{form} - {gloss}") # Create a new morph bundle bundle = project.MorphBundles.Create(analysis) project.MorphBundles.SetForm(bundle, "run") project.MorphBundles.SetGloss(bundle, "run") # Link to lexicon sense = project.LexiconAllSenses()[0] project.MorphBundles.SetSense(bundle, sense) 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.
- GetGloss(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetGloss(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetSense(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetSense(*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.
- GetMSA(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetMSA(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetInflType(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetInflType(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetInflectionClass(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetInflectionClass(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetOwningAnalysis(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetGuid(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.TextsWords.WordformOperations module¶
- class flexicon.code.TextsWords.WordformOperations.SpellingStatusStates[source]¶
Bases:
objectSpelling status values for wordforms.
- UNDECIDED = 0¶
- INCORRECT = 1¶
- CORRECT = 2¶
- class flexicon.code.TextsWords.WordformOperations.WordformOperations(project)[source]¶
Bases:
BaseOperationsProvides operations for managing wordforms in a FLEx project.
Wordforms represent surface forms of words as they appear in texts. Each wordform can have multiple analyses and a spelling status.
This class should be accessed via FLExProject.Wordforms property.
Example
>>> project = FLExProject() >>> project.OpenProject("MyProject") >>> # Get all wordforms >>> for wf in project.Wordforms.GetAll(): ... print(project.Wordforms.GetForm(wf)) >>> # Create a new wordform >>> wf = project.Wordforms.Create("running") >>> # Set spelling status >>> project.Wordforms.SetSpellingStatus(wf, SpellingStatusStates.CORRECT)
- Known Limitations:
Deep copy of wordform analyses (deep=True in Duplicate) is not yet implemented. See Duplicate() method for details and workaround.
- GetAll(**kwargs)¶
- Create(*args, **kwargs)¶
Automatically instantiate and call the method.
- Delete(*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.
- GetForm(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetForm(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetSpellingStatus(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetSpellingStatus(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAnalyses(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetOccurrenceCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetOccurrences(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetChecksum(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAllWithStatus(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAllUnapproved(*args, **kwargs)¶
Automatically instantiate and call the method.
- ApproveSpelling(*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.