Can the 'summary service' be used on the command line in Mac OS X?

I have already tried piping, using the text file as an argument and sending the text file as stdin.

link|improve this question
What were the commands you used to pipe the test file into the summary service? – fideli Dec 12 '09 at 14:16
cat textfile | $(locate SummaryService | grep MacOS | tail -1) – user21154 Dec 13 '09 at 10:49
Doesn't work for me. – Studer Feb 10 '10 at 15:08
feedback

3 Answers

Unfortunately without writing an application (AppleScript ObjC, or even a true Obj-C app) to interact with NSService, no. Even then Summary Service is exclusively a GUI application so it would bring up the GUI.

However some Services (if an Automator Workflow) can be run manually on the command line by using automator on the command line.

link|improve this answer
feedback

There's also an open text summarization library called libots that includes a command line "ots" executable that one can pipe to. Summary Service and OTS seem to give different results, in brief testing I'm not sure which one I would give higher marks.

link|improve this answer
feedback

Try this AppleScript (say it's called summarize.scpt) and call from the command line using "osascript summarize.scpt <n>" where n is the number of desired summary sentences. This works on OS X 10.6.7. Just pipe the content in.

on run argv
  set stdin to do shell script "cat"
  set stdout to summarize stdin in (item 1 of argv)
end run

Alternately, you could use a one liner something like this:

#!/bin/bash
osascript -e 'set stdin to do shell script "cat"' -e "set stdout to summarize stdin in $1"
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.