Home > All, Blog > test “google-code-prettify”

test “google-code-prettify”

April 3rd, 2007

官網:google-code-prettify

這裡看到的,似乎還有些問題。我原本是用Code Auto Escape,功能陽春但還過得去的plugin。先繼續用Code Auto Escape吧。

Ruby

test 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

test 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());
}

fcamel All, Blog

  1. April 3rd, 2007 at 16:25 | #1

    hi,

    看了一下你的原始碼,
    code要加上class=”prettyprint”才會作用,
    還是你有做其他修改呢?

  2. April 3rd, 2007 at 16:50 | #2

    我原本有加prettyprint,一度有成功一半,Ruby是好的,下面的Java爛了,所以後來又回頭用Code Auto Escape (Code Auto Escape也是用code tag),所以順便把class=”prettyprint”拿掉啦

    我想下次真的要貼code時,再來研究看是那個plugin或CSS和這功能衝到吧,謝謝提醒 :D

  1. No trackbacks yet.