<commit_before># Description
#  A Netrunner info hubot
#
# Configuration:
#  None
#
# Commands:
#  hubot netrunner {query} - responds with card info from wikia and shows a url
#  hubot nrdb {card_attribute} {query} - responds with card info from netrunner db
#  hubot nrdb {card_attribute} {query} -l - responds with list of first 10 matches
#  hubot nrdb {card_attribute} {query} -n - responds with only card image, no text
#
# Author:
#  omardelarosa
#
_ = require('lodash')
util = require('util')

superscript_mappings =
  0: '\u2070'
  1: '\u00B9'
  2: '\u00B2'
  3: '\u00B3'
  4: '\u2074'
  5: '\u2075'
  6: '\u2076'
  7: '\u2077'
  8: '\u2078'
  9: '\u2079'

formatResponse = (bodyObj, url) ->
  text = "\n"
  if bodyObj["sections"]
    _.each bodyObj["sections"], (s) ->
      if s.title == "Sources"
        return
      text += s.title + "\n"
      if s.content
        _.each s.content, (c) ->
          if c.type == "paragraph"
            text += "\t" + c.text + "\n\n"
          if c.type == "list" and c.elements.length > 0
            _.each c.elements, (e) ->
              text += "\t" + e.text + "\n\n"
  text += url + "\n"
  return text

formatNRDBResponse = (msg, card, opts) ->
  text = "\n"
  text += "*Title*: #{card.title}\n"
  text += "*Faction*: #{
    if card.faction == 'Neutral'
      'Neutral'
    else ':' + (card.faction.toLowerCase().replace(/\s+/g,'_')) + ':'
  }\n"

  text += "*Type*: #{card.type} #{ if card.subtype then (' - ' + card.subtype) else '' }\n"
  if card.type == "Agenda"
    text += "*Adv/Pts*: #{card.advancementcost} \/#{card.agendapoints}\n"
  if card.type == "ICE" || card.type == "Upgrade" || card.type == "Asset"
    text += "*Rez Cost*: #{card.cost}\n"
    if card.type == "ICE"
      text += "*Strength*: #{card.strength}\n"
  
  if card.type == "Program" || card.type == "Resource" || card.type == "Hardware"
    text += "*Install Cost*: #{card.cost}\n"
    if /Icebreaker/i.test(card.subtype)
      text += "*Strength*: #{card.strength}\n"
  
  if card.type == "Operation" || card.type == "Event"
    text += "*Cost*: #{card.cost}\n"
  
  if card.type == "Identity"
    text += "*Minimum Deck Size*: #{card.minimumdecksize}\n"
    text += "*Influence Limit*: #{card.influencelimit}\n"

#add trash costs for assets and upgrades
  if card.type == "Asset" || card.type == "Upgrade"
    text += ":trash: : #{card.trash}\n"
  
  if typeof card.factioncost != 'undefined' and card.factioncost != 0
    text += "*Influence*: #{card.factioncost}\n"
  
  text += "*Set*: #{card.setname}\n"
  
  text += '*Text*: ' + card.text
    # Lowercase words between brackets and remove spaces
    .replace(
      /\[([\w\s]*)\]/g,
      (r) ->
        r.replace(/\s/g,'').toLowerCase()
    )
    # Wrap icons in Slack-friendly colons
    .replace(/[\[|\]]/g, ':')
    
    # Process superscripts for traces
    .replace(
      /<sup>(\d+)<\/sup>/,
      (match, p1) ->
        superscript = superscript_mappings[p1]
        if superscript
          return superscript<commit_msg>adds base link to runner IDs.<commit_after># Description
#  A Netrunner info hubot
#
# Configuration:
#  None
#
# Commands:
#  hubot netrunner {query} - responds with card info from wikia and shows a url
#  hubot nrdb {card_attribute} {query} - responds with card info from netrunner db
#  hubot nrdb {card_attribute} {query} -l - responds with list of first 10 matches
#  hubot nrdb {card_attribute} {query} -n - responds with only card image, no text
#
# Author:
#  omardelarosa
#
_ = require('lodash')
util = require('util')

superscript_mappings =
  0: '\u2070'
  1: '\u00B9'
  2: '\u00B2'
  3: '\u00B3'
  4: '\u2074'
  5: '\u2075'
  6: '\u2076'
  7: '\u2077'
  8: '\u2078'
  9: '\u2079'

formatResponse = (bodyObj, url) ->
  text = "\n"
  if bodyObj["sections"]
    _.each bodyObj["sections"], (s) ->
      if s.title == "Sources"
        return
      text += s.title + "\n"
      if s.content
        _.each s.content, (c) ->
          if c.type == "paragraph"
            text += "\t" + c.text + "\n\n"
          if c.type == "list" and c.elements.length > 0
            _.each c.elements, (e) ->
              text += "\t" + e.text + "\n\n"
  text += url + "\n"
  return text

formatNRDBResponse = (msg, card, opts) ->
  text = "\n"
  text += "*Title*: #{card.title}\n"
  text += "*Faction*: #{
    if card.faction == 'Neutral'
      'Neutral'
    else ':' + (card.faction.toLowerCase().replace(/\s+/g,'_')) + ':'
  }\n"

  text += "*Type*: #{card.type} #{ if card.subtype then (' - ' + card.subtype) else '' }\n"
  if card.type == "Agenda"
    text += "*Adv/Pts*: #{card.advancementcost} \/#{card.agendapoints}\n"
  if card.type == "ICE" || card.type == "Upgrade" || card.type == "Asset"
    text += "*Rez Cost*: #{card.cost}\n"
    if card.type == "ICE"
      text += "*Strength*: #{card.strength}\n"
  
  if card.type == "Program" || card.type == "Resource" || card.type == "Hardware"
    text += "*Install Cost*: #{card.cost}\n"
    if /Icebreaker/i.test(card.subtype)
      text += "*Strength*: #{card.strength}\n"
  
  if card.type == "Operation" || card.type == "Event"
    text += "*Cost*: #{card.cost}\n"
  
  if card.type == "Identity"
    text += "*Minimum Deck Size*: #{card.minimumdecksize}\n"
    text += "*Influence Limit*: #{card.influencelimit}\n"
    #add runner base link
    if card.baselink
      text += ":linknr: : #{card.baselink}\n"

#add trash costs for assets and upgrades
  if card.type == "Asset" || card.type == "Upgrade"
    text += ":trash: : #{card.trash}\n"
  
  if typeof card.factioncost != 'undefined' and card.factioncost != 0
    text += "*Influence*: #{card.factioncost}\n"
  
  text += "*Set*: #{card.setname}\n"
  
  text += '*Text*: ' + card.text
    # Lowercase words between brackets and remove spaces
    .replace(
      /\[([\w\s]*)\]/g,
      (r) ->
        r.replace(/\s/g,'').toLowerCase()
    )
    # Wrap icons in Slack-friendly colons
    .replace(/[\[|\]]/g, ':')
    
    # Process superscripts for traces
    .replace(
      /<sup>(\d+)<\/sup>/,
      (match, p1) ->
        superscript = superscript_mappings[p1]
        if superscript
          return superscript
{'fraction_non_alphanumeric': 0.19531631159538138, 'fraction_numerical': 0.01723857537811026, 'mean_word_length': 2.5324526134405514, 'pattern_counts': {'":': 3, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '879095', 'n_tokens_mistral': 2325, 'n_tokens_neox': 2239, 'n_words': 571}