Skip to content

Commit

Permalink
renamed tagged words to words in sentence scans
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkinsella committed Jan 28, 2012
1 parent e61b808 commit e0a1238
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 21 deletions.
4 changes: 0 additions & 4 deletions lib/style/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ def scan
end
end

def find_sentence(text)
@sentences.find {|sentence| sentence.text == text}
end

private

def convert_to_txt(input)
Expand Down
12 changes: 4 additions & 8 deletions lib/style/sentence_scans/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ def replacement_word(offending_word)
end

def tokenized_words
tagged_words.map(&:tokenized).reject {|word| word == ""}
words.map(&:tokenized).reject {|word| word == ""}
end

# We retokenize for the text case where no overall scanner is prepared
def tagged_words
@tagged_words ||= Tagger.new(sentence.text).tagged_words
def words
sentence.tagged_words
end

def next_word(word)
tagged_words.at(tagged_words.index(word) + 1)
words.at(words.index(word) + 1)
end

def next_significant_word(word)
Expand All @@ -42,10 +42,6 @@ def next_significant_word(word)
possible_word
end

def part_of_speech(code)
tagged_words.select {|tagged_word| tagged_word.tag == code }.map &:word
end

def already_has_that_problem_on_text(offending_text)
sentence.find_problems_by_type(problem_class).any? do |problem|
problem.on_text?(offending_text)
Expand Down
2 changes: 1 addition & 1 deletion lib/style/sentence_scans/capitalization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def scan
private

def first_word
tagged_words.first
words.first
end

def first_letter
Expand Down
10 changes: 5 additions & 5 deletions lib/style/sentence_scans/passive_tense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ class PassiveTense < Base

# heuristic: A "BE" verb follwed by a verb other than a gerund
def scan
passive = tagged_words.find do |tagged_word|
tagged_word.be_verb? && (! next_word(tagged_word).gerund_verb? ) && (! state_word?(tagged_word))
passive = words.find do |word|
word.be_verb? && (! next_word(word).gerund_verb? ) && (! state_word?(word))
end
create_problem(passive.word) if passive
create_problem(word.word) if passive
end

private

def state_word?(tagged_word)
word = next_significant_word(tagged_word)
def state_word?(word)
word = next_significant_word(word)
word.noun? || word.possessive?
end

Expand Down
2 changes: 1 addition & 1 deletion lib/style/sentence_scans/used_word_already_in_sentence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def scan
private

def repeated_words
tagged_words.select do |word|
words.select do |word|
appears_more_than_twice(word) && word.non_structural? && appears_non_consecutively(word.tokenized)
end.uniq
end
Expand Down
2 changes: 0 additions & 2 deletions readme.textile
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ h2. Roadmap
2 Refactor the collection methods.
4 More useless words.
5 Troublesome words from Stunk.
6 Refactor i.e. to use tokenized stuff.
7 Refactor next word stuff.
8 Tense switches
9 Improve tests by:
a Creating a sentence helper
Expand Down

0 comments on commit e0a1238

Please sign in to comment.