def grep_meanings(html_element)
      acronym = html_element.css("acronym").first
      return unless acronym

      ru_word_class = acronym["title"]
      word_class = WORD_CLASSES[ru_word_class]
      translations = []

      html_element.css("ul > li").each do |tr|
        # a text line with translations separated by commas
        line = ""

        # use strong tag as an anchor
        strong = tr.css("strong").first
        if strong && strong.text =~ /\d+|[а-я]+\)/
          node = strong
          while(node = node.next_sibling)
            if node.text? || node.name == "a"
              text = node.text
              line << text unless text =~ /\(|\)/
            elsif ["em", "acronym"].include? node.name
              next
            else
              break
            end
          end
        end
        translations += words_from_line(line)
      end


      # sometimes there is only one meaning
      if translations.empty?
        if a_tag = html_element.css("span > a").first
          line = a_tag.text
        elsif span = html_element.css("span").first
          line = span.text
        elsif i_tag = html_element.xpath("i[2]")
          line = i_tag.text
        else
          return nil
        end
        translations = words_from_line(line)
      end

      self.translated[word_class] = translations.uniq
    end
def grep_meanings(html_element)
      acronym = html_element.css("acronym").first
      return unless acronym

      ru_word_class = acronym["title"]
      word_class = WORD_CLASSES[ru_word_class]
      translations = []

      html_element.css("ul > li").each do |tr|
        # a text line with translations separated by commas
        line = ""

        # use strong tag as an anchor
        strong = tr.css("strong").first
        if strong && strong.text =~ /\d+|[а-я]+\)/
          node = strong
          while(node = node.next_sibling)
            if node.text? || node.name == "a"
              text = node.text
              line << text unless text =~ /\(|\)/
            elsif ["em", "acronym"].include? node.name
              next
            else
              break
            end
          end
        end
        translations += words_from_line(line)
      end


      # sometimes there is only one meaning
      if translations.empty?
        if a_tag = html_element.css("span > a").first
          line = a_tag.text
        elsif span = html_element.css("span").first
          line = span.text
        elsif i_tag = html_element.xpath("i[2]")
          line = i_tag.text
        else
          return nil
        end
        translations = words_from_line(line)
      end

      self.translated[word_class] = translations.uniq
    end
TODO: refactor