I found this thread, IMHO the value of this script in research might have been overlooked…
The script is originally intended for single word OR for more complex regex. But I find that any simple phase with more than 2 words can also yield a pretty narrowed-down outcome. I modify the script a tiny bit to include the name of item for each hit, in which can be useful if wiki-link is enabled. There are much more modifications that can be made…
Disclaimer 1: experimental, can’t guarantee that it’s going to work!
Disclaimer 2: perhaps this function is already in DT2/3 and I simply has missed it!
The script could be useful in producing a more focused summary to a list of items after a search in main window, or user is looking for a more focused summary within a group of target literature.
(1) Entering a phrase in the inbox: users encounter a key concept/phrase and wanting to search and see how other literature use/mention/explain the concept/phrase.
(2) Entering an author or together with the year of publication in the inbox ( I am assuming all papers are in Harvard citation format in this experimental script): users want to see how a specific author/paper is being cited in other papers.
After the rtf file is opened, if wiki-link is enabled, and the search phrase is entered into the search field of the sidebar, phrase will be highlighted the summary and will also be shown in the original paper when u click on the wiki-link.
tell application id "DNtp"
try
set theSelection to the selection
if theSelection is {} then error "Please select some contents."
repeat
set regEx to display name editor "Summarize Items" info "Regular Expression:"
if regEx is not "" then exit repeat
end repeat
set theResult to ""
repeat with theRecord in theSelection
set theText to plain text of theRecord
-- set theLink to the aliases of theRecord -- show wikilink by aliaes
set theLink to the name of theRecord -- show wikilink by name
-- set theLink to (the reference URL of theRecord) -- show UUID of each item that get a maatch, but I am guessing the code has to be mmodified quite a bit for showing the UUID as link and this is not necessary if wiikilink is enabled anyway
try
set theSummary to do shell script "echo " & quoted form of theText & " | grep -i " & quoted form of regEx
set theSummary to quoted form of theSummary & return & theLink
set theResult to theResult & theSummary & return & return
end try
end repeat
set theResult to "Search Phrase: " & regEx & return & return & theResult & theSummary
if theResult is not "" then create record with {name:"The Summary with Phrase " & regEx, type:rtf, rich text:theResult} in current group
display alert "Processing completed" giving up after 1
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell