EntryModel.swift
EntryModel Documentation
Overview
EntryModel.swift
defines the Entry
struct, which represents a single text entry in the application with its associated metadata and vector embeddings. This model is used for storing and processing text content throughout the application.
Structure Definition
Properties
id
UUID
Unique identifier for the entry. Automatically generated if not provided.
content
String
The actual text content of the entry.
timestamp
Date
When the entry was created. Defaults to current time if not specified.
embeddings
[Float]
Vector representation of the text content, used for similarity matching.
Protocol Conformance
Codable
Enables JSON encoding and decoding
Used for persistence and API communication
No custom encoding/decoding required as all properties are standard types
Identifiable
Provides unique identification for SwiftUI integration
Uses the
id
property as the unique identifierEnables direct use in SwiftUI Lists and ForEach
Hashable
Custom implementation focusing on
id
propertyEnables use in Sets and as Dictionary keys
Implementation:
Initialization
Parameters
id
: Optional. Defaults to new UUID if not providedcontent
: Required. The text content of the entrytimestamp
: Optional. Defaults to current date/timeembeddings
: Optional. Defaults to empty array
Usage Examples
Creating a Basic Entry
Creating an Entry with Custom Values
Using in Collections
Best Practices
Always initialize with the
content
parameter at minimumUse the default initialization for
id
unless you need a specific UUIDOnly provide embeddings when they've been generated through the NLP pipeline
Consider the timestamp carefully - use the default (current time) for new entries, but preserve original timestamps when loading existing data
Related Components
ClusterModel.swift
: Uses Entry objects in collectionsStorage Provider: Handles persistence of Entry objects
NLP Processing: Generates embeddings for Entry content
Last updated