Expansion of Terms, Abbreviations, and Definitions

An expansion of the solution here: Abbreviations and Definitions in a Dataview table.
It gets a bit metaphysical, so please bear with me.

I have these note types:

  • Abbreviation - e.g. “CM”. Tagged #abbreviation. Managed as a Metadata Menu fileClass with the relevant fields.
  • Term - e.g. “Construction Management” or “Contract Manager”. May be tagged #terminology, or anything else
  • Organisation - e.g. “This Company”. Tagged #organisation
  • Project - e.g. “My Project”. May be tagged #project or similar.

What I’m trying to do

In a note for a project, I want a table like this:

Abbreviation Term Definition(s)
CM Construction Management, Contract Manager (definition of these terms)
PM Project Manager, Preventative Maintenance (definition of these terms)

An Abbreviation may have multiple Terms associated with it (see “CM” above). The current solution uses a field called “terms” in the Abbreviation, which are linked to defined Terms.
The Abbreviation is also tagged with the project, so that the above table only returns abbreviations related to the project.
Each Term then has a field “summary” which can be returned for each Term in the table above.

This is all working fine currently.

HOWEVER.

If an Abbreviation has multiple Terms depending on the context, the table should only display the Term(s) for that Abbreviation related to that context.
The Context may be a project, an organisation, or anything else.
Imagine if the Abbreviation “BM” meant “Business Manager” in one context, and “Bowel Movement” in another context. Currently the table would would display all meanings of the Abbreviation in every table.

Things I have tried / am currently trying

See Abbreviations and Definitions in a Dataview table for previous efforts.

In the Abbreviation fileClass, I’ve added new ObjectList and Object fields, so now the frontmatter for the note “BM” looks like this:

---
tags:
  - abbreviation
objectList_Terms in use by Context:
  - object_Terms by Context: 
      fileMulti_Contexts:
        - "[[Projects/Some Project Or Other]]"
        - "[[Projects/Another Project]]"
        - "[[Another Context]]"
      file_Term: "[[Terminology/Business Manager]]"
  - object_Terms by Context: 
      fileMulti_Contexts:
        - "[[Projects/Another Project]]"
      file_Term: "[[Terminology/Breakfast Monitor]]"
  - object_Terms by Context: 
      fileMulti_Contexts:
        - "[[Health]]"
        - "[[Puerile Jokes]]"
      file_Term: "[[Terminology/Bowel Movement]]"
---

In this way, we can say that BM has one meaning in some contexts, and another meaning in other contexts.

Now the question is, how do I use this information to make the tables for each context?

For “Health” the table would show:

Abbreviation Term Definition(s)
BM Bowel Movement (definition of term from the summary field)
etc

For “Another Project” the table would show:

Abbreviation Term Definition(s)
BM * Business Manager (definition of term from the summary field)
* Breakfast Monitor (definition of term from the summary field)
etc

Would this be possible?

Yes, it would be possible! :smiley:

I would simplify the structure slightly, though, so I tested with the following BM file:

---
tags:
  - f78368
  - abbreviation
contexts:
- term: "[[Terminology/Business Manager]]"
  fileContexts:
  - "[[Projects/Some Project Or Other]]"
  - "[[Projects/Another Project]]"
  - "[[Another Context]]"
- term: "[[Terminology/Breakfast Monitor]]"
  fileContexts:
  - "[[Projects/Another Project]]"
- term: "[[Terminology/Bowel Movement]]"
  fileContexts:
  - "[[Health]]"
  - "[[Puerile Jokes]]"
---

```dataview
TABLE WITHOUT ID ctx.term, ctx.fileContexts
WHERE file = this.file
FLATTEN contexts as ctx
```

This would be easier to maintain, as it has shorter names and a slightly simpler syntax, but it is still very queryable(?). The query above lists the various terms, with the corresponding contexts.

In the other files, you could then use this query:

```dataview
TABLE ctx.term
FROM #abbreviation 
FLATTEN contexts as ctx
WHERE contains(ctx.fileContexts, this.file.link)
```

And it would list all the matching abbreviations with the file linking to the term. I’m not sure where you would pick the description from? Is that a property of the ctx.term file? If so, you could add it by simply doing something like ctx.term.summary or similar.

1 Like

That’s great thank you!
I didn’t realise I could just have multiple contexts instead of an object containing a list of contexts. That’s simpler.
The Term note contains a field “summary” which can be returned by a query (you suggested this in the previous thread).
So the key reason for all this is to have a table showing all the Abbreviations, Terms, and Term Summaries for a particular context.

I have this, but it doesn’t return the Abbreviations for the context:

TABLE ctx.term, ctx.fileContexts
FROM #abbreviation
WHERE contains(ctx.fileContexts, "[[Abbreviation Test Document]]")
FLATTEN contexts AS ctx
SORT file ASC, string(term) ASC

The 2nd issue is how to get the summary to display in the table. The summary is a field of each Term, so the query would have to reach into each linked term to retrieve it. The table should look like this for the abbreviations in a particular context:

Abbreviation Term Summary
(abbreviation from the selected context) (term) (summary from the term)
BM Business Manager Someone who manages business
CM Configuration Management (summary for that)

That’s more tricky I think. I tried some things but it might need dataviewJS.

When copying queries, be sure to keep the lines in order. You’ve switched the FLATTEN ... as ctx and the WHERE ctx..., which breaks the query.

Regarding the 2nd issue, I’ve already said the solution, put ctx.term.summary into the display line. In other words, use this query:

```dataview
TABLE ctx.term, ctx.fileContexts, ctx.term.summary
FROM #abbreviation
FLATTEN contexts AS ctx
WHERE contains(ctx.fileContexts, [[Abbreviation Test Document]])
SORT file.name ASC
```

I’m a little uncertain about the sorting, but doing both on the file and the term seems superfluous, and doing sort on the full file object is usually a bad idea, so it’s better to use just the name part (and avoid any issue with other parts being used for sorting (i.e. the folder part).

Update: Corrected a typo with some extra quotes

Thanks again for your indispensable assistance. I think this is shaping up to be a “Share and showcase” post.

The frontmatter can be edited manually, but I found it easier to use Metadata Menu. By using the Metadata Menu fileClass function, I created a fileClass file_Abbreviation, which is linked to the tag abbreviation, or any note in the folder Abbreviations. The fileClass includes the following fields:

  • contexts (ObjectList)
  • term (File link) (child of contexts)
  • fileContexts (Multifile link) (child of contexts)

This means that all notes with that tag or in that folder can be given the fields semi-automatically, and the field entry is made easier.

An example for the abbreviation “BM2” frontmatter after editing:

---
tags:
  - abbreviation
contexts:
  - term: "[[Terminology/Breakfast Monitor]]"
    fileContexts:
      - "[[Organisations/International Union of Railways]]"
  - term: "[[Terminology/Bowel Movement]]"
    fileContexts:
      - "[[Projects/Podcasts/Coiled Spring/Podcast]]"
      - "[[Abbreviations/Puerile Jokes]]"
  - term: "[[Terminology/Business Manager]]"
    fileContexts:
      - "[[Projects/Another Project]]"
      - "[[Documentation Publishing Plan]]"
---

Then in the body of the abbreviation note I can put this:

```dataview
TABLE WITHOUT ID ctx.term, ctx.term.summary, ctx.fileContexts
WHERE file = this.file
FLATTEN contexts as ctx

Which displays the uses of the abbreviation in the various contexts:

Now in the document or other context requiring a list of abbreviations relevant in that context, we canb have this:

TABLE WITHOUT ID ctx.term as "Term", ctx.term.summary as "Summary", ctx.fileContexts as "Context(s)"
FROM #abbreviation
FLATTEN contexts AS ctx
WHERE contains(ctx.fileContexts, [[Podcast]])

(note that “[[Podcast]]” is not in quotes in the WHERE expression. That was the problem before.)

I could even skip the column showing contexts, because we know the abbreviation is relevant to the current context, and we may not care what other contexts it’s relevant in.

All working well now, thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.