mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 23:13:43 +08:00
similarity tweaks
This commit is contained in:
parent
4e15bc0bb1
commit
6220b02ef0
3 changed files with 54 additions and 2 deletions
|
@ -8,7 +8,7 @@ const TPL = `
|
|||
<div class="similar-notes-widget hide-in-zen-mode">
|
||||
<style>
|
||||
.similar-notes-wrapper {
|
||||
max-height: 100px;
|
||||
max-height: 75px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
|
|
@ -332,6 +332,18 @@ class Note {
|
|||
this.isDecrypted = true;
|
||||
}
|
||||
}
|
||||
|
||||
// for logging etc
|
||||
get pojo() {
|
||||
const pojo = {...this};
|
||||
|
||||
delete pojo.noteCache;
|
||||
delete pojo.ancestorCache;
|
||||
delete pojo.attributeCache;
|
||||
delete pojo.flatTextCache;
|
||||
|
||||
return pojo;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Note;
|
||||
|
|
|
@ -6,7 +6,21 @@ const IGNORED_ATTR_NAMES = [
|
|||
"includenotelink",
|
||||
"internallink",
|
||||
"imagelink",
|
||||
"relationmaplink"
|
||||
"relationmaplink",
|
||||
"template",
|
||||
"disableversioning",
|
||||
"archived",
|
||||
"hidepromotedattributes",
|
||||
"keyboardshortcut",
|
||||
"bookzoomlevel",
|
||||
"noteinfowidgetdisabled",
|
||||
"linkmapwidgetdisabled",
|
||||
"noterevisionswidgetdisabled",
|
||||
"whatlinksherewidgetdisabled",
|
||||
"similarnoteswidgetdisabled",
|
||||
"disableinclusion",
|
||||
"rendernote",
|
||||
"pageurl",
|
||||
];
|
||||
|
||||
function filterLabelValue(value) {
|
||||
|
@ -41,6 +55,10 @@ function buildRewardMap(note) {
|
|||
}
|
||||
|
||||
for (const ancestorNote of note.ancestors) {
|
||||
if (ancestorNote.noteId === 'root') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ancestorNote.isDecrypted) {
|
||||
addToRewardMap(ancestorNote.title, 0.3);
|
||||
}
|
||||
|
@ -61,6 +79,12 @@ function buildRewardMap(note) {
|
|||
}
|
||||
|
||||
for (const attr of note.attributes) {
|
||||
if (attr.name.startsWith('child:')
|
||||
|| attr.name.startsWith('relation:')
|
||||
|| attr.name.startsWith('label:')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// inherited notes get small penalization
|
||||
const reward = note.noteId === attr.noteId ? 0.8 : 0.5;
|
||||
|
||||
|
@ -213,6 +237,12 @@ async function findSimilarNotes(noteId) {
|
|||
}
|
||||
|
||||
for (const attr of candidateNote.attributes) {
|
||||
if (attr.name.startsWith('child:')
|
||||
|| attr.name.startsWith('relation:')
|
||||
|| attr.name.startsWith('label:')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IGNORED_ATTR_NAMES.includes(attr.name)) {
|
||||
score += gatherRewards(attr.name);
|
||||
}
|
||||
|
@ -277,6 +307,16 @@ async function findSimilarNotes(noteId) {
|
|||
|
||||
results.sort((a, b) => a.score > b.score ? -1 : 1);
|
||||
|
||||
results.forEach(r => {
|
||||
const note = noteCache.notes[r.noteId];
|
||||
|
||||
if (!note.isDecrypted) {
|
||||
console.log(note.pojo);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(rewardMap);
|
||||
|
||||
return results.length > 200 ? results.slice(0, 200) : results;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue