Skip to content

Instantly share code, notes, and snippets.

@lguardiola
Created August 22, 2011 23:35
Show Gist options
  • Save lguardiola/1163920 to your computer and use it in GitHub Desktop.
Save lguardiola/1163920 to your computer and use it in GitHub Desktop.
pendiente de finalizacion funcional
LETRAS='áéíóúñüça-z'
LETRASM='ÁÉÍÓÚÑÜA-Z'
# Palabra Palabra|de|del
NOMBRES_PROPIOS_RE="(?:[#{LETRASM}][#{LETRAS}#{LETRASM}]{2,}(?:[ ,](?:[#{LETRASM}][#{LETRASM}#{LETRAS}]+|(?:(?:de|la|del)(?= [#{LETRASM}])))){1,})"
class Document
include Mongoid::Document
field :title, String
field :content, String
embeds_many :people
embeds_many :milestones
end
class Person
include Mongoid::Document
field :name, String
end
class Milestone
include Mongoid::Document
field :what, String
field :where, String
field :when, String
end
class Migrator
delegate :content, :people, :milestones, :to => :document
def initialize(document)
@document = document
end
def proccess
extract_people
extract_milestones
end
def extract_people
names = content.scan(Regexp.new("#{NOMBRES_PROPIOS_RE}"))
people = names.map do |name|
Person.new({:name => name})
end
end
def extract_milestones
found_milestones = # llamar a extraccion de milestones
milestones = found_milestones.map do |saraza|
Milestone.new(saraza)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment