-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat/palette-json-generator-webapp #25
feat/palette-json-generator-webapp #25
Conversation
- uses `fetch()` to retrieve the blissay ID map, - uses `fetch()` to retrieve W3C's bliss gloss .json file, - UUID for each cell is prepended with the cell's label, - generates an "Unknown" cell for errors, to be fixed manually, - outputs a palette file with problem cells indicated as such.
- use local copy of `bliss_symbol_explanations.json`, - `String.include()` will sometimes match many glosses. The script now outputs all the matches found to the console and uses the first match in the generated palette - for no match found, outputs a cell with label "NOT FOUND" and Bliss word for "not found".
README.md
Outdated
## Utility Scripts | ||
|
||
- [Load a document into a vector databbase (`scripts/loadDocIntoVectorDb.js`)](./scripts/loadDocIntoVectorDb.js) | ||
- [Generate a palette JSON file (`scripts/paletteJsonGenerator.js`)](./scripts/loadDocIntoVectorDb.js) |
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.
"paletteJsonGenerator.js" is not in the "./scripts" directory. Did you forget to clean up this line after making the generator an app?
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.
Yup. I'll remove it.
apps/palette-generator/README.md
Outdated
|
||
Once the development server is running, open this `localhost` url from within a | ||
browser: | ||
[`http://localhost:5173/apps/palette-generator/palette-generator.html`](http://localhost:5173/apps/palette-generator/palette-generator.html) |
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.
What do you think about renaming "palette-generator.html" to "index.html" so that accessing "http://localhost:5173/apps/palette-generator/" will automatically load the index 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.
Good idea.
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.
Since the entry page has been renamed to "index.html", the link and text should be changed to remove "palette-generator.html".
apps/palette-generator/README.md
Outdated
row of the palette cells. Spaces are used for separate cells so the text used | ||
to specify a cell cannot contain any spaces. | ||
|
||
There are three types of input allowed here: |
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.
You listed four types below. Change "three types" to "four types" in this line?
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.
Yes.
apps/palette-generator/README.md
Outdated
the label "cross hatches"; and "23641LABEL:ruin" will give "ruin" as the label | ||
instead of the official gloss "ruin,wreck,wreckage\_(building)\_(1)". | ||
|
||
The SVG string is marked by "SVG:" at the beginning of the string and ":SVG" at |
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.
Provide an example of using the SVG string.
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've added two examples. But, I am not going to explain the full syntax of svg builder strings. That should be in the svg-builder project, but there is no documentation there. And, I don't know the full specification. :-(
apps/palette-generator/README.md
Outdated
### Save Palette | ||
|
||
Clicking the "Save palette" button will export a palette definition JSON file | ||
and save it into the user's "Downloads" folder. The name of the file will be |
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.
What if the user's computer doesn't hae a "Downloads" folder. Is this a browser specific configuration?
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.
Good question. The code itself does not include the name "Downloads" or the name of any other folder. An url is created that the browser understands, but is meaningless to me. The file ends up in the folder that has been set as the browser's download folder. Users can set this to something other than "Downloads", in which case the palette will be saved based on that browser setting.
I will reword it to say, '.. and saved to disk where the browser saves file downloads, typically the "Downloads" folder.'
// Initialize any globals used elsewhere in the code. | ||
await initAdaptivePaletteGlobals("paletteDisplay"); | ||
await fetchBlissGlossJson(); | ||
let currentPaletteName = ""; |
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.
The hook for currentPaletteName
is probably wrong. The save button doesn't save the given palette name. The clear button doesn't clear the palette name too.
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 found a bug here and fixed it, but I have not addressed your comment fully:
The save button doesn't save the given palette name.
It does after the fix, but there is still an edge case where (1) the palette is generated, (2) the user changes the name in the text field, and then (3) clicks the "Save" button. In that case, the file is saved according the name in the text field when the palette was generated, not the just-changed text field For this case, there needs to be an event handler for watching changes in the text field and adjusting various objects. I'm working on that.
The clear button doesn't clear the palette name too.
I don't think it should clear the name in the text field. If a palette has been generated, but there are mistakes, and all the user wants to do is clear it, fix the mistake(s), and re-generate, then they should not have to re-enter the name. Their intent is to change the contents of the palette, not the name. When they do want to change the name, then it's relatively simple to click on the text field and give it a new name.
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 don't think it should clear the name in the text field.
Thanks for the clarification, and I agree.
const LABEL_MARKER = "LABEL:"; | ||
|
||
// Configurable options -- ideally provided by the UI | ||
const palette_name = "No name Palette"; |
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.
The default palette name on the UI is "palette". Would be nice to sync up the default value of palette_name
variable and the one on the UI.
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.
Good idea. I will get the contents of the name text field and pass it into the generator function.
const type = "ActionBmwCodeCell"; | ||
|
||
// Special encodings for labels that don't follow the standard mapping | ||
const specialEncodings = { |
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.
README probably should include the usage of this specialEncodings
. Or, with introducing the LABEL:
feature, this handling can be removed from the code?
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'm inclined to remove it now. But, just in case, what did you intend it for? Do the SVG: and LABEL: features cover that purpose?
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 agree this special handling can be removed.
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.
Remove the definition and the use of specialEncodings
?
List the items in each row, one line per row. Each row consists of a set | ||
of glosses separated by a space. | ||
</p> | ||
<label for="glossInput">Glosses:</label><br> |
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.
The label for the text area to receive BCI-AV-ID, glosses, SVGs etc should no longer be "Glosses" since it accepts a lot more than glosses.
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.
Right, I'll come up with a better name.
const BLANK_CELL_LABEL = "BLANK"; | ||
const SVG_PREFIX = "SVG:"; | ||
const SVG_SUFFIX = ":SVG"; | ||
const LABEL_MARKER = "LABEL:"; |
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.
When I input this line in the "Glosses" text area:
BLANK 18267LABEL:aaa induction
to alter the label for a symbol. I got this error in the error section: "BciAvId not found for label: induction". Moving the "LABEL:" marker to the last "induction" gloss reports the same error.
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.
That string specifies three cells: a blank one, one for a plus sign labelled "aaa" and a cell whose gloss is "induction" or contains the word induction. "Induction" does not match any gloss and that is why there is an error. Checking blissary.com with "induction" gives "No results found." The result is as expected. Moving the LABEL marker won't change the result.
There was some text in the README explaining that spaces are used as a separator to indicate the string to use for a cell. I've added more warnings to that effect including that LABEL: strings cannot contain spaces and to use an underscore if a space is desired. Specifically, if the label for the plus sign was supposed to be "aaa induction", then you write it this way:
BLANK 18267LABEL:aaa_induction
That gives two cells, a blank and a plus with the label "aaa induction".
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.
You are right. The error is reported correctly. I mistakenly thought it was related to the "LABEL" marker.
- also renamed a number of variables that used python underscore_case to used camelCase.
apps/palette-generator/README.md
Outdated
strings that are parsed by the svg builder. If the string "LABEL:*label\_text" | ||
occurs immediately before the closing ":SVG" marker, it will be used as the | ||
label for the cell, and is truncated from the rest of the string before the | ||
remainder is sent to the builder. The rules for the syntax of this "LABEL" is |
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 tried with using "LABEL" with "SVG" marker. This string SVG:14183,"/",25777,"/","W8W:0,8":SVGLABEL:aaa
leads to an error: "BciAvId not found for label: SVG:14183,"/",25777,"/","W8W:0,8":SVG". Did I combine the "SVG" and "LABEL" correctly?
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.
Quoting from the README with emphasis:
If the string "LABEL:*label_text" occurs immediately before the closing ":SVG" marker,
So your example should be SVG:14183,"/",25777,"/","W8W:0,8","LABEL:aaa":SVG
However, that's different from the two other cases of an ID or a gloss-string, where the LABEL:
is appended to the ID or string. I think it should be the same regardless of the input. I have re-written the processing so that your example works, and the old way is now illegal.
It would be helpful for users if you could add a small helper section next to the "Glosses" text field on the app interface. This area could provide quick explanations or examples of available markers like SVG, LABEL, and BLANK. I found I often doubt if I'm using these markers correctly and have to check README frequently. |
@cindyli wrote:
I added one but in a way that allows users to pop it open as needed and then hide it. I used the I think I addressed all of your comments -- ready for another review, thanks. |
apps/palette-generator/README.md
Outdated
|
||
Once the development server is running, open this `localhost` url from within a | ||
browser: | ||
[`http://localhost:5173/apps/palette-generator/palette-generator.html`](http://localhost:5173/apps/palette-generator/palette-generator.html) |
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.
Since the entry page has been renamed to "index.html", the link and text should be changed to remove "palette-generator.html".
// dd = document.createElement("dd"); | ||
// dl.append(dd); | ||
// dd.innerText = match.label; |
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.
Remove the commented code?
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.
Yes, no longer needed.
const type = "ActionBmwCodeCell"; | ||
|
||
// Special encodings for labels that don't follow the standard mapping | ||
const specialEncodings = { |
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.
Remove the definition and the use of specialEncodings
?
if (matches.length === 0) { | ||
throw new Error(`BciAvId not found for label: ${label}`); | ||
} | ||
console.log(""); |
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.
Shall this line be removed?
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.
It was meant to output a blank line to separate the matches logged on the console. But in FF it insists on printing <empty string>
which is not a blank line. I switched it to console.log("\n");
and that does print a blank line. Then I took it out completely, and the logged matches are readable even without a separating blank line. So, I ended up simply removing it.
@cindyli, I've addressed you last comments. I also added a new Nonetheless, ready for another review. |
The pull request looks great. I will wait for the fix of the rendering of the |
I did manage to render Then I realized that the palette json file to be saved should never have cells of type Let me know what you think. |
I agree this is fine. |
A web-app for entering glosses, BCI AV IDs, and svg builder strings to produce and save a palette.
The main point is to make it easier than the previous way to make palettes by using text editor to edit the JSON description file directly. The previous way was time consuming and very error prone. The web-app approach allows most of the generation of the JSON to be automated, and allows the user to later tweak the JSON file as necessary.
This branch was originally created based on the code for PR #21, but incorporated @cindyli's script into user interface. It's not clear if this should be directly merged with the main branch or merged into the feat/palette-json-generator script branch first.