Raramorph The Ruby Arabic Morphological Analyzer
September 14, 2008
Raramorph is a Ruby 1.9 gem for an intelligent port of Aramorph based on Buckwalter Arabic Morphological Analyzer Version 1.0 , Released By eSpace Technologies.
The first Release of Raramorph full morphological analyzer tools , provided with an executable or a library can be included in the code , with basic developer tools , to be extended in the next version.
Due to algorithmic and data structures optimization in Raramorph , we enhanced the performance of the library reaching an average of 4 – 5 seconds in loading the dictionaries which was the main bottleneck in the java raramorph reaching to 10-11 seconds and average of 2-3 seconds in parsing meduim sized files and printing the output file.
Installing Raramorph :
gem install raramorph ( note that raramorph requires Ruby1.9 )
Usage :
for exectuable :
raramorph input_file_name output_file_name -v -a -v verbose mode ( optional ) -a arabic output ( optional )
In Coding
require ‘raramorph’
For analyzing a file
Raramorph.execute(input_filename, output_filename ,verbose = false, not_arabic = true)
You can use functions like analyze_token , tokenize , segement_word all as static methods in Raramorph class , In the next Release developer tools will be more stable including more features for analysis and finding the morphological solutions , which can be used in searching and mining engines.
Also Raramorph -ferret adapter is to be released soon , for helping in the morphological analysis in search engines.
Raramorph Source Code is avaliable at :
http://github.com/espace/raramorph/tree/master
SystemVIPC now compatible with Ruby 1.8 and Ruby 1.9
September 9, 2008
SystemVIPC is a Ruby 1.8 module for System V Inter-Process Communication: message queues, semaphores, and shared memory.
eSpace Has released a version from SystemVIPC-0.8 RC1 that is compatible and works fine for Ruby 1.8 and Ruby 1.9
It’s really nice to work with SysVIPC with its simple used APIs , Here I’ll provide a simple tutorial for using SysVIPC Shared Memory.
Downloading and Installing
- Download SysVIPC Compatible Release for Ruby 1.8 , Ruby 1.9 at : http://github.com/espace/sysvipc-0.8-rc1.git
- Extract the Source , then run : ruby1.9 extconf.rb ( note : run with the ruby version you want ) then : make install Makefile
- You will have the sysvipc.so file appearing now
- In all cases you have to put these lines of code :
require ‘sysvipc.so’
include SystemVIPC
Shared Memroy Example
## Testing Shared Memory
- $key = ftok ‘/tmp/shm’ , IPC_CREAT
- $sh = SharedMemory.new($key, 33554432, IPC_CREAT | 0660)
- $sh.attach
- child = open(“|-“,”w+”)
- if child.nil?
- $sh.write(‘In Shared Memory’)
- sleep 2
- $sh.write(‘now showing you the world!’)
- else
- sleep 1
- puts $sh.read(100)
- sleep 3
- puts $sh.read(100)
- end
Lines 1 , 2 , 3 we convert the path name into as SysVIPC key , then we initiate if necessary 8 MegaBytes shared Memory Segment associated with key , then finally we attach the shared memory segment.
lines 4 , 5 we for a child for the process
At lines 6 , 8 we use the SharedMemory method write to write two data items to the shared memory segment
lines 11 , 13 the forked child process reads the data written by the parent process in the shared Memory segment and prints it.
sleep call is used for synchronizing the events..
Hope this is helpful….
View The SystemVIPC documentation at : http://sysvipc.rubyforge.org/
Push Server Technology in Ruby On Rails with Juggernaut
July 26, 2008
For an application that requires communication and interactive communication between the users , chatting is one of the most suitable to make you achieve this aspect . A lot of chatting programs are availiable , alot of chatting sites are availiable , but if you want to make a browser based chatting through your application , this might seem to be a little bit complicated.
The main problem is that , Our traditional browsers pulls the page from the server using requests and the server replies with a response , this model is not applicable to use in a browser based chatting application , as what is supposed to happen when client X send the data to client Y ? Client X sends the data to the server then the server pushs this data to client Y , In our traditional model the server can’t send the data to the browser without a request from the client , this puts to us limited choices to implement this , as periodically asking the server for new data which is not efficent and highly costing.
So what is the solution … ? PUSH SERVERS TECHNOLOGY
Push technology, or server push, describes a style of Internet-based communication where the request for a given transaction originates with the publisher or central server. It is contrasted with pull technology, where the request for the transmission of information originates with the receiver or client. A lot of Push Servers have been introduced .. I looked at most of them the most exceptional one , was the Flash Media Server But its not free for more than 10 connected users , and simply you can look at its price to know why its not feasible to be used by startups 🙂 …
So as working with Ruby On Rails , I searched for a neat Ruby On Rails solution , this was the result … Juggernaut Push Server Plugin . This was an excellent solution for me… However let’s take a look at Juggernaut.
Juggernaut is a push server written in Ruby , that can make your application interactively communicate with the server. Juggernaut uses flash objects , javascripts , rails code .
How does Juggernaut work ?
Juggernaut uses a flash object in the browser with a server socket , which makes juggernaut work on almost 90 % of the current browsers , as it only requires flash 8.
Juggernaut Consists of three main parts
- in-browser/client side elements
- a stand alone push server and
- Rails elements to tie everything together.
So this is a simple chat scenario….
- Browser connects to rails server , recieves the required javascripts , SWFs files ( Element 1 )
- The browser creates a flashXML socket with the push server ( used for listening ) ( Element 1 )
- The Client sends the data using AJAX method to a controller. ( Element 3 )
- Rails send the data to the push server using the Juggernaut plugin methods ( Element 3 )
- Juggernaut push server broadcasts the data to the channels ( Element 2 )
- Clients receive the new data using the flashXML socket and updates the dom elements with Javascript ( Element 1)
Juggernaut has different modes of operation , the data can be sent to a certain channel ( no. of users ) Or to a specific user .
Advantages of Juggernaut
- Allows a real time connection with a client – Rails can literally push javascript in real time to the client which is then evaluated.
- Using flash sockets allows us to use different port other than the rails application port , which helps us not to overload the application server with requests which may lead to crash the application , thats why we need a stand alone application server
- Push server – written in Ruby using EventMachine. EventMachine has a non-blocking IO so scales very well
- Integrated, as a plugin, into Rails.
- Subscribers can subscribe to multiple channels, and broadcasters can broadcast to multiple channels.
- Broadcasts can be made to channels, or to a specific client.
- Connect/Disconnect triggers.
- Authentication support.
- Uses Flash 8 – installed on more than 95% of computers.
- Supports all the major browsers (uses ExternalInterface): Firefox 1+, IE 6+ and Safari 2+
My friends and I made juggernaut plugin to add a secured chatting sessions to juggernaut using RSA or DES encryption algorithms , I’ll write a blog post about it soon.
So How can I use juggernaut..
This is a very good tutorial about installing and using Juggernaut in your application , it is quite straight forward in linux , but it has some problems in installation with windows and it solved here
Hope this was helpful
Control your Admin pages in Radiant applications
July 20, 2008
Radiant is a cool tool for managing the contents of a website , however many times you will feel that you need to need to customize things in Radiant , but its hard to do because of the radiant structure which makes the radiant code not visible directly to you , lack of documentation in creating extensions , but we can overcome by a simple way , which is trying to control the Radiant Page without editing the main Radiant gem Code through some Radiant and Rails Facilities.
I was working in a project where I needed to edit the ( pre-created add page ) view for the admin , to add in certain cases some buttons , links , page parts with new actions to be added . The solution is quite simple…
It is assumed that you have a fair knowledge with Radiant extensions to complete through the steps.
Steps :
1 – Appending code to a written action in the radiant controllers
- In the activate method in the x_extension.rb file in your extension folder , Open the controller you want to add the functions in , use the rails call back functions ( after_filter , before_filter ) to append the code to the required action
Admin::PageController.class_eval do
after_filter :this_is_a_function , :only => [:new , :edit ,:update]
private
def this_is_a_function
# do your code
end
end
2- After adding the back end code we need to put the display to this code in the Radiant page , we can use the radiant ( admin.page.edit , admin.tabs ) to append objects to specific regions in the page , this is the attributes the admin.page.edit object has , these attributes defines certain regions in the page , where Radiant uses these regions to divide the page . You are able to edit in any of these regions , under any conditions without affecting the existing Radiant gem
@regions={:form=>[“edit_title”, “edit_extended_metadata”, “edit_page_parts”], :form_bottom=>[“edit_buttons”], :parts_bottom=>[“edit_layout_and_type”, “edit_timestamp”], :main=>[“edit_header”, “edit_form”, “edit_popups”]}>
( admin.page.edit ) attributes
Example :
Add a button to the bottom of the form in case the page is having a certain page type ( Archive , normal , not found …) , Add a select list for the user to choose an element in the bottom part of the page
- Just add the following lines in your activate method in the x_extension.rb file
admin.page.edit.form_bottom << “add_button”
admin.page.edit.parts_bottom << “select”
In these two lines , we tell the radiant to add partials in the named regions ( form_bottom , parts_bottom ) to be render , as the regions are arrays of partials and the radiant renders the partials in the regions.
- The only remaining thing is to create the partials
A. create folder called admin and inside it add the page ( As we write the partials in the admin namespace )
B. Add the html code you want in the partials you want , you can add conditions inside the partials to make it rendered in some specific page claasses
3. You can add specific page parts to a certain class of pages by the same way of adding actions to controller , you can use the after_save call back and add some code to add a page parts to the page as follows :
Admin::Page.class_eval do
after_save :add_parts
def_add_parts
if this.class_name == “X”
this.parts << PagePart.new(:name=> “x” , :filter_id => “y” , :page_id=>this.id )
end
end
end
This will add a part for the class of pages you choose ..
Hope this will be helpful
Cooking PopCorn with Cell Phones !!!! Is This Possible ?
June 23, 2008
One of my friends sent me a link a couple of days for a youtube video showing some friends using their cell phones radiations to cook the kernel of popcorn (Video is in the bottom of the post ) , and actually they’ve done it !!!!! But What ? Is this possible?
The answer is no as i read in Wierd Blog;. They interviewed the University of Virginia physics professor Louis Bloomfield and this was his comment.
“[The videos] are cute,” said Bloomfield in a phone conversation . “But that’s never gonna happen.”
In a microwave oven, energy excites the water inside popcorn kernels until it turns into highly pressurized gas, causing the kernels to pop. If mobile phones emitted that much energy, the water in the fingers of people holding them would heat up.
“It would hurt like crazy,” Bloomfield said. “Cellphones probably warm your tissues, but studies indicate that’s not injurious.”
Bloomfield, author of How Everything Works: Making Physics Out of the Ordinary, dismissed theories bubbling up in comment threads about the videos that suggest harmonious vibrations are heating the corn.
“Ringing the phones doesn’t help because they’re interfering with each other and receiving a signal [from a cellphone tower] — not transmitting it,” he said. Furthermore, while it is possible to heat with sound, it’s not likely to happen at the low volume emitted by a mobile phone. “It would be like gathering opera singers together to sing, and trying to make the corn pop,” Bloomfield said.
He also said that the trick in the video they may had put a boiler below the table or stuff like this , but this is still weired …
I guess the guys weren’t doing this just as a trick or fun … May Be its a simple message about how HARMFUL the CELL PHONES are .. and how we are living in an electromagnetic field of waves …. living with us 🙂
May be some days with the more evolution in radio magnetic waves these side effects disappear .. OR may be cooking popcorn with cell phones will be true for our electromagnetic world we live IN ……
Here is the Video Watch And Enjoy 🙂