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.

Parameters:

  • key (String)

    The phrase key.

  • meta_key (String) (defaults to: nil)

    The phrase meta key.

  • file (String) (defaults to: nil)

    The file this phrase was found in.

  • commit_id (String) (defaults to: nil)

    The git commit id this phrase was found in.

  • author_name (String) (defaults to: nil)

    The name of the person who git thinks created this phrase.

  • author_email (String) (defaults to: nil)

    The email address of the person who git thinks created this phrase.

  • line_number (Fixnum) (defaults to: nil)

    The line number in file were this phrase was found.


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

Returns the email address of the person who git thinks created this phrase.

Returns:

  • (String)

    the email address of the person who git thinks created this phrase.


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

Returns the name of the person who git thinks created this phrase.

Returns:

  • (String)

    the name of the person who git thinks created this phrase.


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

Returns the git commit id this phrase was found in.

Returns:

  • (String)

    the git commit id this phrase was found in.


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

Returns the file this phrase was found in.

Returns:

  • (String)

    the file this phrase was found in.


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)

Returns the phrase key.

Returns:

  • (String)

    the phrase key.


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

Returns the line number in file were this phrase was found.

Returns:

  • (Fixnum)

    the line number in file were this phrase was found.


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)

Returns the phrase meta key.

Returns:

  • (String)

    the phrase meta key.


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.

Parameters:

  • hash (Hash)

    A hash of options containing key, meta_key, file, commit_id, author_name, author_email, and line_number.

Returns:

  • (nil, Phrase)

    a phrase object created from hash. If hash is nil, returns nil.


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