-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
523 changed files
with
2,542 additions
and
3,733 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,12 @@ | ||
%% Begin Waypoint %% | ||
- **[[Development]]** | ||
- **[[Government regulation]]** | ||
- **[[Institutional types]]** | ||
- **[[Law]]** | ||
- **[[Regulation]]** | ||
- **[[Sovereignty]]** | ||
|
||
%% End Waypoint %% | ||
|
||
```dataviewjs | ||
function toPrologAtom(str) { | ||
return str.replace(/ /g, '_').toLowerCase(); // Replace spaces with underscores for Prolog atoms | ||
} | ||
const currentFolder = dv.current().file.folder; | ||
const pages = dv.pages().filter(p => p.file && p.file.folder.startsWith(currentFolder)); | ||
let prologStatements = ''; | ||
const fileMap = {}; | ||
const fileMapAll = {}; | ||
let triples = []; | ||
// Populate the fileMap for current folder and fileMapAll for the whole Vault | ||
pages.forEach(page => { | ||
if (page.file && page.file.path) { | ||
const path = page.file.path; | ||
const fileName = toPrologAtom(page.file.name); | ||
fileMap[path] = fileName; | ||
} | ||
}); | ||
dv.pages().forEach(page => { | ||
if (page.file && page.file.path) { | ||
const path = page.file.path; | ||
const fileName = toPrologAtom(page.file.name); | ||
fileMapAll[path] = fileName; | ||
} | ||
}); | ||
// Generate the triples | ||
pages.forEach(page => { | ||
if (!page.file || !page.file.path) return; | ||
const path = page.file.path; | ||
const fileName = toPrologAtom(page.file.name); | ||
const folderName = toPrologAtom(page.file.folder.split('/').pop()); | ||
const outgoingLinks = page.file.outlinks ? [...new Set(page.file.outlinks.values.map(l => l.path))] : []; | ||
const processedLinks = {}; | ||
const links = Object.entries(page).filter(([key, val]) => val && val.path != null).map(([key, val]) => { | ||
const item = { from: fileName, to: fileMapAll[val.path], rel: toPrologAtom(key) }; | ||
processedLinks[val.path] = 1; | ||
return item; | ||
}).filter(item => item.from !== item.to); // Filter out self-referential links | ||
triples = triples.concat(links); | ||
const unnamedLinks = outgoingLinks.filter(l => !processedLinks[l]).map(l => ({ from: fileName, to: fileMapAll[l], rel: 'linked' })); | ||
triples = triples.concat(unnamedLinks); | ||
}); | ||
// Remove duplicate triples | ||
const uniqueTriples = Array.from(new Set(triples.map(JSON.stringify))).map(JSON.parse); | ||
// Generate atoms for each node | ||
const nodes = Object.values(fileMap).map(v => `${v}.`).join('\n'); | ||
prologStatements += nodes + '\n\n'; | ||
// Separate and sort Prolog statements for each edge | ||
let parentRelations = []; | ||
let otherRelations = []; | ||
uniqueTriples.forEach(t => { | ||
const fromPage = pages.find(page => fileMap[page.file.path] === t.from); | ||
const toPage = dv.pages().find(page => fileMapAll[page.file.path] === t.to); | ||
// Check if 'toPage' is in the same folder as 'fromPage' OR if 'toPage' is in a subfolder of 'fromPage' | ||
if (toPage && ( | ||
toPage.file.folder === fromPage.file.folder || | ||
toPage.file.folder.startsWith(fromPage.file.folder + '/') | ||
)) { | ||
parentRelations.push(`parent(${t.from}, ${t.to}).`); | ||
} else { | ||
otherRelations.push(`${t.rel}(${t.from}, ${t.to}).`); | ||
} | ||
}); | ||
// Sort otherRelations alphabetically | ||
otherRelations.sort(); | ||
// Concatenate Prolog statements: otherRelations and parentRelations | ||
prologStatements += otherRelations.join('\n') + '\n\n'; | ||
prologStatements += parentRelations.join('\n') + '\n\n'; | ||
// Output Prolog statements | ||
dv.header(2, currentFolder); | ||
dv.span(prologStatements, 'prolog'); | ||
await dv.view("prolog"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
content/Entries/Concepts/Abstract/Institutional types/Corporation/Corporation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%% Begin Waypoint %% | ||
- **[[Trans-National Corporations]]** | ||
|
||
%% End Waypoint %% | ||
|
||
```dataviewjs | ||
await dv.view("prolog"); | ||
``` |
8 changes: 8 additions & 0 deletions
8
...al types/Corporation/Trans-National Corporations/Trans-National Corporations.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%% Begin Waypoint %% | ||
|
||
|
||
%% End Waypoint %% | ||
|
||
```dataviewjs | ||
await dv.view("prolog"); | ||
``` |
10 changes: 10 additions & 0 deletions
10
content/Entries/Concepts/Abstract/Institutional types/Government/Government.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[does::[[Government regulation]]] | ||
|
||
%% Begin Waypoint %% | ||
|
||
|
||
%% End Waypoint %% | ||
|
||
```dataviewjs | ||
await dv.view("prolog"); | ||
``` |
10 changes: 10 additions & 0 deletions
10
content/Entries/Concepts/Abstract/Institutional types/Institutional types.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
%% Begin Waypoint %% | ||
- **[[Corporation]]** | ||
- **[[Government]]** | ||
- **[[Intergovernmental bodies]]** | ||
|
||
%% End Waypoint %% | ||
|
||
```dataviewjs | ||
await dv.view("prolog"); | ||
``` |
8 changes: 8 additions & 0 deletions
8
...stract/Institutional types/Intergovernmental bodies/Intergovernmental bodies.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%% Begin Waypoint %% | ||
|
||
|
||
%% End Waypoint %% | ||
|
||
```dataviewjs | ||
await dv.view("prolog"); | ||
``` |
Oops, something went wrong.