2007年1月31日 星期三

WordPress Plugin:SyntaxHighlighter

官網

安裝、設定、使用都很容易,可是測試結果有問題,so sad。

Ruby

#!/usr/local/bin/ruby exit if ARGV.length < 2 # read stop words stop = File.new(ARGV[0]) stop_words = Hash.new() while line = stop.gets line.split.each { |e| stop_words[e] = 1} end stop.close # read text text = File.new(ARGV[1]) count = Hash.new(0) while line = text.gets line.split.each { |e| count[e] += 1 if stop_words[e] == nil } end text.close # dump results count.keys.each { |key| puts "#{count[key]} #{key}" }

Java

Table stopTable = buildStopWordTable(args[0]); // store String Table doc = new HashTableLL(); // store Count BufferedReader br = openFile(args[1]); String s; while ((s=br.readLine()) != null) { StringTokenizer stk = new StringTokenizer(s); while (stk.hasMoreTokens()) { s = stk.nextToken(); if (s.length() == 0 || stopTable.find(s) != null) continue; Count nc = new Count(s); Count c = (Count)doc.find(nc); if (c != null) c.count++; else { doc.add(nc); } } } br.close(); Iterator iterator = doc.getIterator(); while(iterator.hasNext()) { System.out.println(iterator.next()); }

沒有留言:

張貼留言