Class: CommentAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/wikidata/diff/comment_analyzer.rb

Class Method Summary collapse

Class Method Details

.isolate_comment_differences(comment) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wikidata/diff/comment_analyzer.rb', line 2

def self.isolate_comment_differences(comment)
phrases = {
    'merge_to': 0,
    'merge_from': 0,
    'redirect': 0,
    'undo': 0,
    'restore': 0,
    'clear_item': 0,
    'create_item': 0,
}

if comment.nil?
    return phrases
end

if comment.include?('wbmergeitems-from')
    phrases[:merge_from] = 1
end

if comment.include?('wbmergeitems-to')
    phrases[:merge_to] = 1
end

if comment.include?('wbcreateredirect')
    phrases[:redirect] = 1
end

if comment.include?('undo:')
    phrases[:undo] = 1
end

if comment.include?('restore:')
    phrases[:restore] = 1
end

if comment.include?('wbeditentity-override')
    phrases[:clear_item] = 1
end

# create-property, create-item, create-lexeme all includes this phrase
# so based on content model in revision analyzer, it is decided which one it is
if comment.include?('wbeditentity-create')
    phrases[:create_item] = 1
end

return phrases
end