Browse Source

highlight_delta() should work with trigrams

pull/24/head
Ben Kurtovic 12 years ago
parent
commit
fa16d5eff7
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      pages/copyvios.mako

+ 6
- 3
pages/copyvios.mako View File

@@ -95,7 +95,7 @@


def highlight_delta(chain, delta): def highlight_delta(chain, delta):
processed = [] processed = []
prev = chain.START
prev_prev = prev = chain.START
i = 0 i = 0
all_words = chain.text.split() all_words = chain.text.split()
paragraphs = chain.text.split("\n") paragraphs = chain.text.split("\n")
@@ -108,12 +108,15 @@
except IndexError: except IndexError:
next = chain.END next = chain.END
sword = strip_word(word) sword = strip_word(word)
before = prev in delta.chain and sword in delta.chain[prev]
after = sword in delta.chain and next in delta.chain[sword]
block = [prev_prev, prev] # Block for before
alock = [prev, sword] # Block for after
before = [block in delta.chain and sword in delta.chain[block]]
after = [alock in delta.chain and next in delta.chain[alock]]
is_first = i == 0 is_first = i == 0
is_last = i + 1 == len(all_words) is_last = i + 1 == len(all_words)
res = highlight_word(word, before, after, is_first, is_last) res = highlight_word(word, before, after, is_first, is_last)
processed_words.append(res) processed_words.append(res)
prev_prev = prev
prev = sword prev = sword
processed.append(u" ".join(processed_words)) processed.append(u" ".join(processed_words))
i += 1 i += 1


Loading…
Cancel
Save