-
-
Notifications
You must be signed in to change notification settings - Fork 6
Display morph type tokens in UI #2205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4137141
Initial work on morph types in UI
rmunn 62bd174
Citation forms should not be decorated
rmunn fcd260a
Remove TODO we won't actually implement
rmunn d60e888
Add morph types to in-memory-demo-api for testing
rmunn 1f38aa2
Fix one Playwright test
rmunn 6eab38b
Fix tests
myieye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import type {MorphTypeKind, IMorphType} from '$lib/dotnet-types'; | ||
|
|
||
| import {type ProjectContext, useProjectContext} from '$project/project-context.svelte'; | ||
| import {type ResourceReturn} from 'runed'; | ||
|
|
||
| const morphTypesSymbol = Symbol.for('fw-lite-morph-types'); | ||
| export function useMorphTypesService(): MorphTypesService { | ||
| const projectContext = useProjectContext(); | ||
| return projectContext.getOrAdd(morphTypesSymbol, () => { | ||
| return new MorphTypesService(projectContext); | ||
| }); | ||
| } | ||
|
|
||
| export class MorphTypesService { | ||
| constructor(projectContext: ProjectContext) { | ||
| this.#morphTypesResource = projectContext.apiResource([], api => api.getMorphTypes()); | ||
| } | ||
|
|
||
| #morphTypesResource: ResourceReturn<IMorphType[], unknown, true>; | ||
|
|
||
| current: IMorphType[] = $derived.by(() => { | ||
| return this.#morphTypesResource.current; | ||
| }); | ||
|
|
||
| async refetch() { | ||
| await this.#morphTypesResource.refetch(); | ||
| return this.current; | ||
| } | ||
|
|
||
| prefixes = $derived.by(() => { | ||
| const result: Partial<{[kind in MorphTypeKind]: string|undefined}> = {}; | ||
| this.current.forEach(morphType => { | ||
| result[morphType.kind] = morphType.prefix; | ||
| }); | ||
| return result; | ||
| }); | ||
|
|
||
| suffixes = $derived.by(() => { | ||
| const result: Partial<{[kind in MorphTypeKind]: string|undefined}> = {}; | ||
| this.current.forEach(morphType => { | ||
| result[morphType.kind] = morphType.postfix; | ||
| }); | ||
| return result; | ||
| }); | ||
|
|
||
| getPrefix(kind: MorphTypeKind): string|undefined { | ||
| return this.prefixes[kind]; | ||
| } | ||
|
|
||
| getSuffix(kind: MorphTypeKind): string|undefined { | ||
| return this.suffixes[kind]; | ||
| } | ||
|
|
||
| decorate(headword: string | undefined, kind: MorphTypeKind): string|undefined { | ||
| if (!headword) return headword; | ||
| const prefix = this.getPrefix(kind) ?? ''; | ||
| const suffix = this.getSuffix(kind) ?? ''; | ||
| return `${prefix}${headword}${suffix}`; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the decorated headword searchable too.
After Line 137, the UI can show
-a/a-, but the current demo search/filter path still matches only rawlexemeForm/citationFormvalues. That means users can now see headwords they cannot filter for, which is already the failing-acase called out in the PR notes. Please drive filtering from the same decorated headword representation.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed sorting in the demo API to not consider/include/respect morph-tokens.
TODO: It's true that the filter code should check against headword OR lexeme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Let me look at the filter code to provide concrete guidance on where and how to fix it.
🏁 Script executed:
Length of output: 151
🏁 Script executed:
Length of output: 883
🏁 Script executed:
Length of output: 4097
@myieye, thanks for the sorting fix and the TODO note. ThefilterEntriesstandalone function inin-memory-demo-api.tsis the concrete place to fix — it already checks rawlexemeForm/citationForm, but needs to also include the decorated values. SinceInMemoryDemoApialready holds#morphTypesService, the change is small:Then at the call site in
getFilteredEntries:The
citationFormguard mirrors the same logic already inWritingSystemService.#decorated, so the two stay in sync — if the entry has a citation form for a given WS, the filter won't add a phantom decorated hit for that WS. The exemplar filter is a separate concern (index-tab navigation), but the same pattern would apply there if you want consistency.🧠 Learnings used