I try to manage my conlangs dictionary using obsidian. I store entries in folder “entries” and examples in “examples”. example-1 has yaml field lexeme where I list entries that use this example in [[entry]] format. (to recreate a many-to-many relationship from databases)
There is no problem with making queries that would display examples in the entries that are assigned.
However, I have no idea how to make pages with listings (that I would be able to do if I was using php and mysqli) that show:
a) list of entries that have an examples assigned
b) list of entries without any examples in the database
I would prefer to use dataview, not datavie.js, but I would be grateful if anyone would be so kind to help me with this issue.
This is an example entry (the main metalanguage here is Polish) (I removed the ``` signs around the dataview query for it to render correctly here as the source code)
---
category:
- wikisłownik
język:
- klasyczny żelazny
entryID: 1
created: 2023-11-12
etap: goły
root: "[[R-]]"
gram: zos
glos: ja
---
# ra
## Etymologia
## Informacje gramatyczne
## Znaczenie
## Przykłady
dataview
TABLE WITHOUT ID exeID as "Lp", exe AS "Przykład", glosspl as "Polski"
from "07_przykłady"
where !contains(database-plugin, "basic") and contains(lexeme, [[ra]])
sort file.name asc
## Wyrażenia
dataview
TABLE WITHOUT ID exeID as "Lp", exe AS "Przykład", glosspl as "Polski"
from "08_wyrażenia"
where !contains(database-plugin, "basic") and contains(lexeme, [[ra]])
sort file.name asc
## Źródła
- [[01_ZROBIONE/001_01_dziennik prac.pdf|001_01_dziennik prac]]
- [[003_00_log_slownictwa.pdf]]
and here is the example entry connected to this lexeme entry
---
category:
- wikiprzykład
created: 2024-09-28
etap: goły
exeID: "1"
lexeme:
- "[[ra]]"
- "[[fjelnen]]"
- "[[sa]]"
- "[[fjego]]"
- "[[xölgjen]]"
- "[[malo]]"
- "[[kjedo]]"
- "[[ğavo]]"
length: 8
---
[[Korpus]] - [[Przykłady słownika]]
# Przykład nr 1
>[!example] Przykład
> exe:: Fjelnjen sar fjegöm, xölgjen rövu malor kjedo ğavölga.
> glosspl:: Rano poprosiłam go/ją, żeby pomógł/pomogła mi to zrobić.
> glossen:: In the morning I asked him/her to help me do this.
I managed to do the listing of examples grouped by assigned lexeme:
TABLE rows.exe, rows.glosspl
from "07_przykłady"
FLATTEN lexeme
group by lexeme
But I have no idea how to create a listing of existing lexemes in the folder “05_entries” that are not listed in any example in “07_przykłady” in the yaml.
You do need to flip the query around, and focus on those lexeme entry, as you call them, and then rather list those actually having examples connected to them. However, in order to do so you’ll need to do a double loop on inlinks to the lexeme entry, and picking from the lexemy entry on the examples.
Test case 1: [[ra]] - linked from [[exe1]] & [[exe2]]
Test case 2: [[malo]] - linked from [[exe1]]
Test case 3: [[no examples]] - not linked
```dataview
TABLE WITHOUT ID file.link as Lexeme, linkedExamples as Examples
WHERE file.folder = this.file.folder
AND glos = "ja"
FLATTEN list(filter(file.inlinks, (inlink) => contains(inlink.lexeme, file.link))) as linkedExamples
```
Using a note with the query above, and assuming that all files are in the same folder and the dictionary entries are those having glos: ja, this listed the following:
The trick to this query is to first use filter on the file.inlinks as all links in a file if properly placed somewhere is listed in that list, and then to actually verify that link we want is within the lexeme list.
The list linkedExamples could be used for further mapping of other columns like picking out the glosspl list, or similar, using something like:
FLATTEN list(map(linkedExamples, (link) => link.glosspl)) as glossplList
Bonus tip: Using four backticks around your source text, allows for both the text and any inherent code blocks are shown properly.
O, this is way above my paygrade, but solves my problem to the level I need it to be able to spot the example-less entries. Thank you.
I adapted it to the base (changed some folder names into English).
This solution works as long as the only links I have are examples (and not any other article), but it’ll make my work faster.
```dataview
TABLE WITHOUT ID file.link as Lexeme, linkedExamples as Examples
from "05_entries"
where !contains(database-plugin, "basic")
FLATTEN list(filter(file.inlinks, (inlink) => contains(inlink.lexeme, file.link))) as linkedExamples
```