[TxMt] Spell checking using Google

Hans-Joerg Bibiko bibiko at eva.mpg.de
Mon Apr 30 08:55:18 UTC 2007


Hi Andy,

very nice feature.

I have two tiny additions to that.

1)
How about to specify a variable TM_GSPELL_LANG to be able to set the  
input language (e.g. 'de' for German) for line:

Line 8: GOOG_PAGE = "/tbproxy/spell?lang=#{ENV["TM_GSPELL_LANG"]}&hl=en"


2)
If you query gsepll for e.g. German "Fähhre" it returns among others  
"F&#E4;hre". To decode this here my suggestion:

def mydecode(source)
	return source.gsub(/&#([0-9]{1,7});|&#x([0-9a-f]{1,6});/i) {
		$1 ? [$1.to_i].pack('U') : [$2.to_i(16)].pack('U')
	}
end

Unfortunately, Ruby is not my first language. Maybe you can add this.
For checking of a single word I did

...
tt=mydecode(t)
alts = t.split(/\t/)
...

this works, but for the multiple words checking - I have no idea ;(
Maybe it would work if one decode the body variable but this doesn't  
work for multiple words. I get the spelling suggestion 'Fe' for 'Fähhre'

Thanks,

Hans


More information about the textmate mailing list