Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self.find_existing(domain, url_id)
- Article.where(web_domain:domain,url_id:url_id).first
- end
- def content_lines
- if @content_lines.nil?
- regular_exp = /(?: # Either match...
- 「.*」 # a quoted sentence
- | # or
- [^「」『』。?!]* # anything except quotes or dots.
- )+ # Repeat as needed
- [。?!]\s* # Then match a dot and optionally some whitespace.
- /x
- @content_lines = content.scan(regular_exp)
- @content_lines.each do |cl| cl.gsub!(/[[:space:]]/, ' ') end
- @content_lines.each(&:strip!)
- end
- @content_lines
- end
- before_create :build_lines
- def build_lines
- content_lines.each_with_index do |line, index|
- lines.build(text:line, line_number:index+1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement