What does the compare method's content parameter do?

Intrigued by Classify not working, or I cant figure it out, I wanted to see if classification (or something like that) could be automated for bookmarks.

Obviously, I can’t use the classify method because a bookmark doesn’t have any content. But there’s compare, which takes a content parameter. So, my script downloads the HTML from the bookmark’s URL, gets the raw text and passes that as content. Example in JavaScript:

(() => {
  const app = Application("DEVONthink 3");
  app.selectedRecords().forEach(r => {
    const params = {
	record: r,
	};
	if (r.type() === "bookmark") {
	  params.content = app.getTextOf(app.downloadMarkupFrom(r.url()));
	}
	const targetList = app.compare(params);
  })
})()

However, the targetList is empty, although the “See also & classify” inspector shows several correct matches. That makes me wonder if the content parameter does anything in this case? Should it?

Disclaimer & bonus question: I did try the same with AppleScript and got the same non-result. But I couldn’t make this simple line work in AS:

set html to (download markup from (url of r))

where r refers to repeat with r in selected records. This line gives me

„«constant Ctyphtml»“ kann nicht als „«event DTpacd36» (URL of r)“ gesetzt werden. Zugriff nicht erlaubt.

on compilation.

Well, I don’t really know AppleScript, so I probably do something bad there – but what? If I pass a literal URL string, everything works ok (kind of, the compare result is empty, as I said).

Either the record or the content has to be specified.

Thanks, setting only content does indeed work.

Does compare use the same algorithm as classify, so that the location of the first element of the compare result would be equivalent to the first element of the classify result?

No. The location group of the first compare result is not necessarily identical to the first classify result.

That’s a shame :frowning: If the two results were similar, it would be easy to use compare as a replacement of classify for bookmarks. As it stands, classify can’t be passed a content parameter, so it can’t be used for bookmarks.

1 Like