<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>aaron.harnly.net &#187; ruby</title>
	<atom:link href="http://harnly.net/category/blog/geek/lang/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://harnly.net</link>
	<description>Sì, abbiamo un'anima. Ma è fatta di tanti piccoli robot.</description>
	<pubDate>Fri, 05 Sep 2008 04:59:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
			<item>
		<title>NLTK&#8217;s &#8220;ing words&#8221;: variations</title>
		<link>http://harnly.net/2007/blog/geek/lang/ruby/nltks-ing-words-variations/</link>
		<comments>http://harnly.net/2007/blog/geek/lang/ruby/nltks-ing-words-variations/#comments</comments>
		<pubDate>Sun, 22 Apr 2007 13:36:23 +0000</pubDate>
		<dc:creator>aaronharnly</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://harnly.net/2007/blog/computers/ruby/nltks-ing-words-variations/</guid>
		<description><![CDATA[NLTK, the &#8220;natural language toolkit&#8221; for Python, is a wonderful lightweight framework that provides a wealth of NLP tools. The other day, in reading through its documentation, I came across a little appendix describing the advantages of Python for implementing and (especially) teaching NLP.

The authors show a simple sample program to find and list words [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nltk.sourceforge.net">NLTK, the &#8220;natural language toolkit&#8221;</a> for Python, is a wonderful lightweight framework that provides a wealth of NLP tools. The other day, in reading through its documentation, I came across a <a href="http://nltk.sourceforge.net/lite/doc/en/nlp-python.html">little appendix describing the advantages of Python</a> for implementing and (especially) teaching NLP.</p>

<p>The authors show a simple sample program to find and list words ending in &#8220;ing&#8221; from the standard input:</p>

<p><code>import sys
for line in sys.stdin.readlines():
    for word in line.split():
        if word.endswith('ing'):
            print word</code></p>

<p>and contrast this elegant Python implementation with a variety of monstrosities in other languages. I won&#8217;t disagree that the Python is nice, but it seemed like a good little exercise to see whether I can&#8217;t produce something almost as good in my languages de jour.</p>

<p>To wit, a Ruby version:
<code>for line in ARGF 
  for word in line.split
    if word.match(/ing$/) then
      puts word<br />
    end
  end
end
</code></p>

<p>which is almost identical to the Python version, though showing Ruby&#8217;s not-exactly-pretty fascination with the &#8216;end&#8217; keyword.</p>

<p>And a Scala version using for-comprehensions. Note to Scala creators: It&#8217;s really frustrating having the various ways of executing Scala &#8212; as a script, as an object, etc. &#8212; all disagree slightly on how the outermost wrapper of a procedure should be formatted. </p>

<p><code>import scala.io._
object IngWords extends Application {
   for (
      val line &lt;- Source.fromInputStream(System.in).getLines;
      val word &lt;- line.split(" ");
      word.endsWith("ing")
   ) 
  Console.println(word)<br />
}</code></p>

<p>(Aside: I need a decent syntax highlighting package for WP, it seems.)</p>
]]></content:encoded>
			<wfw:commentRss>http://harnly.net/2007/blog/geek/lang/ruby/nltks-ing-words-variations/feed/</wfw:commentRss>
		</item>
		<item>
		<title>NLTK&#8217;s &#8220;ing words&#8221;: variations</title>
		<link>http://harnly.net/2007/blog/geek/lang/ruby/nltks-ing-words-variations-2/</link>
		<comments>http://harnly.net/2007/blog/geek/lang/ruby/nltks-ing-words-variations-2/#comments</comments>
		<pubDate>Sun, 22 Apr 2007 13:36:23 +0000</pubDate>
		<dc:creator>aaronharnly</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://harnly.net/2007/blog/autobiography/nltks-ing-words-variations-2/</guid>
		<description><![CDATA[NLTK, the &#8220;natural language toolkit&#8221; for Python, is a wonderful lightweight framework that provides a wealth of NLP tools. The other day, in reading through its documentation, I came across a little appendix describing the advantages of Python for implementing and (especially) teaching NLP.

The authors show a simple sample program to find and list words [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nltk.sourceforge.net">NLTK, the &#8220;natural language toolkit&#8221;</a> for Python, is a wonderful lightweight framework that provides a wealth of NLP tools. The other day, in reading through its documentation, I came across a <a href="http://nltk.sourceforge.net/lite/doc/en/nlp-python.html">little appendix describing the advantages of Python</a> for implementing and (especially) teaching NLP.</p>

<p>The authors show a simple sample program to find and list words ending in &#8220;ing&#8221; from the standard input:</p>

<p><code>import sys
for line in sys.stdin.readlines():
    for word in line.split():
        if word.endswith('ing'):
            print word</code></p>

<p>and contrast this elegant Python implementation with a variety of monstrosities in other languages. I won&#8217;t disagree that the Python is nice, but it seemed like a good little exercise to see whether I can&#8217;t produce something almost as good in my languages de jour.</p>

<p>To wit, a Ruby version:
<code>for line in ARGF 
  for word in line.split
    if word.match(/ing$/) then
      puts word<br />
    end
  end
end
</code></p>

<p>which is almost identical to the Python version, though showing Ruby&#8217;s not-exactly-pretty fascination with the &#8216;end&#8217; keyword.</p>

<p>And a Scala version using for-comprehensions. Note to Scala creators: It&#8217;s really frustrating having the various ways of executing Scala &#8212; as a script, as an object, etc. &#8212; all disagree slightly on how the outermost wrapper of a procedure should be formatted. </p>

<p><code>import scala.io._
object IngWords extends Application {
   for (
      val line &lt;- Source.fromInputStream(System.in).getLines;
      val word &lt;- line.split(" ");
      word.endsWith("ing")
   ) 
  Console.println(word)<br />
}</code></p>

<p>(Aside: I need a decent syntax highlighting package for WP, it seems.)</p>
]]></content:encoded>
			<wfw:commentRss>http://harnly.net/2007/blog/geek/lang/ruby/nltks-ing-words-variations-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scala is my new Ruby</title>
		<link>http://harnly.net/2007/blog/geek/lang/ruby/scala-is-my-new-ruby/</link>
		<comments>http://harnly.net/2007/blog/geek/lang/ruby/scala-is-my-new-ruby/#comments</comments>
		<pubDate>Tue, 20 Mar 2007 00:36:40 +0000</pubDate>
		<dc:creator>aaronharnly</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://harnly.net/2007/blog/computers/ruby/scala-is-my-new-ruby/</guid>
		<description><![CDATA[Scala is my new Ruby, i.e. the language I love to tinker in. Rather more practical, too, as the fact that Ruby is dog-slow has gotten in the way of my work more than once recently.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.scala-lang.org/">Scala</a> is my new <a href="http://www.ruby-lang.org/">Ruby</a>, i.e. the language I love to tinker in. Rather more practical, too, as the fact that <a href="http://shootout.alioth.debian.org/debian/benchmark.php?test=all&amp;lang=ruby&amp;lang2=java">Ruby is dog-slow</a> has gotten in the way of my work more than once recently.</p>
]]></content:encoded>
			<wfw:commentRss>http://harnly.net/2007/blog/geek/lang/ruby/scala-is-my-new-ruby/feed/</wfw:commentRss>
		</item>
		<item>
		<title>From DTD to Rails Migrations</title>
		<link>http://harnly.net/2007/blog/geek/lang/ruby/from-dtd-to-rails-migrations/</link>
		<comments>http://harnly.net/2007/blog/geek/lang/ruby/from-dtd-to-rails-migrations/#comments</comments>
		<pubDate>Wed, 07 Mar 2007 21:29:06 +0000</pubDate>
		<dc:creator>aaronharnly</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://harnly.net/2007/blog/computers/ruby/from-dtd-to-rails-migrations/</guid>
		<description><![CDATA[In the category of tools that I want, but better not make right now, lest it turn into a &#8220;paroxysm of generalization&#8221;:

I have a DTD, describing a bunch of entities, their relationships, and their attributes. I&#8217;m going to push data from a set of XML files (adhering to said DTD) into a Ruby-on-Rails savvy database. [...]]]></description>
			<content:encoded><![CDATA[<p>In the category of tools that I want, but better not make right now, lest it turn into a &#8220;paroxysm of generalization&#8221;:</p>

<p>I have a DTD, describing a bunch of entities, their relationships, and their attributes. I&#8217;m going to push data from a set of XML files (adhering to said DTD) into a Ruby-on-Rails savvy database. Wouldn&#8217;t be nice to have a simple tool that, in the most general way possible, would, given that DTD:</p>

<ol>
<li><p>Issue a series of &#8217;script/general model Foo&#8217; commands for the various entities.</p></li>
<li><p>Populate the Rails migration files appropriately, to manage the creation of the database tables for these entities. That would include inserting :foo_id columns for has-many and has-and-belongs-to-many relationships (though differentiating between the two might require some human supervision), and exploiting the wonderful Red Hill Foreign Key Migrations to create appropriate FK constraints. </p></li>
<li><p>In addition / as an alternative to using the Red Hill plugin, insert the appropriate has_many / habtm declarations in the model files.</p></li>
<li><p>And finally, make a script that can read a set of such XML files and fill the database appropriately.</p></li>
</ol>

<p>Well, sounds nice to me, anyway. Put it on the someday-maybe list.</p>
]]></content:encoded>
			<wfw:commentRss>http://harnly.net/2007/blog/geek/lang/ruby/from-dtd-to-rails-migrations/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.517 seconds -->
