jmignot Wrote:I tried but it returned an error in OSX
The command worked for me when I copied and pasted it from the post. If your shell is csh, try using bash instead. csh can be the default shell if you have a really old version of OS X or if you have upgraded from an old version of OS X.
Here's a Ruby script that should also work out of the box in (relatively new versions of) OS X:
edict = {}
IO.read("JMdict_e").scan(/<entry>.*?<\/entry>/m).each { |entry|
keb = entry[/(?<=<keb>).*(?=<\/keb>)/] || next
reb = entry[/(?<=<reb>).*(?=<\/reb>)/]
next if edict[keb]
gloss = entry[/(?<=<gloss>).*(?=<\/gloss>)/]
gloss = gloss.sub(/^(\([^)]+\) )*/, "").sub(/ \([^)]+\)$/, "")
edict[keb] = [reb, gloss]
}
IO.read("words.txt").split.each { |word|
reb, gloss = edict[word] || next
puts word + "\t" + reb + "\t" + gloss
}
You can run the script by for example saving it as jmdict.rb in the home folder, putting
http://ringtail.its.monash.edu.au/pub/nihongo/JMdict_e and words.txt in the home folder, and then running "ruby jmdict.rb" in Terminal.