<commit_before>Tag = require '../tag'

#
# CommentaryTag links an *argument* with *commentary text*.
#
# The commentary text allows for analysis of an argument in a few paragraphs.
#
# @property [String] tagType The tag's type.
# @property [String] targetType The target object's type: 'argument'.
# @property [String] targetSha1 The target object's sha1 hash.
# @property [String] commentaryText The commentary text.
#
class CommentaryTag extends Tag

  ### Constructor ###

  # Inits a new CommentaryTag instance.
  #
  #     targetType = 'argument'
  #     targetSha1 = '0123456789abcdef000000000000000000000000'
  #     commentaryText = 'The commentary analysis, up to a few paragraphs...'
  #
  #     commentaryTag = new commentaryTag( targetType, targetSha1, commentaryTag )
  #
  # @api public
  # @param [String] targetType The target object's type.
  # @param [String] targetSha1 The target object's sha1 hash.
  # @param [String] commentaryText The commentary text.
  constructor: (@targetType, @targetSha1, @commentaryText) ->
    @tagType = 'commentary'

  ### Instance Methods ###

  #### Object Record ####
  #
  # Example usage:
  #
  #     record = tag.objectRecord()
  #
  # Commentary tag object records have the form:
  #
  #     tag
  #
  #     tag_type commentary
  #     target <target-type> <target-sha1>
  #     commentary_text <text>
  #
  # Example object record for commentary tag:
  #
  #     tag
  #
  #     tag_type commentary
  #     target argument 1a1a1a1a1a1a1a1a000000000000000000000000
  #     commentary_text The commentary analysis, up to a few paragraphs...
  #
  # @see Tag#objectRecord()

  #### Instance Field Validators ####

  # Validates fields for a commentary tag instance.
  #
  # Each overrides the corresponding Tag validator,
  # and throws an error on failure, or returns true on success.
  #
  # @api private
  # @throws ObjectValidationError
  # @return [Boolean] True only on success.
  #
  validateFields: () ->
    return @validateTagType() and @validateTarget() and @validateCommentaryText()

  validateTarget: () ->
    unless @targetType is 'argument'
      throw @Errors.ObjectValidation "Commentary target type must be 'argument'."

    return super()

module.exports = CommentaryTag<commit_msg>fix typo: missing 'new' keyword<commit_after>Tag = require '../tag'

#
# CommentaryTag links an *argument* with *commentary text*.
#
# The commentary text allows for analysis of an argument in a few paragraphs.
#
# @property [String] tagType The tag's type.
# @property [String] targetType The target object's type: 'argument'.
# @property [String] targetSha1 The target object's sha1 hash.
# @property [String] commentaryText The commentary text.
#
class CommentaryTag extends Tag

  ### Constructor ###

  # Inits a new CommentaryTag instance.
  #
  #     targetType = 'argument'
  #     targetSha1 = '0123456789abcdef000000000000000000000000'
  #     commentaryText = 'The commentary analysis, up to a few paragraphs...'
  #
  #     commentaryTag = new commentaryTag( targetType, targetSha1, commentaryTag )
  #
  # @api public
  # @param [String] targetType The target object's type.
  # @param [String] targetSha1 The target object's sha1 hash.
  # @param [String] commentaryText The commentary text.
  constructor: (@targetType, @targetSha1, @commentaryText) ->
    @tagType = 'commentary'

  ### Instance Methods ###

  #### Object Record ####
  #
  # Example usage:
  #
  #     record = tag.objectRecord()
  #
  # Commentary tag object records have the form:
  #
  #     tag
  #
  #     tag_type commentary
  #     target <target-type> <target-sha1>
  #     commentary_text <text>
  #
  # Example object record for commentary tag:
  #
  #     tag
  #
  #     tag_type commentary
  #     target argument 1a1a1a1a1a1a1a1a000000000000000000000000
  #     commentary_text The commentary analysis, up to a few paragraphs...
  #
  # @see Tag#objectRecord()

  #### Instance Field Validators ####

  # Validates fields for a commentary tag instance.
  #
  # Each overrides the corresponding Tag validator,
  # and throws an error on failure, or returns true on success.
  #
  # @api private
  # @throws ObjectValidationError
  # @return [Boolean] True only on success.
  #
  validateFields: () ->
    return @validateTagType() and @validateTarget() and @validateCommentaryText()

  validateTarget: () ->
    unless @targetType is 'argument'
      throw new @Errors.ObjectValidation "Commentary target type must be 'argument'."

    return super()

module.exports = CommentaryTag
{'fraction_non_alphanumeric': 0.10295414462081129, 'fraction_numerical': 0.03262786596119929, 'mean_word_length': 3.465551181102362, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6712763', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1325, 'n_words': 436}