Well,
Let me start of saying that I love Ruby on Rails. The syntax of the language, the possibilities, the speed at which you can develop. There's currently nothing that can beat it in my oppinion. Ask any Ruby on Rails developer and he will probably tell you the same.
However, what they don't tell you, is that it's becomming a serious pain over the years to get most things running on Windows machines. Alot of the gems that are beeing used either drop support for Windows systems, or never included it to begin with. And honestly it's starting to piss me off.
"Deploying Ruby on Rails is easy". Quoted literally from the Ruby on Rails page. Let me tell you, it's not !
The page lists various installations and tricks that can make the deployment of such an application seem like childsplay. Let's go over them shall we?
- Fusion Passenger Mod : No Windows Support --> Failed on the "easy" part
- Proxy Setups : Tried it and failed miserably. only NGINX got what I wanted
- JRuby : Not even going there...
I've been working with the rubygems system for quiet some time now. The system is simply marvelous, except for the flaw that alot of gems don't compile under Windows.
Now before you start jumping around talking about compilers etc:
- I have the Ruby DevKit installed and configured
- I have a complete msys minGW system setup with make etc, all working from commandline
The problem is that some gems cannot compile without alot of stuff installed beforehand or having specific requirements installed.
Are all gems bad then? No, definitly not. There's some out there that have great documentation of all the required gems that need to be installed and some even describe on which sources/libraries/applications need to be available to compile the gems.
Unfortunatly not all gems are like that. Some simply state they do not support Windows. Then i'm asking, what's the point of creating open-source projects that are supposed to be platform independant? I mean, that's the point of Ruby on Rails is it not?
Personal blog about small things from my life Occasionaly contains sharp and snappy comments about occurances in the world and technical stories related about my job.
Tuesday, May 10, 2011
Wednesday, April 13, 2011
RubyGems : Ankusa
Last 2 weeks, I've been working on a Ruby project for my company. The idea was to use semantic technology to allow the indexing of XML files and to classify these files depending on their content.
Because I was free to choose my implementation, and since I love working with Ruby on Rails and Ruby in general, I decided to work with Ruby scripts and various gems that would help me in creating the required scripts for the task at hand.
My first step was finding a gem that would allow me to index the files so they could be searched for keywords. Ferret is a nice little gem that allows indexing of text fragments. It was relatively easy for me to insert the contents of these XML files instead of the text fragments. Below is a snippet of code, written in pure Ruby that creates a new index with Ferret and stores some content in the files, depending on whether the content was correct or not
I know the display might not be ideal on the blog, but bear with it.
To allow the classification, I relied on the 'Classifier' gem first which can be found on rubygems.org, but this gem contained a really primitive implementation of the Bayes Classifier, and in the end I was forced to abandon it because it did not meet my requirements.
Then I stumbled across the Ankusa gem which actually performed nicely for what I needed to finish the task at hand.
However, this gem contained a flaw in the code. When certain words were analysed by the gem, a log(0) calculation occured, crashing the Ruby script. If you're not a math genius, the log calculation of 0 would result in minus infinite, which is not that easy to work with.
To solve this problem, I created a branch on GitHub that contains my fix and all other changes already implemented by other people that have worked on the Ankusa gem.
Now, I have a complete working script that indexes, analyzes and classifies XML files.
Because I was free to choose my implementation, and since I love working with Ruby on Rails and Ruby in general, I decided to work with Ruby scripts and various gems that would help me in creating the required scripts for the task at hand.
My first step was finding a gem that would allow me to index the files so they could be searched for keywords. Ferret is a nice little gem that allows indexing of text fragments. It was relatively easy for me to insert the contents of these XML files instead of the text fragments. Below is a snippet of code, written in pure Ruby that creates a new index with Ferret and stores some content in the files, depending on whether the content was correct or not
require 'rubygems'
require 'ferret'
require 'ankusa'
require 'ankusa/file_system_storage'
require 'rexml/document'
require 'fileutils'
include Ferret
file_list = Dir['input/*.xml']
unless file_list.empty?
puts 'The following XML files where discovered in the input directory:'
file_list.each_with_index { |f,i| puts "\t#{i}. #{File.basename f}"}
puts 'Press enter to continue with the script...'
gets
storage = Ankusa::FileSystemStorage.new 'core/data/storage.bin'
c = Ankusa::NaiveBayesClassifier.new(storage)
c.train :recipe, ""
c.train :unknown, ""
ferret = Ferret::Index::Index.new :default_input_field => :content,
:id_field => :content,
:path => 'core/data/index'
puts 'Processing files:'
file_list.each do |file|
xml = REXML::Document.new(File.open file, 'r')
content = xml.root.elements["normalize-space(//body/section/paragraph/text())"].to_s
title = xml.root.elements['//body/title/text()'].to_s
category = c.classify(content)
puts "#{File.basename file}"
puts "Category :: #{category}"
puts "Is this correct? [y/n]"
reply = false
reply = true if gets.strip.chomp.eql? 'y'
c.train :unknown, content if (!reply and category.eql? :recipe)
c.train :unknown, content if (reply and category.eql? :unknown)
c.train :recipe, content if(!reply and category.eql? :unknown)
c.train :recipe, content if (reply and category.eql? :recipe)
c.untrain :recipe, content if (!reply and category.eql? :recipe)
c.untrain :recipe, content if (!reply and category.eql? :unknown)
ferret << {:content => content, :title => title, :filename => File.basename(file)}
if ((category.eql?(:recipe) and reply) or (category.eql?(:unknown) and !reply))
FileUtils.move(file, 'output/recipes')
end
if ((category.eql?(:unknown) and reply) or (category.eql?(:recipe) and !reply))
FileUtils.move(file, 'output/unknown')
end
puts " #{File.basename file} processed..."
storage.save
end
else
puts 'No XML files discovered inside the input directory.'
end
I know the display might not be ideal on the blog, but bear with it.
To allow the classification, I relied on the 'Classifier' gem first which can be found on rubygems.org, but this gem contained a really primitive implementation of the Bayes Classifier, and in the end I was forced to abandon it because it did not meet my requirements.
Then I stumbled across the Ankusa gem which actually performed nicely for what I needed to finish the task at hand.
However, this gem contained a flaw in the code. When certain words were analysed by the gem, a log(0) calculation occured, crashing the Ruby script. If you're not a math genius, the log calculation of 0 would result in minus infinite, which is not that easy to work with.
To solve this problem, I created a branch on GitHub that contains my fix and all other changes already implemented by other people that have worked on the Ankusa gem.
Now, I have a complete working script that indexes, analyzes and classifies XML files.
Tuesday, March 8, 2011
Kingdom Hearts : Birth By Sleep
It's been a while since I've written a story again on my blog. But last weekend I bought myself a new game for the PSP (which has been collecting dust since last summer). I've been playing the Kingdom Hearts I & II on the Playstation 2, and I really enjoy the games.
Despite the fact the games mix in alot of elements from Disney, they also bring in the more mature elements from the Final Fantasy games. This unique mix, in an adventure game, is what makes me enjoy the games.
The opening trailer of Kingdom Hearts : Birth By Sleep is very similar to the hidden movie that was played at the end of Kingdom Hearts II:
Currently i'm playing the story of Terra, and I've entered the second world. There's not much to tell yet about the game for me, but right now I find it really challenging.
Playing on the "Normal" difficulty, the game seems to be more challenging then the original Kingdom Hearts games and actually allows more freedom as well in your character development.
The combination of merging abilities and selecting your own setup of abilities can make boss fights really trivial or really challenging.
Stay tuned for a more detailed review about the game once I've progressed further.
Subscribe to:
Posts (Atom)