1
이 코드를 건조하고 싶습니다. 나는 비록 어떻게 알아내는 것처럼 보일 수 없다.이 루비 코드를 마르는 방법
def get_all_verb_nodes
all_verb_nodes = @all_nodes_ins_del_nodes.select { |node|
previous_node = node.xpath('preceding-sibling::w:r').last
base_word = previous_node.text.split.last.strip.delete('.!?,:') if previous_node
words = get_node_text(node)
next_node = node.next_element
next_node_is_insert_or_delete = is_insert_or_delete?(next_node.name) if next_node
next_node_word = next_node.text.strip if next_node
words.length <= 2 && words.any? { |word| is_a_verb?(base_word+word) || is_a_verb?(word) && !is_pluralized?(base_word+word, base_word+next_node_word) } && !next_node_is_insert_or_delete
}
end
def get_all_article_nodes
all_article_nodes = @all_nodes_ins_del_nodes.select { |node|
previous_node = node.xpath('preceding-sibling::w:r').last
base_word = previous_node.text.split.last.strip.delete('.!?,:') if previous_node
words = get_node_text(node)
next_node = node.next_element
next_node_is_insert_or_delete = is_insert_or_delete?(next_node.name) if next_node
next_node_word = next_node.text.strip if next_node
words.length <= 2 && words.any? { |word| @articleset.include?(word) || (@articleset.include?(base_word) if word == 'n') } && [email protected]?(next_node_word) && !next_node_is_insert_or_delete
}
end
둘 다 기능의 특정 요구 사항을 정의하는 마지막 행을 제외하고 거의 동일합니다.
감사합니다.
주석으로 읽는 것이 매우 절차적이고보기가 힘들어 보이지만 'yield'라는 블록과 호출은 아마도 여기에 필요합니다. –