Hallo zusammen,
zur Automatisierung von Tags wurde schon verschiedentlich geschrieben.
Ich muss Dokumente nach einer Vielzahl von Stichworten auswerten und danach passende Tags einsetzen. Mit Hazel hat das nicht funktioniert, da PDF-Dateien oft in der Urform nicht durchsuchbar waren.
Ich habe nun eine Reihe von Regeln entworfen, welche die lesbar gemachten Dokumente auswerten und Tags einsetzen. Allerdings habe ich eine Konkordanzliste von derzeit rund 500 Schlagwörtern. Ich kann unmöglich 500 Regeln erstellen. Entweder gibt es eine Möglichkeit, mehrere Regeln in einer Art Master-regel zusammenzufassen oder etwas anderes.
Ich bin Journalist und bekomme täglich 100 Dokumente auf den Tisch, wobei sich die Themen ständig ändern.
In anderen Programmen kannte ich eine Konkordanzliste, die extern einfach als Textdatei angelegt und ständig erweitert wird. Auf die hat dass die Auswerte-Software zugegriffen. So etwas halte ich für meine Zwecke für passend.
Any ideas…?
1. Die Schlagwörter in einem Skript angeben (bzw. auf eine Datei verweisen). Achtung: “Test” würde auch vergeben wenn der Text nur “Testverfahren” enthält.
-- Set tags from keywords
property theKeywords : {"ABC", "Test", "lobortis", "maximus"} -- Set your keywords
on run
tell application id "DNtp" to my performSmartRule(selection as list)
end run
on performSmartRule(theRecords)
tell application id "DNtp"
try
repeat with thisRecord in theRecords
set thisRecord_Text to plain text of thisRecord
set thisRecord_Tags_updated to {}
repeat with thisKeyword in theKeywords
set thisKeyword to thisKeyword as string
if thisRecord_Text contains thisKeyword then
set end of thisRecord_Tags_updated to thisKeyword
end if
end repeat
set tags of thisRecord to (tags of thisRecord) & thisRecord_Tags_updated
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
end performSmartRule
2. Für Schlagwörter leere Tags erstellen und dann das mitgelieferte Smart Rule Skript Tags - Zuweisen (Assign Tags) nutzen. Im Skript muss die maximal gewünschte Tag-Anzahl angegeben werden.
Wie @pete31 richtig sagte: Die Schlagwörter extern speichern (sonst muss man ständig das Script anpassen) und im Script nur einlesen. “extern” kann natürlich auch ein Datensatz in DT sein. Du musst natürlich irgendeine Möglichkeit haben, am Inhalt des PDF die passenden Schlagwörter zu erkennen (oder ist das eine 1:1-Beziehung in dem Sinne “Wort kommt im Text vor”?).
“Master”-Regeln gibt es in DT nicht, weshalb man das Problem eben nur mit einem Script lösen kann.
Sieht schön kurz aus, allerdings habe ich von Skripten keine Ahnung und wüßte nicht, wie einen Befehl zum Auslesen einer Datei dort einfügen sollte. Das Skript von @chrillek überfordert mich haushoch…
Ein Schlagwort “Test” berücksichtigt nur noch exakt “Test”, also nicht mehr “Testverfahren” (und auch nicht “test”).
-- Set tags from keywords file
property theKeywordsFile_Path : "/Users/User/Desktop/theKeywords.txt" -- Set path to a file containg keywords delimited by a new line
on run
tell application id "DNtp" to my performSmartRule(selection as list)
end run
on performSmartRule(theRecords)
tell application id "DNtp"
try
set theKeywordsFile_Text to read theKeywordsFile_Path as «class utf8»
set theKeywords to paragraphs of theKeywordsFile_Text
considering case
repeat with thisRecord in theRecords
set thisRecord_Text to plain text of thisRecord
set thisRecord_Text_Words to words of thisRecord_Text
set thisRecord_Tags_updated to {}
repeat with thisKeyword in theKeywords
set thisKeyword to thisKeyword as string
if thisRecord_Text_Words contains thisKeyword then
set end of thisRecord_Tags_updated to thisKeyword
end if
end repeat
set tags of thisRecord to (tags of thisRecord) & thisRecord_Tags_updated
end repeat
end considering
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
end performSmartRule