foambubble / foam

A personal knowledge management and sharing system for VSCode
https://foambubble.github.io/
Other
15.36k stars 659 forks source link

Resolve Plurals and Alternative Names (Aliases) #1066

Closed jmanthony3 closed 2 years ago

jmanthony3 commented 2 years ago

Is your feature request related to a problem? Please describe.

Every once in a while, an instantiation of a tag or wikilink in a note refers to a keyword or concept (depending on level of abstraction) but must be written in the plural form to fit grammatically within the sentence wherein the tag/wikilink is referenced. Unless one can live with bad grammar in a note, writing tags/wikilinks in both the singular and plural forms can generate twice as many tags and wikilinks which are redundant and do not take full advantage of navigating/searching by that tag throughout all referenced notes because the singular and plural forms are treated as entirely separate tags. Furthermore, some concepts are referred to by slightly different names or by an acronym, but instantiating tags/wikilinks to these references generates more, separate tags/wikilinks instead of referencing the same, root keyword/concept.

461 explains that an alias can be written in the instantiation of a wikilink in the note via: [[wikilink|alias]]. However, this behavior does not really help, because the alias is only shown in the preview of the note (the first screenshot below) and does not update how that note itself is referenced from other notes. Referring to the second screenshot, if I were to change [[high-cycle-fatigue|HCF]] to [[HCF]], then Foam wants to create a new note dedicated to "HCF" and does not reference the existing note for "high-cycle-fatigue". Furthermore, attempting to follow the advice from #461 via a YAML table in the note properties section of the note does not yield the desired result (as displayed in the third screenshot). The definition of this alias was made with and without double quotes and existed before the first and second screenshots were taken.

According to #461, aliases only apply to wikilinks and do not extend to tags wherein the same issue can exist. I explain in more detail below, but there does not seem to be a way to generate aliases for tags that could exist in a singular or plural form or as an acronym.

Describe the solution you'd like

As a user, I would like to see a way to assign aliases to a tag/wikilink that future instantiations using one of those aliases references the same tag/wikilink; thereby, reducing the number of redundant tags/wikilinks and taking full advantage of intra-note referencing while still maintaining correct grammar or fitting within the context of the note. In some notes, a concept might be referred to in the singular or plural tenses, by alternative name, or by an acronym. For example, if I have a note talking about the importance of Finite Element Analysis (FEA) in future engineering solutions, then I could tag/wikilink either the "Finite Element Analysis" or the "FEA" portions of the statement. Either portion reference the same, root keyword/concept. Or, tagging the keyword "code" in a note would reference the same, root keyword as another tagged keyword "codes". This probably should not be a fully automatic feature without user oversight because words that are similar to each other (by plurality or acronym) may actually refer to other things: e.g. an acronym can stand for multiple things and this would be ambiguous which definition of the acronym one refers to.

Describe alternatives you've considered

So far, I am living with bad grammar and putting the alternative names for a concept in the name of the note itself, but this makes for expressively long file names.

Screenshots or Videos

image

image

image

riccardoferretti commented 2 years ago

First of all thanks for the thorough description of the issue, it makes it much easier to work with :)

Foam wants to be md compatible and is trying to find solutions that work both for the user and the knowledge base (we don't want to add resolution rules that are opinionated, otherwise you wouldn't be able to use your knowledge base outside of Foam).

This is why we went for the alias approach to address issues like yours.

The only other solution I can see (but it's not built-in) is to use wikilink references to achieve the same, e.g.:

3. [[HCF]]: elastic regimes of materials

[HCF]: high-cycle-fatigue "HCF"

This issue is not too different from the slugification debate that has been ongoing within Foam, FYI #1033

In short, my take is that this can only be worked around using aliases because of the markdown specs, possibly using definitions (but there is no good workflow around that), and I wouldn't want to add into Foam a more complex resolution logic that will make notes not md compatible.

jmanthony3 commented 2 years ago

So I added [HCF]: high-cycle-fatigue "HCF" to the bottom of the note as you suggest (as seen in the screenshot below). But this only works within the note itself where this definition is included. I can refer to the high-cycle-fatigue.md by "HCF" within note this definition is written, but I cannot use the acronym in other notes to link to this same file. Are you saying that adding this capability for linking alias definitions across files (not just within the file the definition is given) would break compatibility for Markdown?

image

riccardoferretti commented 2 years ago

The definition only works for the file in which exists, so the behavior you saw is correct. You would need to include that in every file where you want to use the alias.

jmanthony3 commented 2 years ago

Hmm...sounds like I could, then, write an external file for a dictionary of aliases and insert relevant definitions from this dictionary at the bottom of each file.

jmanthony3 commented 2 years ago

Hmm...sounds like I could, then, write an external file for a dictionary of aliases and insert relevant definitions from this dictionary at the bottom of each file.

Wait, if the link references definition can be populated automatically (by this setting) at the bottom of a file, then why not allow for the presence of an external file to source these definitions and have this automatic inclusion be super long? If automatically populating the bottom of Markdown files does not break compatibility, then could this automatic process first reference an external dictionary of one's own design to populate the bottom of every file (with options to exclude files made in certain folders)?

riccardoferretti commented 2 years ago

sounds like I could, then, write an external file for a dictionary of aliases and insert relevant definitions from this dictionary at the bottom of each file

yes that would work

why not allow for the presence of an external file to source these definitions and have this automatic inclusion be super long?

That could be done, I wouldn't consider that to be scope for Foam core, but an extension built on the Foam API (which is WIP) would very easily achieve that, possibly even as an in-memory look-up (basically you wouldn't even need to append the definitions, as at that point you would be augmenting the Foam metadata). This would basically mean building the feature you request, but not within Foam itself (where I don't believe it belongs), but as an extension of Foam (as other people have done to customize their workflow)