<commit_before># parse a command string into a command object:
# e.g.
#
# "put book on table" ->
#   verb: 'put'
#   do:   'book'
#   prep: 'on'
#   io:   'table'
#
# "look" ->
#   verb: 'look'
#   do:   null
#   prep: null
#   io:   null

# "take yellow bird" ->
#   verb: 'take'
#   do:   'yellow bird'
#   prep: null
#   io:   null

# "put yellow bird in cuckoo clock" ->
#   verb: 'put'
#   do:   'yellow bird'
#   prep: 'in'
#   io:   'cuckoo clock'

# warning: prepositions containing other prepositions as
# substrings (using word boundaries) must precede them.
# e.g. 'on top of' comes before 'on', but 'onto' doesn't have to precede 'on'.
prepositions = [
  'with', 'using',
  'at', 'to',
  'in front of',
  'in', 'inside', 'into',
  'on top of', 'on', 'onto', 'upon',
  'out of', 'from inside', 'from',
  'over',
  'through',
  'under', 'underneath', 'beneath',
  'behind',
  'beside',
  'for', 'about',
  'is',
  'as',
  'off of', 'off'
]

prepex = new RegExp '\\b(' + prepositions.join('|') + ')\\b'

sanitize = (text) -> text.trim().replace /\s+/g, ' '

specials = [
  { pattern: /^\/(?!\/)(\s*)/, verb: 'say' },
  { pattern: /^\/\/(\s*)/, verb: 'emote' },
  { pattern: /^\?(\s*)/, verb: 'eval' },
]

replaceSpecials = (text) ->
  for special in specials
    if text.match special.pattern
      text = text.replace special.pattern, special.verb + ' '
      break
  text

# return [first_word, rest]
chomp = (s) ->
  i = s.indexOf(' ')
  if i != -1
    [s[0..i-1], s[i+1..-1]]
  else
    [s, undefined]

parse_preposition = (text) ->
  search = text.match prepex
  if search?<commit_msg>Simple profanity filter for fun.<commit_after># parse a command string into a command object:
# e.g.
#
# "put book on table" ->
#   verb: 'put'
#   do:   'book'
#   prep: 'on'
#   io:   'table'
#
# "look" ->
#   verb: 'look'
#   do:   null
#   prep: null
#   io:   null

# "take yellow bird" ->
#   verb: 'take'
#   do:   'yellow bird'
#   prep: null
#   io:   null

# "put yellow bird in cuckoo clock" ->
#   verb: 'put'
#   do:   'yellow bird'
#   prep: 'in'
#   io:   'cuckoo clock'

# warning: prepositions containing other prepositions as
# substrings (using word boundaries) must precede them.
# e.g. 'on top of' comes before 'on', but 'onto' doesn't have to precede 'on'.
prepositions = [
  'with', 'using',
  'at', 'to',
  'in front of',
  'in', 'inside', 'into',
  'on top of', 'on', 'onto', 'upon',
  'out of', 'from inside', 'from',
  'over',
  'through',
  'under', 'underneath', 'beneath',
  'behind',
  'beside',
  'for', 'about',
  'is',
  'as',
  'off of', 'off'
]

prepex = new RegExp '\\b(' + prepositions.join('|') + ')\\b'

sanitize = (text) -> text.trim().replace /\s+/g, ' '

specials = [
  { pattern: /^\/(?!\/)(\s*)/, replacement: 'say ' },
  { pattern: /^\/\/(\s*)/, replacement: 'emote ' },
  { pattern: /^\?(\s*)/, replacement: 'eval ' },
  { pattern: /\b(ass|tit|fag|vag)\b/, replacement: '***' },
  { pattern: /\b(shit|fuck|tits|cock|dick|boob|fags|cunt)\b/, replacement: '****' },
  { pattern: /\b(shits|fucks|bitch|penis|cocks|dicks|boobs|cunts)\b/, replacement: '*****' },
  { pattern: /\b(faggot|vagina)\b/, replacement: '******' },
  { pattern: /\b(faggots|bitches)\b/, replacement: '*******' },
]

replaceSpecials = (text) ->
  for special in specials
    if text.match special.pattern
      text = text.replace special.pattern, special.replacement
  text

# return [first_word, rest]
chomp = (s) ->
  i = s.indexOf(' ')
  if i != -1
    [s[0..i-1], s[i+1..-1]]
  else
    [s, undefined]

parse_preposition = (text) ->
  search = text.match prepex
  if search?
{'fraction_non_alphanumeric': 0.223149693934335, 'fraction_numerical': 0.0027824151363383415, 'mean_word_length': 2.894907908992416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '1409561', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1430, 'n_words': 381}