Using Dataview to Create a Personal Glossary/Dictionary

Things I have tried

I study multiple languages, and I’m trying to use Dataview to create different dictionary-type views of my vocabulary words.

I’m familiar with Javascript, but I’m new to Obsidian and Dataview. I have successfully created Dataview queries that show:

  • all the words in my vocabulary folders with columns showing data about them
  • all the words in a specific language
  • all the words in a specific language with a certain part of speech (ie, all French nouns)

I have some general database learning, but it’s more about building the connections than doing the querying part.

What I’m trying to do

I would like to create “studied language” to “studied language” dictionaries that allow me to display entries like this:

French → Italian
chat: gatto /ˈɡ (m)

I have folders set up like this:
–Individual notes for each word, such as “cat,” “hello,” “goodbye”
-French Vocab
–Individual notes for each word, as in English above, that have the key “English” that is a link to the English note, ie “chat English:: [[Vocabulary/English Vocab/cat]]”
-Italian Vocab
–Individual notes set up as in French above
-Russian Vocab
–Individual notes set up as in French above
…And so on for each language studied

My keys include: Word (vocab term), English (English translation), Language, and a couple others that are more relevant to individual terms rather than comparing across languages (pronunciation, part of speech, etc.).

Is there a way for me to query my folders so that I can have an entry word (“chat” in the display example above) that displays information for its equivalent in another language (gatto /ˈɡ (m) in above)?

Essentially, I have things set up so that:
x = y
z = y

and I want to display:
x = z

I’m using a small test database right now, so I’m fine with rearranging folders, notes, adding/subtracting keys, etc. to accomplish my task.

(Note: I’m not studying English. I included the English folder to link my foreign vocab words to the same English translation because I thought that would help me query the database.)

Thank you for any help or recommendations for tutorials that might help! I searched this forum and beyond and tried the various suggestions I found, but none have gotten me further than where I am yet.

I found the answer to my question while looking for an answer to a different one. I’m going to leave my question up in case someone else is trying to do the same thing, and because the answer was in a long thread that may not necessarily come up.

If anyone else has:
x = y
z = y

and wants to display:
x = z

I did the following:

 TABLE WITHOUT ID[0] as "French",[1] as "Italian",[1].IPA as "IPA"
 FROM "Languages/Vocabulary"
 WHERE contains(Language, "French") or contains(Language, "Italian")
 GROUP BY English

My understanding, line by line (please correct me if I’m wrong!):

  • TABLE WITHOUT ID[0] as “French”,[1] as “Italian”,[1].IPA as “IPA”: Creates a table out of the array made by the FROM and WHERE lines with columns for French, Italian Equivalent, and Italian Pronunciation (IPA)

  • FROM “Languages/Vocabulary”: Pulls notes from the Vocabulary subfolder of Languages

  • WHERE contains(Language, “French”) or contains(Language, “Italian”): Filters notes pulled via FROM to those that contain Italian or French in the Language key

  • GROUP BY English: Connects the French and Italian words based on their English keys/translation

Unfortunately this also sorts the words by their English equivalents, and I’ve tried to sort on every field I can think of to get it to sort by the first column with no luck (ideas welcome!).

I hadn’t seen “” before, until I was scrolling through a snippets thread and came to this post:

So thanks @SkepticMystic for indirectly helping me out!

1 Like

This is very neat, thanks for sharing! You said you know some databases, so I’ll point out that the x = z is related to the concept of “JOIN” in databases. Not something I know much about myself, nor something that Dataview supports naturally, so very cool to see an example in DQL. I am curious how you know the order of French vs Italian in rows...[0] vs rows...[1]? Is it sorting within rows by the Language field, or the folder name/path, …? I do not know how to fix the sorting issue in plain DQL.

If you wanted to try dataviewjs, you might be able to look at the example about direct and indirectly linked pages for some inspiration, although you’re just looking through the direct backlinks of each English page, so less looping necessary. Instead of a Set, you’d want a Map so you can match French & Italian with English. But conceptually, the linked example helped me realize that I can use dataviewjs queries in combination with helper data-structures to get data that looked like what I wanted. Please do share how it goes if you try it!

Thank you! Yes! I looked all over for “JOIN”-related stuff and didn’t have any luck. I’m glad to see it’s not because I’m crazy or didn’t look hard enough…

I didn’t think to save the code I originally had, but it started out as a list of pages grouped by English. When I added the WHERE contains part, I suddenly had a list that showed the French first, then the Italian right underneath, some space, and then the next pair of words.

I had given up on it and was hoping to get help here while I worked on a different problem, when I stumbled on the post linked above. I added like they had and got the word I needed. I changed it to so I could link to the page instead, and then I just changed the labels on those columns with the row…[0] references. I could already see that French was first, so I started it with index 0. It looks like the query put French first because it’s alphabetically first in the folder I was searching.

I’ll have to look into the page you linked some more. I’ll definitely post if I’m able to get it to work. Thank you!

1 Like

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