#<html><pre>
# KEHOME/bin/printhi
# Aug/30/2003

# print OpenCyc concept hierarchy
# usage: printhi '#$name' verb ?;
#	CycL output format: ( c1 c2 ... )
#	final output format: one concept per line, sorted
# verb ::=
#	isa	# genls and isa
#	iss	# genls
#	isu	# isa
#	isa*	# all-genls and all-isa
#	iss*	# all-genls
#	isu*	# all-isa
#
#	isc	# specs and instances
#	isg	# specs
#	isp	# instances
#	isc*	# all-specs and all-instances
#	isg*	# all-specs
#	isp*	# all-instances
# Notes:
#	single quotes are required around concept name
#	to prevent shell from expanding $name.
# Examples:
#	printhi '#$Microtheory' isg;	# specs
#	printhi '#$Person' isa*;	# all-genls and all-isa

(
 sleep 30		# wait for opencyc startup
 echo "$1 $2 ?;"	# MKR question
 echo 'exit;'		# exit opencyc
)  |
mkr2cyc			|  # translate MKR to CycL
opencyc server 2>&1	|  # opencyc output including prompts and errors
sed 's/ /\n/g'		|  # change blank to newline
sed 's/(//g'		|  # delete leading (
sed 's/)//g'		|  # delete trailing )
grep '^#\$'		|  # begin with "#$"
grep -v '^#\$Person$'	|  # delete constant from startup examples
sort -uf		   # sort, delete duplicates

#</pre></html>
