flexicon.code.Notebook package¶
Submodules¶
flexicon.code.Notebook.AnthropologyOperations module¶
- class flexicon.code.Notebook.AnthropologyOperations.AnthropologyOperations(project)[source]¶
Bases:
BaseOperations,_LCMNativeCatalogImportMixinThis class provides operations for managing anthropological and cultural items in a FieldWorks project.
Anthropological items (ICmAnthroItem) are used to categorize and organize cultural information collected during fieldwork. They support hierarchical organization, OCM (Outline of Cultural Materials) codes, and linking to texts and researchers. These items help linguists document cultural context alongside linguistic data.
This class should be accessed via FLExProject.Anthropology property.
Usage:
from flexlibs2 import FLExProject project = FLExProject() project.OpenProject("my project", writeEnabled=True) # Create a new anthropology item item = project.Anthropology.Create("Marriage Customs", "MAR") # Set OCM code project.Anthropology.SetAnthroCode(item, "586") # Set description project.Anthropology.SetDescription(item, "Traditional marriage practices and ceremonies") # Create hierarchical structure subitem = project.Anthropology.CreateSubitem(item, "Wedding Ceremony", "WED") # Link to texts text = project.Texts.Find("Wedding Story 1") if text: project.Anthropology.AddText(item, text) # Get all items linked to a specific text for anthro_item in project.Anthropology.GetItemsForText(text): name = project.Anthropology.GetName(anthro_item) code = project.Anthropology.GetAnthroCode(anthro_item) print(f"{name} ({code})") project.CloseProject()
- CATALOG_FILE = 'OCM.xml'¶
- FRAME_CATALOG_FILE = 'OCM-Frame.xml'¶
- CATALOG_SUBDIR = 'Templates'¶
- LCM_FIELD_NAME = 'AnthroList'¶
- LANG_PROJECT_LIST_ATTR = 'AnthroListOA'¶
- DOMAIN_ITEM_LABEL_SINGULAR = 'anthropology item'¶
- DOMAIN_ITEM_LABEL_PLURAL = 'items'¶
- GetAll(**kwargs)¶
- Create(*args, **kwargs)¶
Automatically instantiate and call the method.
- CreateSubitem(*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.
- FindByCode(*args, **kwargs)¶
Automatically instantiate and call the method.
- FindByCategory(*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.
- GetAbbreviation(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetAbbreviation(*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.
- GetAnthroCode(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetAnthroCode(*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.
- GetSubitems(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetParent(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetTexts(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddText(*args, **kwargs)¶
Automatically instantiate and call the method.
- RemoveText(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetTextCount(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetItemsForText(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetResearchers(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddResearcher(*args, **kwargs)¶
Automatically instantiate and call the method.
- RemoveResearcher(*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.
- ImportFrameCatalog(*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.
- GetGuid(*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.
flexicon.code.Notebook.DataNotebookOperations module¶
- class flexicon.code.Notebook.DataNotebookOperations.DataNotebookOperations(project)[source]¶
Bases:
BaseOperationsThis class provides operations for managing research notebook records in a FieldWorks project.
Research notebook records (IRnGenericRec) are used to document field research, observations, interviews, and other data collection activities. They support hierarchical organization, linking to texts and participants, media attachments, categorization by record type, and status tracking.
Notebook records are essential for documenting the research process and maintaining a structured record of linguistic fieldwork activities.
This class should be accessed via FLExProject.DataNotebook property.
Usage:
from flexlibs2 import FLExProject project = FLExProject() project.OpenProject("my project", writeEnabled=True) # Create a new notebook record record = project.DataNotebook.Create( "Interview with Speaker A", "Detailed notes from interview about kinship terminology" ) # Set record type record_types = project.DataNotebook.GetAllRecordTypes() if record_types: project.DataNotebook.SetRecordType(record, record_types[0]) # Set date of event project.DataNotebook.SetDateOfEvent(record, "2024-01-15") # Add researchers researcher = project.Person.Find("John Doe") if researcher: project.DataNotebook.AddResearcher(record, researcher) # Link to text text = project.Texts.Find("Interview 1") if text: project.DataNotebook.LinkToText(record, text) # Add media file media = project.Media.Find("interview_audio.wav") if media: project.DataNotebook.AddMediaFile(record, media) # Set status project.DataNotebook.SetStatus(record, "Reviewed") # Create hierarchical structure subrecord = project.DataNotebook.CreateSubRecord( record, "Analysis Notes", "Follow-up analysis of terminology patterns" ) # Query records recent = project.DataNotebook.FindByDate("2024-01-01", "2024-12-31") for rec in recent: title = project.DataNotebook.GetTitle(rec) date = project.DataNotebook.GetDateOfEvent(rec) print(f"{title} - {date}") project.CloseProject()
- 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.
- GetTitle(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetTitle(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetContent(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetContent(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetRecordType(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetRecordType(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAllRecordTypes(*args, **kwargs)¶
Automatically instantiate and call the method.
- FindRecordTypeByName(*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.
- GetDateOfEvent(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetDateOfEvent(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetSubRecords(*args, **kwargs)¶
Automatically instantiate and call the method.
- CreateSubRecord(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetParentRecord(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetResearchers(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddResearcher(*args, **kwargs)¶
Automatically instantiate and call the method.
- RemoveResearcher(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetParticipants(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddParticipant(*args, **kwargs)¶
Automatically instantiate and call the method.
- RemoveParticipant(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetLocations(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddLocation(*args, **kwargs)¶
Automatically instantiate and call the method.
- RemoveLocation(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetSources(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddSource(*args, **kwargs)¶
Automatically instantiate and call the method.
- RemoveSource(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetTexts(*args, **kwargs)¶
Automatically instantiate and call the method.
- LinkToText(*args, **kwargs)¶
Automatically instantiate and call the method.
- UnlinkFromText(*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.
- RemoveMediaFile(*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.
- GetAllStatuses(*args, **kwargs)¶
Automatically instantiate and call the method.
- FindStatusByName(*args, **kwargs)¶
Automatically instantiate and call the method.
- FindByDate(*args, **kwargs)¶
Automatically instantiate and call the method.
- FindByResearcher(*args, **kwargs)¶
Automatically instantiate and call the method.
- FindByType(*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.
- GetGuid(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetConfidence(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetConfidence(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.Notebook.LocationOperations module¶
- class flexicon.code.Notebook.LocationOperations.LocationOperations(project)[source]¶
Bases:
BaseOperationsThis class provides operations for managing geographic locations in a FieldWorks project.
Locations in FLEx represent geographic places where linguistic data was collected, where speakers live, or where languages are spoken. Locations support hierarchical organization (regions, subregions, cities), geographic coordinates, elevation data, and descriptive information.
This class should be accessed via FLExProject.Location property.
Usage:
from flexlibs2 import FLExProject project = FLExProject() project.OpenProject("my project", writeEnabled=True) # Get all locations for location in project.Location.GetAll(): name = project.Location.GetName(location) coords = project.Location.GetCoordinates(location) print(f"{name}: {coords}") # Create a new location village = project.Location.Create("Barasana Village", "en") project.Location.SetCoordinates(village, -1.2345, -70.6789) project.Location.SetElevation(village, 150) # Create hierarchical locations region = project.Location.Create("Vaupés Region", "en") subregion = project.Location.CreateSublocation( region, "Papurí River Area", "en") # Find locations by coordinates nearby = project.Location.FindByCoordinates(-1.23, -70.67, radius_km=50) print(f"Found {len(nearby)} locations within 50 km") project.CloseProject()
- GetAll(**kwargs)¶
- Create(*args, **kwargs)¶
Automatically instantiate and call the method.
- Delete(*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.
- GetName(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetName(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAlias(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetAlias(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetCoordinates(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetCoordinates(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetElevation(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetElevation(*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.
- GetRegion(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetRegion(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetSublocations(*args, **kwargs)¶
Automatically instantiate and call the method.
- CreateSublocation(*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.
- GetGuid(*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.
- FindByCoordinates(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetNearby(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.Notebook.NoteOperations module¶
- class flexicon.code.Notebook.NoteOperations.NoteOperations(project)[source]¶
Bases:
BaseOperationsThis class provides operations for managing notes and comments in a FieldWorks project.
Notes in FLEx are annotations that can be attached to various objects including lexical entries, senses, texts, paragraphs, and more. Notes support threading (replies), categorization, metadata tracking, and multi-lingual content.
This class should be accessed via FLExProject.Note property.
Usage:
from flexlibs2 import FLExProject project = FLExProject() project.OpenProject("my project", writeEnabled=True) # Get a lexical entry entry = project.LexEntry.Find("run") # Get all notes for the entry for note in project.Note.GetAll(entry): content = project.Note.GetContent(note) date = project.Note.GetDateCreated(note) print(f"Note: {content} (created {date})") # Create a new note note = project.Note.Create(entry, "Review etymology", "en") # Set note type project.Note.SetNoteType(note, "To Do") # Add a reply reply = project.Note.AddReply(note, "Checked - looks correct", "en") 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.
- GetContent(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetContent(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetNoteType(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetNoteType(*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.
- GetAuthor(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetAuthor(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetReplies(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddReply(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetOwner(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetGuid(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.Notebook.PersonOperations module¶
- class flexicon.code.Notebook.PersonOperations.PersonOperations(project)[source]¶
Bases:
BaseOperationsThis class provides operations for managing people (consultants, speakers, researchers) in a FieldWorks project.
People are stored as ICmPerson objects and can represent consultants, native speakers, researchers, or any other individuals associated with the linguistic data collection and analysis.
This class should be accessed via FLExProject.Person property.
Usage:
from flexlibs2 import FLExProject project = FLExProject() project.OpenProject("my project", writeEnabled=True) # Get all people for person in project.Person.GetAll(): name = project.Person.GetName(person) print(name) # Create a new person person = project.Person.Create("John Smith") # Set properties project.Person.SetEmail(person, "john.smith@example.com") project.Person.SetDateOfBirth(person, "1985-03-15") project.Person.SetGender(person, "Male") # Add contact information project.Person.SetPhone(person, "+1-555-123-4567") project.Person.SetAddress(person, "123 Main St, City, Country") # Add notes project.Person.AddNote(person, "Primary consultant for dialect study") project.CloseProject()
- 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.
- GetName(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetName(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetGender(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetGender(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetDateOfBirth(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetDateOfBirth(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetEmail(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetEmail(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetPhone(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetPhone(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetAddress(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetAddress(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetEducation(*args, **kwargs)¶
Automatically instantiate and call the method.
- SetEducation(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetPositions(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddPosition(*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.
- GetGuid(*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.
- GetResidences(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddResidence(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetLanguages(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddLanguage(*args, **kwargs)¶
Automatically instantiate and call the method.
- GetNotes(*args, **kwargs)¶
Automatically instantiate and call the method.
- AddNote(*args, **kwargs)¶
Automatically instantiate and call the method.
flexicon.code.Notebook.annotation module¶
Wrapper class for annotation objects with definition-based polymorphism.
This module provides Annotation, a wrapper class that transparently handles ICmBaseAnnotation objects. Unlike class-based polymorphism (where different concrete C# classes represent different types), annotations use definition-based polymorphism: the type is determined by the AnnotationDefn property, not the ClassName.
- Problem:
Annotations in FLEx are polymorphic but not via class inheritance. Instead: - All annotations are ICmBaseAnnotation (single base class) - Type is determined by AnnotationDefn property (like a category/tag) - Projects can define custom annotation types (ScrScriptureNote, ConsultantNote, etc.) - Users must check AnnotationDefn and filter by definition name manually
- Solution:
Annotation wrapper provides: - annotation_type property (name of the annotation definition) - Convenience checks (is_scripture, is_translator, is_consultant, etc.) - Metadata properties (author, content, date_created, date_modified) - Smart type detection without exposing AnnotationDefn complexity - Unified interface for working with any annotation type
Example:
from flexlibs2.code.Notebook.annotation import Annotation
# Wrap an annotation from GetAll()
anno = noteOps.GetAll(entry)[0] # Typed as ICmBaseAnnotation
wrapped = Annotation(anno)
# Access annotation type
print(f"Type: {wrapped.annotation_type}")
# Access metadata
print(f"Author: {wrapped.author}")
print(f"Content: {wrapped.content}")
print(f"Created: {wrapped.date_created}")
# Type checking (works for any project-defined type)
if wrapped.annotation_type == "To Do":
print("This is a to-do annotation")
# Convenience checks for common types
if wrapped.is_scripture:
print("This is a Scripture annotation")
- class flexicon.code.Notebook.annotation.Annotation(lcm_annotation)[source]¶
Bases:
LCMObjectWrapperWrapper for annotation objects providing unified interface access.
Handles ICmBaseAnnotation objects with definition-based type detection. The type is determined by the AnnotationDefn property (like a tag/category), not by the C# class name.
- Variables:
_obj – The base interface object (ICmBaseAnnotation)
_concrete – The concrete type object (always ICmBaseAnnotation in this case, but inherited from LCMObjectWrapper for consistency)
Example:
anno = noteOps.GetAll(entry)[0] wrapped = Annotation(anno) print(wrapped.annotation_type) print(wrapped.author) if wrapped.is_scripture: print("Scripture annotation")
- property annotation_type: str¶
Get the annotation type as a string.
Returns the name of the AnnotationDefn. This is the primary way to identify the type of annotation, as types are defined by the definition, not by the C# class.
- Returns:
- The annotation type name (e.g., “To Do”, “Question”, “Resolved”,
”ScrScriptureNote”, “ConsultantNote”), or empty string if no type set.
- Return type:
str
Example:
print(f"Type: {wrapped.annotation_type}") # Type: To Do if wrapped.annotation_type == "Question": print("This is a question annotation")
Notes
Type is determined by AnnotationDefn.Name, not ClassName
Custom types can be added by projects
Empty if no AnnotationDefn is set
Use for type-based filtering and categorization
- property annotation_defn¶
Get the annotation definition (type definition) object.
Returns the AnnotationDefn object that defines the type of this annotation. For advanced users who need to work with the definition directly.
- Returns:
- The annotation definition object, or None
if no type is set.
- Return type:
ICmAnnotationDefn or None
Example:
if wrapped.annotation_defn: defn_name = wrapped.annotation_type can_create = wrapped.annotation_defn.UserCanCreate
Notes
For most use cases, use annotation_type property instead
AnnotationDefn contains metadata about the type
Returns None if no AnnotationTypeRA is set
- property is_scripture¶
Check if this is a Scripture annotation.
Returns True if the annotation type name contains ‘Scripture’ or ‘Scr’. This is a convenience check for common Scripture annotation types.
- Returns:
True if this appears to be a Scripture annotation.
- Return type:
bool
Example:
if wrapped.is_scripture: print("Scripture annotation")
Notes
Case-insensitive check of annotation type name
Returns True for types like “ScrScriptureNote”, “Scripture Comment”, etc.
Use for quick type filtering
- property is_translator¶
Check if this is a translator note.
Returns True if the annotation type name contains ‘Translator’ or ‘Translator Note’. This is a convenience check for translator annotations.
- Returns:
True if this appears to be a translator annotation.
- Return type:
bool
Example:
if wrapped.is_translator: print("Translator note")
Notes
Case-insensitive check of annotation type name
Returns True for types like “TranslatorNote”, “Translator Comment”, etc.
- property is_consultant¶
Check if this is a consultant note.
Returns True if the annotation type name contains ‘Consultant’ or ‘Consultant Note’. This is a convenience check for consultant annotations.
- Returns:
True if this appears to be a consultant annotation.
- Return type:
bool
Example:
if wrapped.is_consultant: print("Consultant note")
Notes
Case-insensitive check of annotation type name
Returns True for types like “ConsultantNote”, “Consultant Comment”, etc.
- property is_todo¶
Check if this is a “To Do” annotation.
Returns True if the annotation type is “To Do” (case-insensitive).
- Returns:
True if this is a to-do annotation.
- Return type:
bool
Example:
if wrapped.is_todo: print("This needs to be done")
Notes
Case-insensitive check
Exact match (modulo case) of “To Do”
- property is_question¶
Check if this is a question annotation.
Returns True if the annotation type name contains ‘Question’ or ‘Query’.
- Returns:
True if this appears to be a question annotation.
- Return type:
bool
Example:
if wrapped.is_question: print("This needs clarification")
Notes
Case-insensitive check
Returns True for types like “Question”, “Query”, etc.
- property content: str¶
Get the text content of the annotation.
Returns the Comment property text from the annotation.
- Returns:
The annotation content, or empty string if not set.
- Return type:
str
Example:
print(f"Content: {wrapped.content}") # Content: Check etymology source
Notes
Content is stored in Comment property
Returns in default analysis writing system
Empty string if no content set
- property author: str¶
Get the author of the annotation.
Returns the Source property text, which typically contains the author name.
- Returns:
The author name, or empty string if not set.
- Return type:
str
Example:
print(f"Author: {wrapped.author}") # Author: John Smith
Notes
Author is stored in Source property
Returns in default analysis writing system
Empty string if no author set
- property date_created¶
Get the creation date of the annotation.
- Returns:
The creation date/time, or None if not set.
- Return type:
System.DateTime or None
Example:
if wrapped.date_created: print(f"Created: {wrapped.date_created}") # Created: 11/23/2025 10:30:45 AM
Notes
DateCreated is set automatically when annotation is created
Returns System.DateTime object
May be None for annotations without creation date
- property date_modified¶
Get the last modification date of the annotation.
- Returns:
The modification date/time, or None if not set.
- Return type:
System.DateTime or None
Example:
if wrapped.date_modified: print(f"Modified: {wrapped.date_modified}") # Modified: 11/23/2025 2:15:30 PM
Notes
DateModified is updated when annotation is edited
Returns System.DateTime object
May be None for annotations never modified
- property owner¶
Get the owner object that this annotation is attached to.
Returns the object that owns this annotation (ILexEntry, ILexSense, etc.).
- Returns:
The owner object, or None if not set.
- Return type:
object or None
Example:
if wrapped.owner: print(f"Owner type: {wrapped.owner.ClassName}")
Notes
For top-level annotations, returns the annotated object
For reply annotations, returns the parent annotation
Use BeginObjectRA for the original annotated object
- property guid¶
Get the GUID of the annotation.
- Returns:
The GUID of the annotation.
- Return type:
System.Guid
Example:
guid = wrapped.guid print(f"GUID: {guid}") # GUID: 12345678-1234-1234-1234-123456789abc
Notes
GUIDs are globally unique identifiers
Persistent across project versions
Use for external references and tracking
- property replies¶
Get all reply annotations (threaded discussion) for this annotation.
- Returns:
List of ICmBaseAnnotation reply objects, or empty list if none.
- Return type:
list
Example:
if wrapped.replies: for reply in wrapped.replies: reply_wrapper = Annotation(reply) print(f"Reply: {reply_wrapper.content}")
Notes
Replies are child annotations of this annotation
Returns empty list if no replies
Replies can themselves have replies (nested threading)
- property has_replies¶
Check if this annotation has any replies.
- Returns:
True if this annotation has replies.
- Return type:
bool
Example:
if wrapped.has_replies: print(f"Has {len(wrapped.replies)} replies")
Notes
Convenience check for checking if RepliesOS is non-empty
Returns False if no RepliesOS property or no replies
flexicon.code.Notebook.annotation_collection module¶
Smart collection class for annotations.
This module provides AnnotationCollection, a smart collection that manages annotations while showing type diversity and supporting unified operations across different annotation types.
- Problem:
GetAll() returns annotations with different types (defined by AnnotationDefn). Users need to: - See which types are represented - Filter by type if they want to - Work with all types together without manual type checking - Filter by metadata (author, date range, content)
- Solution:
AnnotationCollection provides: - __str__() showing type breakdown by AnnotationDefn - by_type() filtering to specific annotation types - filter() for common criteria (annotation_type, author, date_created) - Convenience methods (scripture_annotations(), translator_notes(), etc.) - Chainable filtering: annos.scripture().filter(author=’John’)
Example:
from flexlibs2.code.Notebook.annotation_collection import AnnotationCollection
# GetAll() returns AnnotationCollection
annos = noteOps.GetAll(entry)
print(annos) # Shows type breakdown
# AnnotationCollection (12 total)
# To Do: 5 (42%)
# Question: 4 (33%)
# ScrScriptureNote: 3 (25%)
# Filter by type
todos = annos.by_type("To Do")
print(len(todos)) # 5
# Filter by author
john_notes = annos.filter(author="John")
# Filter by date
from System import DateTime
one_week_ago = DateTime.Now.AddDays(-7)
recent = annos.filter(since=one_week_ago)
# Chain filters
john_todos = annos.by_type("To Do").filter(author="John")
# Use convenience methods
scripture = annos.scripture()
translator = annos.translator()
# Iterate
for anno in annos:
print(f"{anno.annotation_type}: {anno.content}")
- class flexicon.code.Notebook.annotation_collection.AnnotationCollection(items=None)[source]¶
Bases:
SmartCollectionSmart collection for annotations with type-aware filtering.
Manages collections of annotation (Annotation wrapper objects) with type-aware display and filtering capabilities. Supports filtering by annotation type, author, date, and custom predicates.
- Variables:
_items – List of Annotation wrapper objects
Example:
annos = noteOps.GetAll(entry) # Returns AnnotationCollection print(annos) # Shows type breakdown todos = annos.by_type("To Do") # Filter to To Do john = annos.filter(author="John") # Filter by author both = annos.by_type("To Do").filter(author="John") # Chain
- filter(annotation_type=None, author=None, since=None, until=None, content_contains=None, where=None)[source]¶
Filter the collection by annotation properties.
Supports filtering by properties that work across all annotation types (annotation_type, author, date range, content). For complex filtering, use where().
- Parameters:
annotation_type (str, optional) – Filter to annotations with this type. Case-sensitive match of AnnotationDefn.Name.
author (str, optional) – Filter to annotations by this author. Case-sensitive match of Source property.
since (System.DateTime, optional) – Filter to annotations created on or after this date.
until (System.DateTime, optional) – Filter to annotations created on or before this date.
content_contains (str, optional) – Filter to annotations whose content contains this string (case-sensitive).
where (callable, optional) – Custom predicate function. If provided, other criteria are ignored. Receives Annotation wrapper object.
- Returns:
New collection with filtered items.
- Return type:
Example:
# Filter by annotation type todos = annos.filter(annotation_type="To Do") # Filter by author john_notes = annos.filter(author="John") # Filter by date range from System import DateTime start = DateTime(2025, 1, 1) end = DateTime(2025, 12, 31) year_notes = annos.filter(since=start, until=end) # Filter by content etymology = annos.filter(content_contains="etymology") # Custom filtering recent_todos = annos.where( lambda a: a.annotation_type == "To Do" and a.date_created and a.date_created > DateTime.Now.AddDays(-7) ) # Chain filters john_todos = annos.filter(author="John").filter(annotation_type="To Do")
Notes
All criteria are AND-ed together if multiple provided
String comparisons are case-sensitive
where() takes precedence over other criteria
Returns new collection (doesn’t modify original)
Use where() for complex custom filtering
- by_type(annotation_type)[source]¶
Filter the collection to a specific annotation type.
Returns a new collection containing only annotations of the specified type.
- Parameters:
annotation_type (str) – The annotation type name to filter by. Case-sensitive match of AnnotationDefn.Name.
- Returns:
New collection with filtered items.
- Return type:
Example:
todos = annos.by_type("To Do") print(len(todos)) # Number of To Do annotations questions = annos.by_type("Question")
Notes
Type comparison is case-sensitive
Returns empty collection if no matching types
Equivalent to filter(annotation_type=type_name)
- by_author(author)[source]¶
Filter the collection to annotations by a specific author.
Returns a new collection containing only annotations with the specified author.
- Parameters:
author (str) – The author name to filter by. Case-sensitive match of Source property.
- Returns:
New collection with filtered items.
- Return type:
Example:
john_notes = annos.by_author("John") print(len(john_notes)) # Number of annotations by John
Notes
Author comparison is case-sensitive
Returns empty collection if no matching authors
Equivalent to filter(author=author_name)
- created_since(date)[source]¶
Filter the collection to annotations created on or after a date.
- Parameters:
date (System.DateTime) – The cutoff date (inclusive).
- Returns:
New collection with filtered items.
- Return type:
Example:
from System import DateTime one_week_ago = DateTime.Now.AddDays(-7) recent = annos.created_since(one_week_ago)
Notes
Date comparison is inclusive (>= date)
Returns annotations without DateCreated in results
- created_until(date)[source]¶
Filter the collection to annotations created on or before a date.
- Parameters:
date (System.DateTime) – The cutoff date (inclusive).
- Returns:
New collection with filtered items.
- Return type:
Example:
from System import DateTime end_of_year = DateTime(2025, 12, 31) old_notes = annos.created_until(end_of_year)
Notes
Date comparison is inclusive (<= date)
- scripture()[source]¶
Filter to Scripture annotations.
Returns a new collection containing only Scripture-type annotations (types containing ‘Scripture’ or ‘Scr’).
- Returns:
New collection with Scripture annotations.
- Return type:
Example:
scripture_notes = annos.scripture() print(len(scripture_notes)) # Number of Scripture notes
Notes
Uses the Annotation.is_scripture property
Case-insensitive type matching
- translator()[source]¶
Filter to translator notes.
Returns a new collection containing only translator-type annotations (types containing ‘Translator’).
- Returns:
New collection with translator notes.
- Return type:
Example:
translator_notes = annos.translator() print(len(translator_notes)) # Number of translator notes
Notes
Uses the Annotation.is_translator property
Case-insensitive type matching
- consultant()[source]¶
Filter to consultant notes.
Returns a new collection containing only consultant-type annotations (types containing ‘Consultant’).
- Returns:
New collection with consultant notes.
- Return type:
Example:
consultant_notes = annos.consultant() print(len(consultant_notes)) # Number of consultant notes
Notes
Uses the Annotation.is_consultant property
Case-insensitive type matching
- todos()[source]¶
Filter to “To Do” annotations.
Returns a new collection containing only “To Do” type annotations.
- Returns:
New collection with To Do annotations.
- Return type:
Example:
todos = annos.todos() print(len(todos)) # Number of To Do items
Notes
Uses the Annotation.is_todo property
Case-insensitive type matching
- questions()[source]¶
Filter to question annotations.
Returns a new collection containing only question-type annotations (types containing ‘Question’ or ‘Query’).
- Returns:
New collection with question annotations.
- Return type:
Example:
questions = annos.questions() print(len(questions)) # Number of questions
Notes
Uses the Annotation.is_question property
Case-insensitive type matching
- with_replies()[source]¶
Filter to annotations that have replies.
Returns a new collection containing only annotations with at least one reply.
- Returns:
New collection with annotations that have replies.
- Return type:
Example:
threaded = annos.with_replies() print(len(threaded)) # Number of annotations with discussion threads
Notes
Uses the Annotation.has_replies property
- get_types()[source]¶
Get all unique annotation types in the collection.
- Returns:
List of unique annotation type names (strings).
- Return type:
list
Example:
types = annos.get_types() for type_name in types: print(f"Type: {type_name}") # Type: To Do # Type: Question # Type: ScrScriptureNote
Notes
Returns unique type names only
Order is based on first appearance in collection
- get_authors()[source]¶
Get all unique authors in the collection.
- Returns:
List of unique author names (strings).
- Return type:
list
Example:
authors = annos.get_authors() for author in authors: print(f"Author: {author}")
Notes
Returns unique author names only
Includes empty strings if any annotations have no author set
Order is based on first appearance in collection