Tasks dynamic template script to rank and measure progress of papers

What I’m trying to do

I have several notes (in the hundreds) that are annotation corresponding to papers.
A list of tasks in every note helps to track the progress that is being done on the paper, such as:

  • Critique
    • 1- 5
    • 6 - 10
  • Highlights
    • 1- 5
    • 6 - 10
  • Terms
  • Citations
    • 1- 5
    • 6 - 10
    • 11 - 20
    • > 20
  • Callouts
    • [!Equation]
    • [!Algorithm]
    • [!Table]
    • [!Schematic]
    • [!Annotated]
  • Reproducibility
    • Code available
    • Running DevContainer
    • Reproduce results

As the paper is being reviewed, the check boxes are ticked, and the progress for each paper is automatically calculated based on the tasks.

Things I have tried

I have tried doing this with Templater, which is quite straightforward. The tasks are pasted into the new note.
The problem is when I want to modify, or add, a task, or tasks, I have to do it manually on each of the notes, which is tiresome.

Is there any way of creating a dynamic tasks template that can be “controlled” (edit/add/remove) by means of JavaScript in Obsidian.

I have tried with Dataview but it will only collect already existing tasks; it doesn’t create a new task that is owned by each of the notes. For calculations, it is easy. I just call a view .js script, and call it via:

```dataviewjs
dv.view("citationStatus")
```

where the citationStatus view lives in the script citationStatus.js.

This is what I have done so far:

```dataviewjs
const tasks = [
  { id: 1, name: "keywords", completed: false, 
  subtasks: [
	  {text: "L1", lim: 1, completed: false},
	  {text: "L2", lim: 5, completed: false},
	  {text: "L3", lim: 10, completed: false},
	  {text: "L4", lim: 20, completed: false},
  ]}, 
  { id: 2, name: "terms", completed: false,
    subtasks: [
	  {text: "L1", lim: 1, completed: false},
	  {text: "L2", lim: 3, completed: false},
	  {text: "L3", lim: 9, completed: false},
  ]}, 
  { id: 3, name: "citations", completed: false,
    subtasks: [
	  {text: "L1", lim: 1, completed: false},
	  {text: "L2", lim: 2, completed: false},
	  {text: "L3", lim: 4, completed: false},
	  {text: "L4", lim: 8, completed: false},
	  {text: "L5", lim: 16, completed: false},
  ]}, 
  { id: 4, name: "figures", completed: false,
    subtasks: [
	  {text: "L1", lim: 1, completed: false},
	  {text: "L2", lim: 3, completed: false},
	  {text: "L3", lim: 9, completed: false},
  ]},  
  { id: 5, name: "critique", completed: false,
    subtasks: [
	  {text: "L1", lim: 1, completed: false},
	  {text: "L2", lim: 3, completed: false},
	  {text: "L3", lim: 7, completed: false},
  ]},     
  { id: 6, name: "highlights", completed: false,
    subtasks: [
	  {text: "L1", lim: 1, completed: false},
	  {text: "L2", lim: 3, completed: false},
	  {text: "L3", lim: 7, completed: false},
  ]},    
  { id: 7, name: "!equation", completed: false,
    subtasks: [
	  {text: "L1", lim: 1, completed: false},
	  {text: "L2", lim: 2, completed: false},
  ]},
  { id: 8, name: "!schematic", completed: false,
    subtasks: [
	  {text: "L1", lim: 3, completed: false},
	  {text: "L2", lim: 5, completed: false},
  ]},  
  { id: 9, name: "Code available", completed: false,
    subtasks: [
	  {text: "L0", lim: 1, completed: false},
  ]},
  { id: 10, name: "Running DevContainer", completed: false,
    subtasks: [
	  {text: "L0", lim: 1, completed: false},
  ]},  
];



// Check if a task is completed
const isTaskCompleted = (taskId) => {
  const task = tasks.find((t) => t.id === taskId);
  return task ? task.completed : false;
};

// Check if a subtask is completed
const isSubtaskCompleted = (taskId, taskValue) => {
  const task = tasks.find((t) => t.id === taskId);
  task.subtasks.forEach(st => {
	  if (taskValue >= st.lim) st.completed = true
  })
  return task
};

let taskId;
let taskValue;

taskId = 1;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))

taskId = 2;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))

taskId = 3;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))

taskId = 4;
taskValue = 3;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))

taskId = 5;
taskValue = 2;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))

taskId = 6;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))

taskId = 8;
taskValue = 2;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))

taskId = 9;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))


var nSubtasks = tasks
	.map(t => t.subtasks.length )
	.reduce( (accum, st) => accum + st, 0);

var nStCompleted = tasks
	.map(t => t.subtasks
		.filter(st => st.completed))
	.filter(task => task.length !== 0).flat().length
	
	

// dv.span(tasks)
dv.table(["id", "criteria", "Level", "completed"],
	tasks.map(p => [
		p.id,
		p.name,
		p.subtasks.map(q => q.text),
		p.subtasks.map(q => q.completed ? "🟢" : "🔴")
	]
	)
)

dv.span("Progress: ")
dv.span((nStCompleted / nSubtasks * 100).toFixed(2))
dv.span("%")
```

This allows me to get a percentage of completion as I progress reviewing papers. The more useful or important snippets I exttact, the most valuable the paper is. It works like some sort of ranking.

There is a couple of remaining things I wanted to ask for help: how to remove the bullet from the list in Level and completed.

This will allow me to (i) insert the javascript snippet as a view; (ii) insert the view in all the paper notes (more than 350); (iii) be able to modify the view and automatically be reflected in all the notes.

I made additional progress last night, and now have a fully automated ranking tool for reviewing papers.

I love this approach because it is not based on a subjective or rushed opinion by a quick reading of the document. The paper will earn its rank by contributions that are extracted onto an Obsidian note. What can be extracted from a paper while reviewing:

  • Schematics
  • Equations (pasted images first, and then converted to Latex)
  • Tables
  • Algorithms
  • New terms
  • Keywords that define the document
  • Embeddings from a PDF as links
  • Citations that are key for the research
  • Figures, plots
  • Critique and highlights of the paper
  • Ideas, questions, and early write-ups (also called crucibles)
  • Optionals such as labeling callouts as !equation, !schematic, !algorithm, !table. This is later useful to make a collection using Dataview

Other miscellaneous measurements regarding reproducibility are: if the paper has a Git repository (1/0); if you have already set up a DevContainer; if there are datasets available (1/0); etc.

This is part of a research I am doing on Physics Applied to Machine Learning, also called Scientific Machine Learning. Some of the algorithms are also called Physics Informed Neural Network, or PINNs.

Here are some screenshots for the following papers:

Yang et al. 2021. B-PINNs: Bayesian physics-informed neural networks for forward and inverse PDE problems with noisy data

Cuomo et al. 2022. Scientific Machine Learning Through Physics-Informed Neural Networks: Where we are and What’s Next .

Raissi et al. 2017b. Physics Informed Deep Learning (Part II): Data-driven Discovery of Nonlinear Partial Differential Equations .

The code has changed a bit; instead of having a completed property in the master tasks I replaced it with the property value, which stores the current value for the KPI (Key Performance Indicator).

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