Class: Rosette::Core::Phrase

Inherits:
Object
  • Object
show all
Includes:
PhraseIndexPolicy, PhraseToHash
Defined in:
lib/rosette/core/extractor/phrase.rb

Overview

Represents a phrase. Phrases are essentially text in some source language.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PhraseToHash

#to_h

Methods included from PhraseIndexPolicy

index_key, #index_key, index_value, #index_value

Constructor Details

#initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil) ⇒ Phrase

Creates a new phrase.


47
48
49
50
51
52
53
54
55
# File 'lib/rosette/core/extractor/phrase.rb', line 47

def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
  @key = key
  @meta_key = meta_key
  @file = file
  @commit_id = commit_id
  @author_name = author_name
  @author_email = author_email
  @line_number = line_number
end

Instance Attribute Details

#author_emailString


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosette/core/extractor/phrase.rb', line 26

class Phrase
  include PhraseIndexPolicy
  include PhraseToHash

  attr_reader :key, :meta_key
  attr_accessor :file, :commit_id
  attr_accessor :author_name, :author_email
  attr_accessor :line_number

  # Creates a new phrase.
  #
  # @param [String] key The phrase key.
  # @param [String] meta_key The phrase meta key.
  # @param [String] file The file this phrase was found in.
  # @param [String] commit_id The git commit id this phrase was found in.
  # @param [String] author_name The name of the person who git thinks
  #    created this phrase.
  # @param [String] author_email The email address of the person who git
  #   thinks created this phrase.
  # @param [Fixnum] line_number The line number in +file+ were this phrase
  #   was found.
  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
    @key = key
    @meta_key = meta_key
    @file = file
    @commit_id = commit_id
    @author_name = author_name
    @author_email = author_email
    @line_number = line_number
  end

  # Creates a phrase from a hash of attributes.
  #
  # @param [Hash] hash A hash of options containing +key+, +meta_key+,
  #   +file+, +commit_id+, +author_name+, +author_email+, and +line_number+.
  # @return [nil, Phrase] a phrase object created from +hash+. If +hash+
  #   is +nil+, returns +nil+.
  def self.from_h(hash)
    if hash
      new(
        hash[:key], hash[:meta_key],
        hash[:file], hash[:commit_id],
        hash[:author_name], hash[:author_email],
        hash[:line_number]
      )
    end
  end
end

#author_nameString


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosette/core/extractor/phrase.rb', line 26

class Phrase
  include PhraseIndexPolicy
  include PhraseToHash

  attr_reader :key, :meta_key
  attr_accessor :file, :commit_id
  attr_accessor :author_name, :author_email
  attr_accessor :line_number

  # Creates a new phrase.
  #
  # @param [String] key The phrase key.
  # @param [String] meta_key The phrase meta key.
  # @param [String] file The file this phrase was found in.
  # @param [String] commit_id The git commit id this phrase was found in.
  # @param [String] author_name The name of the person who git thinks
  #    created this phrase.
  # @param [String] author_email The email address of the person who git
  #   thinks created this phrase.
  # @param [Fixnum] line_number The line number in +file+ were this phrase
  #   was found.
  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
    @key = key
    @meta_key = meta_key
    @file = file
    @commit_id = commit_id
    @author_name = author_name
    @author_email = author_email
    @line_number = line_number
  end

  # Creates a phrase from a hash of attributes.
  #
  # @param [Hash] hash A hash of options containing +key+, +meta_key+,
  #   +file+, +commit_id+, +author_name+, +author_email+, and +line_number+.
  # @return [nil, Phrase] a phrase object created from +hash+. If +hash+
  #   is +nil+, returns +nil+.
  def self.from_h(hash)
    if hash
      new(
        hash[:key], hash[:meta_key],
        hash[:file], hash[:commit_id],
        hash[:author_name], hash[:author_email],
        hash[:line_number]
      )
    end
  end
end

#commit_idString


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosette/core/extractor/phrase.rb', line 26

class Phrase
  include PhraseIndexPolicy
  include PhraseToHash

  attr_reader :key, :meta_key
  attr_accessor :file, :commit_id
  attr_accessor :author_name, :author_email
  attr_accessor :line_number

  # Creates a new phrase.
  #
  # @param [String] key The phrase key.
  # @param [String] meta_key The phrase meta key.
  # @param [String] file The file this phrase was found in.
  # @param [String] commit_id The git commit id this phrase was found in.
  # @param [String] author_name The name of the person who git thinks
  #    created this phrase.
  # @param [String] author_email The email address of the person who git
  #   thinks created this phrase.
  # @param [Fixnum] line_number The line number in +file+ were this phrase
  #   was found.
  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
    @key = key
    @meta_key = meta_key
    @file = file
    @commit_id = commit_id
    @author_name = author_name
    @author_email = author_email
    @line_number = line_number
  end

  # Creates a phrase from a hash of attributes.
  #
  # @param [Hash] hash A hash of options containing +key+, +meta_key+,
  #   +file+, +commit_id+, +author_name+, +author_email+, and +line_number+.
  # @return [nil, Phrase] a phrase object created from +hash+. If +hash+
  #   is +nil+, returns +nil+.
  def self.from_h(hash)
    if hash
      new(
        hash[:key], hash[:meta_key],
        hash[:file], hash[:commit_id],
        hash[:author_name], hash[:author_email],
        hash[:line_number]
      )
    end
  end
end

#fileString


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosette/core/extractor/phrase.rb', line 26

class Phrase
  include PhraseIndexPolicy
  include PhraseToHash

  attr_reader :key, :meta_key
  attr_accessor :file, :commit_id
  attr_accessor :author_name, :author_email
  attr_accessor :line_number

  # Creates a new phrase.
  #
  # @param [String] key The phrase key.
  # @param [String] meta_key The phrase meta key.
  # @param [String] file The file this phrase was found in.
  # @param [String] commit_id The git commit id this phrase was found in.
  # @param [String] author_name The name of the person who git thinks
  #    created this phrase.
  # @param [String] author_email The email address of the person who git
  #   thinks created this phrase.
  # @param [Fixnum] line_number The line number in +file+ were this phrase
  #   was found.
  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
    @key = key
    @meta_key = meta_key
    @file = file
    @commit_id = commit_id
    @author_name = author_name
    @author_email = author_email
    @line_number = line_number
  end

  # Creates a phrase from a hash of attributes.
  #
  # @param [Hash] hash A hash of options containing +key+, +meta_key+,
  #   +file+, +commit_id+, +author_name+, +author_email+, and +line_number+.
  # @return [nil, Phrase] a phrase object created from +hash+. If +hash+
  #   is +nil+, returns +nil+.
  def self.from_h(hash)
    if hash
      new(
        hash[:key], hash[:meta_key],
        hash[:file], hash[:commit_id],
        hash[:author_name], hash[:author_email],
        hash[:line_number]
      )
    end
  end
end

#keyString (readonly)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosette/core/extractor/phrase.rb', line 26

class Phrase
  include PhraseIndexPolicy
  include PhraseToHash

  attr_reader :key, :meta_key
  attr_accessor :file, :commit_id
  attr_accessor :author_name, :author_email
  attr_accessor :line_number

  # Creates a new phrase.
  #
  # @param [String] key The phrase key.
  # @param [String] meta_key The phrase meta key.
  # @param [String] file The file this phrase was found in.
  # @param [String] commit_id The git commit id this phrase was found in.
  # @param [String] author_name The name of the person who git thinks
  #    created this phrase.
  # @param [String] author_email The email address of the person who git
  #   thinks created this phrase.
  # @param [Fixnum] line_number The line number in +file+ were this phrase
  #   was found.
  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
    @key = key
    @meta_key = meta_key
    @file = file
    @commit_id = commit_id
    @author_name = author_name
    @author_email = author_email
    @line_number = line_number
  end

  # Creates a phrase from a hash of attributes.
  #
  # @param [Hash] hash A hash of options containing +key+, +meta_key+,
  #   +file+, +commit_id+, +author_name+, +author_email+, and +line_number+.
  # @return [nil, Phrase] a phrase object created from +hash+. If +hash+
  #   is +nil+, returns +nil+.
  def self.from_h(hash)
    if hash
      new(
        hash[:key], hash[:meta_key],
        hash[:file], hash[:commit_id],
        hash[:author_name], hash[:author_email],
        hash[:line_number]
      )
    end
  end
end

#line_numberFixnum


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosette/core/extractor/phrase.rb', line 26

class Phrase
  include PhraseIndexPolicy
  include PhraseToHash

  attr_reader :key, :meta_key
  attr_accessor :file, :commit_id
  attr_accessor :author_name, :author_email
  attr_accessor :line_number

  # Creates a new phrase.
  #
  # @param [String] key The phrase key.
  # @param [String] meta_key The phrase meta key.
  # @param [String] file The file this phrase was found in.
  # @param [String] commit_id The git commit id this phrase was found in.
  # @param [String] author_name The name of the person who git thinks
  #    created this phrase.
  # @param [String] author_email The email address of the person who git
  #   thinks created this phrase.
  # @param [Fixnum] line_number The line number in +file+ were this phrase
  #   was found.
  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
    @key = key
    @meta_key = meta_key
    @file = file
    @commit_id = commit_id
    @author_name = author_name
    @author_email = author_email
    @line_number = line_number
  end

  # Creates a phrase from a hash of attributes.
  #
  # @param [Hash] hash A hash of options containing +key+, +meta_key+,
  #   +file+, +commit_id+, +author_name+, +author_email+, and +line_number+.
  # @return [nil, Phrase] a phrase object created from +hash+. If +hash+
  #   is +nil+, returns +nil+.
  def self.from_h(hash)
    if hash
      new(
        hash[:key], hash[:meta_key],
        hash[:file], hash[:commit_id],
        hash[:author_name], hash[:author_email],
        hash[:line_number]
      )
    end
  end
end

#meta_keyString (readonly)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosette/core/extractor/phrase.rb', line 26

class Phrase
  include PhraseIndexPolicy
  include PhraseToHash

  attr_reader :key, :meta_key
  attr_accessor :file, :commit_id
  attr_accessor :author_name, :author_email
  attr_accessor :line_number

  # Creates a new phrase.
  #
  # @param [String] key The phrase key.
  # @param [String] meta_key The phrase meta key.
  # @param [String] file The file this phrase was found in.
  # @param [String] commit_id The git commit id this phrase was found in.
  # @param [String] author_name The name of the person who git thinks
  #    created this phrase.
  # @param [String] author_email The email address of the person who git
  #   thinks created this phrase.
  # @param [Fixnum] line_number The line number in +file+ were this phrase
  #   was found.
  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
    @key = key
    @meta_key = meta_key
    @file = file
    @commit_id = commit_id
    @author_name = author_name
    @author_email = author_email
    @line_number = line_number
  end

  # Creates a phrase from a hash of attributes.
  #
  # @param [Hash] hash A hash of options containing +key+, +meta_key+,
  #   +file+, +commit_id+, +author_name+, +author_email+, and +line_number+.
  # @return [nil, Phrase] a phrase object created from +hash+. If +hash+
  #   is +nil+, returns +nil+.
  def self.from_h(hash)
    if hash
      new(
        hash[:key], hash[:meta_key],
        hash[:file], hash[:commit_id],
        hash[:author_name], hash[:author_email],
        hash[:line_number]
      )
    end
  end
end

Class Method Details

.from_h(hash) ⇒ nil, Phrase

Creates a phrase from a hash of attributes.


63
64
65
66
67
68
69
70
71
72
# File 'lib/rosette/core/extractor/phrase.rb', line 63

def self.from_h(hash)
  if hash
    new(
      hash[:key], hash[:meta_key],
      hash[:file], hash[:commit_id],
      hash[:author_name], hash[:author_email],
      hash[:line_number]
    )
  end
end