2011-09-23

essidtop

In the spirit of all the *top tools, I wrote a little one for WiFi today. It's based on one I did earlier for measuring throughput using ipfw pipe counters, to see how much bandwidth things like streaming video and minecraft really take (answers: surprisingly little, and unsurprisingly a lot).

What I really need to do is abstract this out into a more generalized topify type of class, so that I can just write the data retrieval and data formatting functions, and then get a top-like auto-updating display out of it. This may only work on xterm, because it uses a specific control code to do the screen clear. This is much easier than installing and configuring the terminal control gems for ruby.

Usage: ./essidtop.rb wlan0. This will require root privileges, and you should probably change the #! line if your ruby is installed into someplace other than /usr/bin. Probably requires ruby 1.9 (because of the case statement).

#!/usr/bin/ruby

def get_stats(card)
	vals = {}

	cell = nil
	current = {
		:mac     => '??:??:??:??:??:??',
		:essid   => 'Unknown',
		:channel => '-1',
		:snratio => 0,
		:key     => '???'
	}

	%x[/usr/sbin/iwlist #{card} scan].each_line do |ln|
		ln.chomp!
		ln.gsub!(/^\s+/, '')
		ln.gsub!(/\s+$/, '')

		case ln
			when /^Cell ([[:digit:]]+) - Address: ([A-Fa-f[:digit:]:]+)$/ then
				unless (cell.nil?) then
					vals[cell] = current
					current = {
						:mac     => '??:??:??:??:??:??',
						:essid   => 'Unknown',
						:channel => '-1',
						:snratio => 0,
						:key     => '???'
					}
				end

				cell = $1
				current[:mac] = $2

			when /^ESSID:"(.*)"$/ then
				current[:essid] = $1

			when /^Channel:([[:digit:]]+)$/ then
				current[:channel] = $1

			when /^Quality=([[:digit:]]+)\/([[:digit:]]+)\s/ then
				current[:snratio] = (100 * ($1.to_f / $2.to_f)).to_i

			when /^Encryption key:(on|off)/ then
				current[:key] = $1

			else
				#puts "Unmatched: '#{ln}'"
		end
	end

	unless (cell.nil?) then
		vals[cell] = current
	end

	vals
end

card = ARGV[0]

loop do
	stats = get_stats card

	if ($stdout.isatty) then
		printf "\e[H\e[2J"
	end

	# foreach key in stats
	printf "Cell %-17s Ch SN Enc ESSID\n" % 'Mac'
	stats.each do |k,v|
		# print out line
		printf "%-4s %-17s %02d %02d %3s %s\n" % [k, v[:mac], v[:channel].to_i,v[:snratio], v[:key], v[:essid]]
	end

	sleep 10
end
:wq

2011-09-12

AI-generated News Articles

This article in the New York Times yesterday points out that machines are now generating summaries of sports games and financial data. StatSheet (now Automated Insights) has also been doing this for years, apparently. Comments of the singularity approaching abound...

My question is: is this really all that newsworthy?

Yes, it's a leap forward in AI-generated content. It reads fairly well, without the repetition and madlibs style of other generated content. But is it really all that different from what we've already been doing? Algorithmically, of course it is. But, merge-sort isn't any more an AI performing a sort than wait-sort. Sure, it's a faster (and, arguably better) algorithm, but it's still just a divide-and-conquer sorting algorithm. See also encryption: same problem; different algorithms to solve it.

What these companies have really done is taken sports and financial reporting and distilled them into an algorithm that works well in most cases. They're taking games with well defined and understood sets of rules, and analyzing past data to summarize them. It's no more approaching an AI singularity than the madlibs are. This isn't to belittle their success, but I doubt we'd be as impressed if they had these algorithms "sportscasting" checkers. I'm sure it could be done ("In a stunning 18th play move, black managed an astonishing triple-jump to retake the lead"), but it would just be an academic paper, not an industry.

So, the question of success becomes whether or not this is useful. The main two features of auto-generated news are timely reporting and SEO. Timely reporting seems to be a red herring for the sports world; if you care, you'll watch the game or listen to it on the radio. Having a summary up in under a minute is a neat trick, but it's only a side-show to the main event. Which leaves the arms race of SEO. Sure, good SEO is important, but it's only a matter of time until Google and Microsoft revise their algorithms to make these contributions less important. All it would take is making sure that content is generated in a "reasonable" amount of time for a human writer. Then the algorithm will have to have wait time added to it, and you lose the speed argument in favor of auto-generated content. At that point, this becomes solely a cost-cutting measure, and that's generally a race to the bottom. So, eventually we'll have companies pop up with madlib algorithms that are dirt cheap, and it's easy to see watching the game as a better use of time for consumers.

Get me an AI that can write a compelling Science Fiction novel and I'll start paying attention.

:wq