← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


commit d4cc69a6714c40a3ed85a60add38588090cbe57f
parent 83804f84496b4f3585f567c4fb39b093adac1ee3
Author: Michael Camilleri <[email protected]>
Date:   Tue, 20 Oct 2026 23:10:00 +0900

Add a Vocabulary screen for naming tokens in narratives

This commit adds a narrative form to tokens and a Vocabulary screen in
Settings for editing it. Changing the value of a token updates all
reports.  Prior to this commit, the timeline only reloaded after a
survey; renames and question edits made in Settings now post
summaryLookupChanged, which causes the timeline to reload.

The form is an optional Core Data attribute that lightweight migration
adds, and it's included in the JSON export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Diffstat

MNotes/Design.md | 24+++++++++++++-----------
MReportage.xcodeproj/project.pbxproj | 4++++
MReportage/Services/Export/ReportageExport.swift | 3+++
MReportage/Services/Narrative/NarrativeBuilder.swift | 38++++++++++++++++++++++++++++++--------
MReportage/Views/Home/HomeView.swift | 6++++++
MReportage/Views/Home/ReportSummary.swift | 18+++++++++++++-----
MReportage/Views/Settings/QuestionEditor.swift | 4+---
MReportage/Views/Settings/QuestionsView.swift | 1+
MReportage/Views/Settings/SettingsView.swift | 2++
AReportage/Views/Settings/VocabularyView.swift | 333+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MShared/Models/Token.swift | 14++++++++++++++
MShared/Persistence/EntityMapping.swift | 2++
MShared/Persistence/ReportStore.swift | 26++++++++++++++++++++++++++
MShared/Persistence/ReportageModel.xcdatamodeld/ReportageModel.xcdatamodel/contents | 1+
MTests/Unit/ReportStoreTests.swift | 33+++++++++++++++++++++++++++++++++
MTests/Unit/ReportSummaryTests.swift | 32++++++++++++++++++++++++++++----

16 files changed, 510 insertions(+), 31 deletions(-)

diff --git a/Notes/Design.md b/Notes/Design.md

@@ -274,7 +274,7 @@ past narrative.
 | `place`       | For location tokens: a representative coordinate, names from the directory by language, and an optional external ID. |
 | `mergedInto`  | Set when the token has been merged into another. Answers referring to it read as referring to that token, so a merge rewrites no reports and can be undone. |
 | `archivedAt`  | Tokens are archived, never deleted.                          |
-| `inlineText`  | Planned. How the token reads mid-sentence when the automatic form is wrong: 'the park' for a place, or an activity's casing. |
+| `narrativeForm` | Optional. How the token reads in a narrative, used as written in place of the rules: an English form of a name written in kanji ('Hanako' for 山田花子), 'my desk' for a place, or an activity's casing. Answers shown outside the narrative keep `text`. |
 | `modifiedAt`  | Used for last-writer-wins on sync.                           |
 
 **Places** keep their names and coordinate, not just an external ID, so the
@@ -454,8 +454,11 @@ Later activities in a list are lowercased only when the first word is
 capitalised just at its start, its lowercase form is an ordinary English word
 (`UITextChecker`) and the language tagger doesn't mark it as a name. So
 'Drinking coffee' becomes 'drinking coffee', while 'Watching Netflix',
-'Studying Japanese' and 'TV' keep their capitals. People are shown as written,
-and places as below.
+'Studying Japanese' and 'TV' keep their capitals. People are shown by the part
+of their name before the first space ('Sam' for 'Sam Lee'), except names in
+Chinese, Japanese or Korean script, which put the family name first and are
+shown whole. Places read as below. A token's `narrativeForm`, when set, wins
+over all of these.
 
 Narratives are English only for now.
 
@@ -480,8 +483,8 @@ A place reads after 'at', decided in this order:
    Library', 'IKEA', 'Mum's', 'Kichijōji'.
 
 The rules guess wrong now and then (a restaurant typed as 'Bank' becomes 'the
-bank'), so each place is planned to have a form the user can set, which wins
-over the rules. See [Open Questions](#open-questions).
+bank'), so a place's `narrativeForm` wins over them. It replaces what follows
+'at', not the preposition.
 
 ### Why not the on-device model
 
@@ -951,7 +954,7 @@ the app as a fresh install has it. Prompt settings are kept.
 6. **Visualisations.**
 7. **Synced schema.** Settle the [open questions](#open-questions) that change
    synced data before the record formats are fixed: missed prompts, keeping
-   past prompt settings, place forms, adding, removing and rewording
+   past prompt settings, adding, removing and rewording
    questions, multi-select answers, and whether the Reporter import stays.
 8. **Sync.** `CKSyncEngine`, both zones, first upload. Sync comes last
    because CloudKit's Production schema can only be added to, so it should
@@ -988,10 +991,9 @@ the app as a fresh install has it. Prompt settings are kept.
   needs (phrases for yes and no, a template for a choice, the nouns for a
   count, a lead-in for a note), and a blank rule shows the answer as prompt
   and answer.
-- **Place forms.** A field on a place token for how it reads after 'at' ('the
-  office', 'my desk'), filled from the [place rules](#places) and winning over
-  them. It changes the token record, so it lands with the sync schema.
 - **Narratives in other languages.** Narratives are English only.
-- **Vocabulary editing UI.** Renaming and merging are settled in the model
-  (see [Token](#token)); how they're presented in the app isn't.
+- **Merging in the Vocabulary screen.** Settings → Vocabulary lists the
+  activities, people and places in use, most used first, where each can be
+  renamed and given a narrative form. Merging is settled in the model (see
+  [Token](#token)); how it's presented there isn't.
 - **App lock.** Should there be an optional Face ID lock? The data is personal.

diff --git a/Reportage.xcodeproj/project.pbxproj b/Reportage.xcodeproj/project.pbxproj

@@ -20,6 +20,7 @@
 		226A38BE6D7171D892EA35B3 /* FirstLaunch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE9EDC8448889EB9D4D358E /* FirstLaunch.swift */; };
 		227F8E03F77DE5704797CC28 /* QuestionEditorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48ACB0E76C4E2271EA59B8E9 /* QuestionEditorTests.swift */; };
 		22EA393B887791E20B6FE625 /* PlacePickerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B6C4141A26EED99B1F03FBE /* PlacePickerTests.swift */; };
+		23A8E093AFF85144AEACF321 /* VocabularyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 662E31DC0006681643DD0A8D /* VocabularyView.swift */; };
 		25BC9F95DC40E31B1E4C6FBA /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BE62142CCC4A791F05163A /* Token.swift */; };
 		275A9497C40065F5C77AE473 /* InstantReportLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 729C291798F29C69029E7DB7 /* InstantReportLogger.swift */; };
 		28D2CDAAB0777233D4465A83 /* ReporterArchiveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 487F88C880B5DE69964C6A37 /* ReporterArchiveTests.swift */; };
@@ -169,6 +170,7 @@
 		61C0B5BB02ECDBE84F5F73FA /* PersistenceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistenceController.swift; sourceTree = "<group>"; };
 		633FE6CD8111A433CA9BE7EC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
 		643C730A99F0B7BA8C1F8A8E /* JSONSlicer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONSlicer.swift; sourceTree = "<group>"; };
+		662E31DC0006681643DD0A8D /* VocabularyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VocabularyView.swift; sourceTree = "<group>"; };
 		695CB01E79016592A3823541 /* HealthTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthTests.swift; sourceTree = "<group>"; };
 		6E382405EE9DBEC8EE616C1D /* SurveyModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyModelTests.swift; sourceTree = "<group>"; };
 		7196D553D769071DB876B606 /* ReporterTimeZones.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReporterTimeZones.swift; sourceTree = "<group>"; };
@@ -478,6 +480,7 @@
 				1458729667512D1B7E04D92F /* QuestionEditor.swift */,
 				7F9A0A87A54F3E96E079F52D /* QuestionsView.swift */,
 				81BA515BEA1B0B68CE0D1326 /* SettingsView.swift */,
+				662E31DC0006681643DD0A8D /* VocabularyView.swift */,
 			);
 			path = Settings;
 			sourceTree = "<group>";
@@ -771,6 +774,7 @@
 				25BC9F95DC40E31B1E4C6FBA /* Token.swift in Sources */,
 				D9A8839569734F5CEAC43A44 /* TokenAnswer.swift in Sources */,
 				540CA20A213B0446B6F71885 /* Vocabulary.swift in Sources */,
+				23A8E093AFF85144AEACF321 /* VocabularyView.swift in Sources */,
 				E2D35546E39153308E9880B1 /* WelcomeView.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

diff --git a/Reportage/Services/Export/ReportageExport.swift b/Reportage/Services/Export/ReportageExport.swift

@@ -156,6 +156,7 @@ struct ExportedToken: Codable, Hashable, Sendable {
     var questionID: String
     var text: String
     var place: PlaceDetails?
+    var narrativeForm: String?
     var mergedInto: String?
     var archivedAt: Date?
     var modifiedAt: Date
@@ -165,6 +166,7 @@ struct ExportedToken: Codable, Hashable, Sendable {
         questionID = token.questionID
         text = token.text
         place = token.place
+        narrativeForm = token.narrativeForm
         mergedInto = token.mergedInto
         archivedAt = token.archivedAt
         modifiedAt = token.modifiedAt
@@ -176,6 +178,7 @@ struct ExportedToken: Codable, Hashable, Sendable {
             questionID: questionID,
             text: text,
             place: place,
+            narrativeForm: narrativeForm,
             mergedInto: mergedInto,
             archivedAt: archivedAt,
             modifiedAt: modifiedAt

diff --git a/Reportage/Services/Narrative/NarrativeBuilder.swift b/Reportage/Services/Narrative/NarrativeBuilder.swift

@@ -35,13 +35,13 @@ enum NarrativeBuilder {
             else { continue }
             switch (lookup.questionRules[response.questionID], value) {
             case (.activities, .tokens(let ids)):
-                activities += ids.compactMap { lookup.tokenTexts[$0] }
+                activities += ids.compactMap { form(of: $0, rule: .activities, lookup: lookup) }
                 clauseIndex = clauseIndex ?? sentences.count
             case (.people, .tokens(let ids)):
-                people += ids.compactMap { lookup.tokenTexts[$0] }
+                people += ids.compactMap { form(of: $0, rule: .people, lookup: lookup) }
                 clauseIndex = clauseIndex ?? sentences.count
             case (.place, .place(let answer)):
-                place = place ?? placePhrase(for: answer.tokenID, lookup: lookup)
+                place = place ?? form(of: answer.tokenID, rule: .place, lookup: lookup)
                 clauseIndex = clauseIndex ?? sentences.count
             case (.phrases(let yes, let no), .options(let options)):
                 let phrases = [ResponseValue.yesOption: yes, ResponseValue.noOption: no]
@@ -96,7 +96,7 @@ enum NarrativeBuilder {
     private static func mainClause(activities: [String], place: String?, people: [String]) -> Sentence? {
         var text = ""
         if !activities.isEmpty {
-            text += joined(activities.map(InlineCasing.inline))
+            text += joined(activities)
         }
         if let place {
             text += (text.isEmpty ? "At " : " at ") + place
@@ -107,10 +107,32 @@ enum NarrativeBuilder {
         return text.isEmpty ? nil : Sentence(text)
     }
 
-    /// How a place reads after 'at'. A directory's name is shown as written.
-    private static func placePhrase(for tokenID: String, lookup: SummaryLookup) -> String? {
-        guard let text = lookup.tokenTexts[tokenID] else { return nil }
-        return lookup.directoryPlaces.contains(tokenID) ? text : PlacePhrase.phrase(for: text)
+    /// How the token with `id` reads in the main clause under `rule`: its
+    /// narrative form if it has one, or else the form the rules give it. A
+    /// place reads after 'at', and a directory's name is shown as written.
+    static func form(of id: String, rule: NarrativeRule, lookup: SummaryLookup) -> String? {
+        if let form = lookup.narrativeForms[id] { return form }
+        guard let text = lookup.tokenTexts[id] else { return nil }
+        switch rule {
+        case .activities: return InlineCasing.inline(text)
+        case .people: return shortName(text)
+        case .place: return lookup.directoryPlaces.contains(id) ? text : PlacePhrase.phrase(for: text)
+        default: return text
+        }
+    }
+
+    /// How a person reads when they have no narrative form: the part of
+    /// their name before the first space, 'Sam' for 'Sam Lee'. Names in
+    /// Chinese, Japanese or Korean script put the family name first, so
+    /// they're shown whole.
+    static func shortName(_ name: String) -> String {
+        let isCJK = name.unicodeScalars.contains { scalar in
+            scalar.properties.isIdeographic
+                || (0x3040...0x30FF).contains(scalar.value)  // Hiragana and Katakana
+                || (0xAC00...0xD7AF).contains(scalar.value)  // Hangul syllables
+        }
+        guard !isCJK, let first = name.split(separator: " ", maxSplits: 1).first else { return name }
+        return String(first)
     }
 
     /// 'a', 'a and b', 'a, b and c'.

diff --git a/Reportage/Views/Home/HomeView.swift b/Reportage/Views/Home/HomeView.swift

@@ -40,6 +40,12 @@ struct HomeView: View {
             try? await UNUserNotificationCenter.current().setBadgeCount(0)
         }
         .onChange(of: inbox?.survey?.id, initial: true) { openPrompt() }
+        // Questions and vocabulary edited in Settings change how reports read.
+        .task {
+            for await _ in NotificationCenter.default.notifications(named: .summaryLookupChanged) {
+                await describer.load(from: store)
+            }
+        }
     }
 
     private func reload() {

diff --git a/Reportage/Views/Home/ReportSummary.swift b/Reportage/Views/Home/ReportSummary.swift

@@ -7,6 +7,9 @@ struct SummaryLookup: Equatable, Sendable {
     /// Token texts by ID. A merged token's ID maps to the text of the token
     /// it was merged into.
     var tokenTexts: [String: String] = [:]
+    /// Narrative forms of the tokens that have one, by ID, following merges
+    /// as `tokenTexts` does.
+    var narrativeForms: [String: String] = [:]
     /// Place tokens, by ID, whose text is still the name a place directory
     /// gave them. A merged token's ID is here if its token's is.
     var directoryPlaces: Set<String> = []
@@ -19,6 +22,12 @@ struct SummaryLookup: Equatable, Sendable {
     var hiddenQuestions: Set<String> = []
 }
 
+extension Notification.Name {
+    /// Posted after a change to how reports read, such as a question's rule
+    /// or a token's name, so the timeline reloads its `SummaryLookup`.
+    static let summaryLookupChanged = Notification.Name("net.inqk.reportage.summaryLookupChanged")
+}
+
 /// A report described for the home screen: its narrative, built from the
 /// answers that have narrative rules, the other answers as question and
 /// answer, and a line of context.
@@ -100,11 +109,10 @@ extension ReportStore {
                     current = next
                 }
                 lookup.tokenTexts[token.id] = current.text
-                // Imported Foursquare venues and some MapKit places have no
-                // directory names, so their text is the directory's.
-                if let place = current.place, place.externalID != nil,
-                    place.names.isEmpty || place.names.contains(where: { $0.text == current.text })
-                {
+                if let form = current.narrativeForm, !form.trimmingCharacters(in: .whitespaces).isEmpty {
+                    lookup.narrativeForms[token.id] = form
+                }
+                if current.isNamedByDirectory {
                     lookup.directoryPlaces.insert(token.id)
                 }
             }

diff --git a/Reportage/Views/Settings/QuestionEditor.swift b/Reportage/Views/Settings/QuestionEditor.swift

@@ -291,9 +291,7 @@ struct QuestionForm<Footer: View>: View {
 extension View {
     /// Draws a text field on a wash of ink so it reads as somewhere to type,
     /// and focuses it from anywhere in the wash, not just its text.
-    fileprivate func filledField(
-        focus: FocusState<QuestionFormField?>.Binding, as field: QuestionFormField
-    ) -> some View {
+    func filledField<Field: Hashable>(focus: FocusState<Field?>.Binding, as field: Field) -> some View {
         padding(.horizontal, 12)
             .padding(.vertical, 9)
             .background(Theme.field, in: .rect(cornerRadius: 10))

diff --git a/Reportage/Views/Settings/QuestionsView.swift b/Reportage/Views/Settings/QuestionsView.swift

@@ -165,6 +165,7 @@ final class QuestionList {
             await previous?.value
             do {
                 try await save(store)
+                await MainActor.run { NotificationCenter.default.post(name: .summaryLookupChanged, object: nil) }
             } catch {
                 logger.error("Couldn't save questions: \(error)")
             }

diff --git a/Reportage/Views/Settings/SettingsView.swift b/Reportage/Views/Settings/SettingsView.swift

@@ -15,6 +15,8 @@ struct SettingsView: View {
                 Section {
                     NavigationLink("Questions") { QuestionsView() }
                         .settingsRow()
+                    NavigationLink("Vocabulary") { VocabularyView() }
+                        .settingsRow()
                     NavigationLink {
                         NotificationsView()
                     } label: {

diff --git a/Reportage/Views/Settings/VocabularyView.swift b/Reportage/Views/Settings/VocabularyView.swift

@@ -0,0 +1,333 @@
+import OSLog
+import SwiftUI
+
+extension QuestionKind {
+    /// The kinds whose answers are tokens, in the order the Vocabulary
+    /// screen lists them.
+    static let vocabulary: [QuestionKind] = [.tokens, .people, .location]
+
+    /// Tokens of this kind, as the Vocabulary screen names them.
+    var vocabularyTitle: LocalizedStringKey {
+        switch self {
+        case .people: "People"
+        case .location: "Places"
+        default: "Activities"
+        }
+    }
+}
+
+/// Every activity, person and place that answers use, for renaming and for
+/// setting how each reads in narratives. Each change is saved as it's made.
+@MainActor
+@Observable
+final class VocabularyList {
+    struct Item: Identifiable, Equatable {
+        var token: Token
+        /// How often and how recently the token was used, for ordering.
+        var entry: VocabularyEntry
+
+        var id: String { token.id }
+    }
+
+    /// Tokens that are neither archived nor merged, by the kind of question
+    /// they answer, most used first.
+    private(set) var items: [QuestionKind: [Item]] = [:]
+    private(set) var isLoaded = false
+
+    private var store: ReportStore?
+    private var saving: Task<Void, Never>?
+    private let logger = Logger(subsystem: "net.inqk.reportage", category: "Vocabulary")
+
+    func load(from store: ReportStore?) async {
+        guard let store, let questions = try? await store.allQuestions() else { return }
+        let kinds = Dictionary(
+            uniqueKeysWithValues: questions.filter { QuestionKind.vocabulary.contains($0.kind) }.map { ($0.id, $0.kind) })
+        let questionIDs = Array(kinds.keys)
+        guard let entries = try? await store.vocabulary(for: questionIDs),
+            let tokens = try? await store.tokens(for: questionIDs)
+        else { return }
+
+        let byID = Dictionary(uniqueKeysWithValues: tokens.map { ($0.id, $0) })
+        var items: [QuestionKind: [Item]] = [:]
+        for (questionID, entries) in entries {
+            guard let kind = kinds[questionID] else { continue }
+            items[kind, default: []] += entries.compactMap { entry in
+                byID[entry.id].map { Item(token: $0, entry: entry) }
+            }
+        }
+        // Each kind can span several questions, such as one imported from
+        // Reporter and one added since.
+        for kind in items.keys {
+            items[kind]?.sort { Vocabulary.ranksBefore($0.entry, $1.entry) }
+        }
+        self.store = store
+        self.items = items
+        isLoaded = true
+    }
+
+    func item(id: String) -> Item? {
+        items.values.lazy.compactMap { $0.first { $0.id == id } }.first
+    }
+
+    /// Saves an edited token. A new text renames it in every report.
+    func update(_ token: Token) {
+        guard let kind = items.first(where: { $0.value.contains { $0.id == token.id } })?.key,
+            let index = items[kind]?.firstIndex(where: { $0.id == token.id }),
+            items[kind]?[index].token != token
+        else { return }
+        var token = token
+        token.modifiedAt = Date()
+        items[kind]?[index].token = token
+        enqueue { [token] in try await $0.save(token) }
+    }
+
+    /// Runs saves one after another, so a later edit can't be overwritten
+    /// by an earlier one finishing after it.
+    private func enqueue(_ save: @escaping @Sendable (ReportStore) async throws -> Void) {
+        guard let store else { return }
+        let previous = saving
+        saving = Task { [logger] in
+            await previous?.value
+            do {
+                try await save(store)
+                await MainActor.run { NotificationCenter.default.post(name: .summaryLookupChanged, object: nil) }
+            } catch {
+                logger.error("Couldn't save vocabulary: \(error)")
+            }
+        }
+    }
+}
+
+/// The activities, people and places answers have used, each kind on a
+/// screen of its own.
+struct VocabularyView: View {
+    @Environment(\.reportStore) private var store
+    @State private var list = VocabularyList()
+
+    var body: some View {
+        List {
+            SettingsNote {
+                Text(
+                    "Rename the activities, people and places in your answers, and choose how each reads in the timeline."
+                )
+            }
+            Section {
+                ForEach(QuestionKind.vocabulary, id: \.self) { kind in
+                    NavigationLink {
+                        VocabularyKindView(kind: kind, list: list)
+                    } label: {
+                        LabeledContent(kind.vocabularyTitle) {
+                            if list.isLoaded {
+                                Text((list.items[kind]?.count ?? 0).formatted())
+                            }
+                        }
+                    }
+                    .settingsRow()
+                }
+            }
+        }
+        .listStyle(.plain)
+        .scrollContentBackground(.hidden)
+        .background(Theme.paper)
+        .foregroundStyle(Theme.ink)
+        .navigationTitle("Vocabulary")
+        .navigationBarTitleDisplayMode(.inline)
+        .toolbar(.visible, for: .navigationBar)
+        .task { await list.load(from: store) }
+    }
+}
+
+/// The tokens of one kind, most used first, filtered by search.
+private struct VocabularyKindView: View {
+    let kind: QuestionKind
+    let list: VocabularyList
+    @State private var search = ""
+
+    var body: some View {
+        List {
+            ForEach(items) { item in
+                NavigationLink {
+                    TokenDetailView(item: item, kind: kind, list: list)
+                } label: {
+                    VocabularyRow(item: item)
+                }
+                .settingsRow()
+            }
+            if list.isLoaded, items.isEmpty {
+                SettingsNote {
+                    if search.isEmpty {
+                        Text("None of your answers use these yet.")
+                    } else {
+                        Text("Nothing matches.")
+                    }
+                }
+            }
+        }
+        .listStyle(.plain)
+        .scrollContentBackground(.hidden)
+        .background(Theme.paper)
+        .foregroundStyle(Theme.ink)
+        .navigationTitle(Text(kind.vocabularyTitle))
+        .navigationBarTitleDisplayMode(.inline)
+        .searchable(text: $search)
+    }
+
+    private var items: [VocabularyList.Item] {
+        let all = list.items[kind] ?? []
+        let search = search.trimmingCharacters(in: .whitespaces)
+        guard !search.isEmpty else { return all }
+        return all.filter { item in
+            item.token.text.localizedStandardContains(search)
+                || item.token.narrativeForm?.localizedStandardContains(search) ?? false
+        }
+    }
+}
+
+/// A token's name, with its narrative form and, for a place, where it was
+/// last used, and how many reports use it.
+private struct VocabularyRow: View {
+    let item: VocabularyList.Item
+
+    var body: some View {
+        HStack(alignment: .firstTextBaseline) {
+            VStack(alignment: .leading, spacing: Theme.lineGap) {
+                Text(item.token.text)
+                    .font(Theme.serif(.body))
+                if let subtitle {
+                    Text(subtitle)
+                        .font(.footnote)
+                        .foregroundStyle(Theme.muted)
+                }
+            }
+            Spacer()
+            Text(item.entry.useCount.formatted())
+                .font(.footnote)
+                .foregroundStyle(Theme.muted)
+                .accessibilityLabel(Text("Used in ^[\(item.entry.useCount) report](inflect: true)"))
+        }
+    }
+
+    private var subtitle: String? {
+        var parts: [String] = []
+        if let form = item.token.narrativeForm {
+            parts.append(String(localized: "Reads as '\(form)'", comment: "A token's narrative form, in a list"))
+        }
+        if let locality = item.entry.locality {
+            parts.append(locality)
+        }
+        return parts.isEmpty ? nil : parts.joined(separator: " · ")
+    }
+}
+
+/// One token, renamed and given a narrative form in place. Each field is
+/// saved when it's finished.
+private struct TokenDetailView: View {
+    let kind: QuestionKind
+    let list: VocabularyList
+    @State private var text: String
+    @State private var form: String
+    @FocusState private var focus: Field?
+
+    private enum Field: Hashable {
+        case text
+        case form
+    }
+
+    init(item: VocabularyList.Item, kind: QuestionKind, list: VocabularyList) {
+        self.kind = kind
+        self.list = list
+        self.token = item.token
+        _text = State(initialValue: item.token.text)
+        _form = State(initialValue: item.token.narrativeForm ?? "")
+    }
+
+    /// The token as it was opened, for its ID and place.
+    private let token: Token
+
+    var body: some View {
+        List {
+            Section {
+                TextField("Name", text: $text)
+                    .font(Theme.serif(.title3, weight: .medium))
+                    .focused($focus, equals: .text)
+                    .submitLabel(.done)
+                    .filledField(focus: $focus, as: .text)
+                    .settingsRow()
+                    .listRowSeparator(.hidden)
+                SettingsNote { Text("Renaming changes the name in every report that uses it.") }
+            } header: {
+                SettingsHeading("Name")
+            }
+            Section {
+                TextField("In Narratives", text: $form, prompt: Text(verbatim: reading.automatic))
+                    .font(Theme.serif(.body))
+                    .focused($focus, equals: .form)
+                    .submitLabel(.done)
+                    .filledField(focus: $focus, as: .form)
+                    .settingsRow()
+                    .listRowSeparator(.hidden)
+                SettingsNote {
+                    if let sentence = reading.sentence {
+                        Text("Reads as '\(sentence)' \(Text(hint))")
+                    } else {
+                        Text(hint)
+                    }
+                }
+            } header: {
+                SettingsHeading("In Narratives")
+            }
+        }
+        .listStyle(.plain)
+        .scrollContentBackground(.hidden)
+        .scrollDismissesKeyboard(.interactively)
+        .background(Theme.paper)
+        .foregroundStyle(Theme.ink)
+        .navigationBarTitleDisplayMode(.inline)
+        .onChange(of: focus) { commit() }
+        .onDisappear { commit() }
+    }
+
+    private var hint: LocalizedStringKey {
+        switch kind {
+        case .people:
+            "Left blank, a name reads as the part before its first space, unless it's written in Chinese, Japanese or Korean."
+        case .location: "Write how the place reads after 'at', such as 'the park' or 'my desk'."
+        default: "Write how the activity reads in a sentence, such as 'going for a run'."
+        }
+    }
+
+    /// How the token reads with the rules alone, and the sentence it makes
+    /// with the drafted name and form.
+    private var reading: (automatic: String, sentence: String?) {
+        let rule = NarrativeRule.derived(for: kind) ?? .activities
+        var draft = token
+        draft.text = trimmed(text).isEmpty ? token.text : trimmed(text)
+        var lookup = SummaryLookup()
+        lookup.questionRules["Q"] = rule
+        lookup.tokenTexts["T"] = draft.text
+        if draft.isNamedByDirectory { lookup.directoryPlaces.insert("T") }
+        let automatic = NarrativeBuilder.form(of: "T", rule: rule, lookup: lookup) ?? draft.text
+        if !trimmed(form).isEmpty { lookup.narrativeForms["T"] = trimmed(form) }
+        let value: ResponseValue = kind == .location ? .place(PlaceAnswer(tokenID: "T")) : .tokens(["T"])
+        let sentence = NarrativeBuilder.build(
+            responses: [Response(questionID: "Q", prompt: "", value: value)], lookup: lookup
+        ).narrative
+        return (automatic, sentence)
+    }
+
+    private func trimmed(_ string: String) -> String {
+        string.trimmingCharacters(in: .whitespacesAndNewlines)
+    }
+
+    /// Saves the name and form. A name left blank goes back to what it was.
+    private func commit() {
+        guard var current = list.item(id: token.id)?.token else { return }
+        if trimmed(text).isEmpty {
+            text = current.text
+        } else {
+            current.text = trimmed(text)
+        }
+        current.narrativeForm = trimmed(form).isEmpty ? nil : trimmed(form)
+        list.update(current)
+    }
+}

diff --git a/Shared/Models/Token.swift b/Shared/Models/Token.swift

@@ -14,6 +14,10 @@ struct Token: Hashable, Sendable {
     var text: String
     /// Set for tokens of `location` questions.
     var place: PlaceDetails?
+    /// How the token reads in a narrative, when that differs from its text:
+    /// an English form of a name written in kanji, or 'the park' for a place.
+    /// It's used as written, in place of the rules.
+    var narrativeForm: String?
     /// When set, the token was merged into the token with this ID, and
     /// answers referring to it should be read as referring to that token.
     var mergedInto: String?
@@ -21,6 +25,16 @@ struct Token: Hashable, Sendable {
     var modifiedAt: Date
 }
 
+extension Token {
+    /// Whether the token is a place whose text is still a name a place
+    /// directory gave it. Imported Foursquare venues and some MapKit places
+    /// have no directory names, so their text is the directory's.
+    var isNamedByDirectory: Bool {
+        guard let place, place.externalID != nil else { return false }
+        return place.names.isEmpty || place.names.contains { $0.text == text }
+    }
+}
+
 struct PlaceDetails: Codable, Hashable, Sendable {
     /// A representative coordinate for the place: the directory's coordinate,
     /// or the centre of the answers given for it.

diff --git a/Shared/Persistence/EntityMapping.swift b/Shared/Persistence/EntityMapping.swift

@@ -65,6 +65,7 @@ extension TokenEntity {
         questionID = token.questionID
         text = token.text
         place = try token.place.map { try ModelCoding.encode($0) }
+        narrativeForm = token.narrativeForm
         mergedInto = token.mergedInto
         archivedAt = token.archivedAt
         modifiedAt = token.modifiedAt
@@ -80,6 +81,7 @@ extension TokenEntity {
             questionID: questionID,
             text: text,
             place: try place.map { try ModelCoding.decode(PlaceDetails.self, from: $0) },
+            narrativeForm: narrativeForm,
             mergedInto: mergedInto,
             archivedAt: archivedAt,
             modifiedAt: modifiedAt

diff --git a/Shared/Persistence/ReportStore.swift b/Shared/Persistence/ReportStore.swift

@@ -211,6 +211,32 @@ struct ReportStore: Sendable {
         }
     }
 
+    /// The tokens of `questionIDs` that haven't been merged into another,
+    /// archived or not.
+    func tokens(for questionIDs: [String]) async throws -> [Token] {
+        let context = persistence.newBackgroundContext()
+        return try await context.perform {
+            let request = TokenEntity.fetchRequest()
+            request.predicate = NSPredicate(format: "questionID IN %@ AND mergedInto == nil", questionIDs)
+            return try context.fetch(request).map { try $0.token() }
+        }
+    }
+
+    /// Saves an edited token. A new text renames it throughout history,
+    /// since answers refer to it by ID. A token not in the store is left
+    /// out: tokens are added with the reports that first use them.
+    func save(_ token: Token) async throws {
+        let context = persistence.newBackgroundContext()
+        try await context.perform {
+            let request = TokenEntity.fetchRequest()
+            request.predicate = NSPredicate(format: "id == %@", token.id)
+            request.fetchLimit = 1
+            guard let entity = try context.fetch(request).first else { return }
+            try entity.update(from: token)
+            try context.save()
+        }
+    }
+
     /// Ranked suggestions for each of `questionIDs`. See `Vocabulary`.
     func vocabulary(for questionIDs: [String]) async throws -> [String: [VocabularyEntry]] {
         let context = persistence.newBackgroundContext()

diff --git a/Shared/Persistence/ReportageModel.xcdatamodeld/ReportageModel.xcdatamodel/contents b/Shared/Persistence/ReportageModel.xcdatamodeld/ReportageModel.xcdatamodel/contents

@@ -49,6 +49,7 @@
         <attribute name="id" attributeType="String"/>
         <attribute name="mergedInto" optional="YES" attributeType="String"/>
         <attribute name="modifiedAt" attributeType="Date" usesScalarValueType="NO"/>
+        <attribute name="narrativeForm" optional="YES" attributeType="String"/>
         <attribute name="place" optional="YES" attributeType="Binary"/>
         <attribute name="questionID" attributeType="String"/>
         <attribute name="text" attributeType="String"/>

diff --git a/Tests/Unit/ReportStoreTests.swift b/Tests/Unit/ReportStoreTests.swift

@@ -111,6 +111,39 @@ struct ReportStoreTests {
         #expect(entries[0].lastUsed == Date(timeIntervalSince1970: 4 * 3600))
     }
 
+    @Test("The summary lookup has narrative forms, following merges and ignoring blank ones")
+    func narrativeFormLookup() async throws {
+        var yamada = Self.token("Y", "山田花子")
+        yamada.narrativeForm = "Hanako"
+        var blank = Self.token("B", "Sam Lee")
+        blank.narrativeForm = " "
+        let tokens = [yamada, Self.token("M", "山田さん", mergedInto: "Y"), blank]
+        let response = Response(questionID: "Q", prompt: "P", value: .tokens(["Y", "M", "B"]))
+        try await store.insert(Self.report(1, responses: [response]), newTokens: tokens)
+
+        let lookup = try await store.summaryLookup()
+        #expect(lookup.narrativeForms == ["Y": "Hanako", "M": "Hanako"])
+        #expect(lookup.tokenTexts["M"] == "山田花子")
+    }
+
+    @Test("Tokens for the Vocabulary screen leave out merged ones, and edits rename them everywhere")
+    func editTokens() async throws {
+        let tokens = [Self.token("A", "Sam Lee"), Self.token("B", "Sam", mergedInto: "A")]
+        let response = Response(questionID: "Q", prompt: "P", value: .tokens(["A", "B"]))
+        try await store.insert(Self.report(1, responses: [response]), newTokens: tokens)
+        #expect(try await store.tokens(for: ["Q"]).map(\.id) == ["A"])
+
+        var edited = tokens[0]
+        edited.text = "Samantha Lee"
+        edited.narrativeForm = "Sami"
+        try await store.save(edited)
+        try await store.save(Self.token("Z", "Not stored"))
+
+        let lookup = try await store.summaryLookup()
+        #expect(lookup.tokenTexts == ["A": "Samantha Lee", "B": "Samantha Lee"])
+        #expect(lookup.narrativeForms == ["A": "Sami", "B": "Sami"])
+    }
+
     @Test("Place answers count towards their place token")
     func placeVocabulary() async throws {
         let home = Token(

diff --git a/Tests/Unit/ReportSummaryTests.swift b/Tests/Unit/ReportSummaryTests.swift

@@ -11,8 +11,10 @@ struct NarrativeBuilderTests {
         tokenTexts: [
             "read": "Reading", "coffee": "Drinking coffee", "netflix": "Watching Netflix",
             "library": "Library", "home": "Home", "bottle": "Blue bottle", "sam": "Sam", "kai": "Kai",
-            "tanaka": "田中さん",
+            "tanaka": "田中さん", "lee": "Sam Lee", "taro": "田中 太郎", "yamada": "山田花子",
+            "office": "Office", "run": "Running",
         ],
+        narrativeForms: ["yamada": "Hanako", "office": "my desk", "run": "going for a run"],
         directoryPlaces: ["bottle"],
         questionRules: NarrativeRule.builtIn.merging(
             ["activity": .activities, "people": .people, "place": .place], uniquingKeysWith: { $1 })
@@ -37,10 +39,32 @@ struct NarrativeBuilderTests {
         #expect(details.isEmpty)
     }
 
-    @Test("People are shown as written")
+    @Test("People read as their name before the first space, unless written in CJK script")
     func people() {
-        let narrative = Self.build([Self.response("people", .tokens(["sam", "tanaka"]))]).narrative
-        #expect(narrative == "With Sam and 田中さん.")
+        let narrative = Self.build([Self.response("people", .tokens(["sam", "lee", "tanaka", "taro"]))])
+            .narrative
+        #expect(narrative == "With Sam, Sam, 田中さん and 田中 太郎.")
+    }
+
+    @Test("A narrative form wins over the rules for people, places and activities")
+    func narrativeForms() {
+        let (narrative, details) = Self.build([
+            Self.response("activity", .tokens(["read", "run"])),
+            Self.response("place", .place(PlaceAnswer(tokenID: "office"))),
+            Self.response("people", .tokens(["yamada"])),
+        ])
+        #expect(narrative == "Reading and going for a run at my desk, with Hanako.")
+        #expect(details.isEmpty)
+    }
+
+    @Test("Answers outside the narrative keep the token's text")
+    func formsOnlyInNarrative() {
+        var lookup = Self.lookup
+        lookup.questionRules["people"] = nil
+        let details = NarrativeBuilder.build(
+            responses: [Self.response("people", .tokens(["yamada", "lee"]))], lookup: lookup
+        ).details
+        #expect(details.map(\.answer) == ["山田花子 and Sam Lee"])
     }
 
     @Test("A place from a directory is shown as written, and others are phrased")