https://futureofcoding.org/ logo
#thinking-together
Title
# thinking-together
j

Jason Morris

06/08/2023, 6:23 AM
Has anyone seen controlled natural languages implemented in a structure-aware WYSIWYG XML editor? Is there some reason that wouldn't work?
j

Jarno Montonen

06/08/2023, 6:56 AM
Can't say I have, but I'm interested what do you mean by this exactly and what would be the use case?
j

Jason Morris

06/08/2023, 2:27 PM
The use case for CNL is to make the (usually domain-specific) code readable, but writing it has been hard, because there was no way to stop people from typing invalid syntax, and the CNL syntax was so similar to natural language that it was difficult to remember what you can and cannot say. Block-based languages solve the problem by not allowing you to type. You must drag and drop valid syntax nodes and combine them. That's good, but the interface is unfamiliar for some people. Oracle Policy Automation allows you to type anything you want (in MS Word), and offers a search bar you can use to find valid syntax if you get messed up. It's more familiar, but very easy to make syntax errors. A structure aware XML editor would look and feel more like Word, giving non-programmers a familiar environment, but only allow you to type things that were syntactically correct. I'm imagining a sort of strict autocomplete. My particular use case is knowledge representation of statute and regulation, so my users are used to those things being expressed as documents.
j

Jarno Montonen

06/09/2023, 6:06 AM
I see. I think the viability of using XML editor for CNL depends on the details of the language and how structure aware the editor is. Some XML schema definition might be enough for simple language, but more complex languages are likely to require context sensitive syntax rules and even semantic understanding from the editor. I feel like you'll run into a hard ceiling at some point trying to define and enforce the structure with a schema. A language workbench able to produce textual projectional editor would probably be a safer bet.
l

Leonard Pauli

06/14/2023, 5:50 AM
You could try modding the vscode monacco editor, to have autocomplete always trigger, with your custom fn determining possible options in that place in the ast, then redlining bad ones... but even better the strictness, where you would have to select from the list. Possibly okish enough if the text got deleted / fully red highlight, if not passing the check? I'm quite interested in strict structural editors with familiar UI, please connect! :)
j

Jason Morris

06/16/2023, 7:43 PM
To be honest, "familiar UI" isn't inside my set of constraints. My target audience is never going to install VSCode.
In my exploration of the available WYSIWYG XML editors, there are almost none that run off of a schema, and there are actually none for which the schema is dynamic. When you load the editor, it knows what schema it is using, and that schema can't change while it is running. Which means there is no way to let the user define a function, or a predicate, and let them use it on the next line without restarting the editor over and over, which seems like a total non-starter. So that's one reason it won't work, I guess. 🙂
For my use case, the actual language is very prolog like, and I'm not looking for a lot of context-aware features like noticing undefined predicates, etc., because undefined predicates would be literally impossible. So it seems feasible, but there are no tools (in the WYSIWYG XML space) to support it, yet.
7 Views