Posts Tagged ‘rails’

A nice, simple use of Rails helper methods

Friday, August 15th, 2008

I haven’t written many programming-related posts, but lately I’ve been spending a lot of time working on Green Fabric — a new website built with Ruby on Rails. I’ve been learning Rails as I go, and now I’m starting to feel like I really know what I’m doing. So, with that caveat, here’s my first Rails post:

I really like using proper typographical double quotes.  I use them in several places on Green Fabric, such as this page, which explains OpenID.  Look at the word, register.  Here’s how I do that elegantly.

1. My view template has this code:

Most people don't need to <%= quote_this 'register' %> here

2. My application_helper.rb file has this code:

  def ldquo
    '<span class="serif">&ldquo;</span>'
  end

  def rdquo
    '<span class="serif">&rdquo;</span>'
  end

  def quote_this(html_snippet)
    return ldquo() + html_snippet + rdquo()
  end

(In my css file, I’ve defined a “serif” class to set the font-face.) And that’s it!

Creating intelligent legal writing applications

Saturday, January 12th, 2008

screen-717420.pngI’m intrigued by the idea of applying artificial intelligence to law and legal writing. The ALWD Citation Manual is an amazing document that makes a great starting point for developing interesting applications: it’s highly organized and presents the information in a structured taxonomy of “rules”.I began to wonder what it’d take to write tools that’d help create legal citations as well as validate them? And so I’ve started a Ruby on Rails app that handles just one small part of the puzzle: correctly abbreviating words in a citation. Here’s the simple web app managing the database of abbreviations. You might recognize this as the start of the table at Appendix 3(E).And I’ve created the programming for applying the rules of Appendix 3(E):

>> Abbreviation.abbreviate 'Advance'
=> "Adv."
>> Abbreviation.abbreviate 'Advanced'
=> "Adv."
>> Abbreviation.abbreviate 'Advancing'
=> "Advancing"

So, this has been pretty interesting. Now I need to handle plurals well. This, though, means I’ll have to be able to identify plurals… but I have a couple of good ideas about how to do this.