#!/usr/bin/perl -w

print "digraph words {\n";

while (defined($buf = <STDIN>)) {
	chomp($buf);

	$buf = lc($buf);

	# remove some punctuation
	$buf =~ tr/!"*,()?@//d; #"
	$buf =~ s/\. / /g;
	$buf =~ s/\.$/ /g;
	$buf =~ s/\.\.+//g;
	$buf =~ s/: / /g;

	# escape
	$buf =~ s/\\/\\\\/g;
#	$buf =~ s/\"/\\"/g;

	@parts = split(' ', $buf);
	shift(@parts);
	shift(@parts);
	shift(@parts);
	
	while (@parts && defined($parts[1])) {
		$lhs = $parts[0];
		$rhs = $parts[1];
		
		if (!defined($done{$lhs}{$rhs})) {
			printf("\t\"%s\" -> \"%s\";\n", $lhs, $rhs);
			$done{$lhs}{$rhs} = 1;
		}

		shift(@parts);
	}
	$buf = join(' ', @parts);
	
#	print "b:" . $buf . "\n";
}

print "}\n";
