File size: 11,855 Bytes
16bd001
 
8ae426c
 
e003ecd
7206bee
 
6ac0745
 
 
7206bee
 
16bd001
fe0714b
 
 
 
16bd001
fe0714b
16bd001
 
 
 
 
fe0714b
 
 
 
16bd001
fe0714b
16bd001
 
1a41ae7
16bd001
 
 
 
c42b837
16bd001
 
 
 
13ee459
df5479f
16bd001
87eba1e
c42b837
13ee459
16bd001
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1a41ae7
16bd001
 
 
 
 
 
 
 
 
ad27253
e035f7f
fb008a2
16bd001
 
 
 
 
 
 
 
 
 
 
13ee459
df5479f
16bd001
 
 
87eba1e
13ee459
 
16bd001
 
 
 
 
 
 
ad27253
16bd001
 
 
 
 
 
 
 
 
87eba1e
16bd001
 
e035f7f
 
 
 
 
87eba1e
e035f7f
d57d5ce
 
 
 
 
 
 
16bd001
 
 
 
 
 
 
 
 
 
 
273d07c
46f5b11
d57d5ce
46f5b11
9ba259f
46f5b11
 
 
 
 
 
13ee459
 
 
 
 
c9591df
d57d5ce
9da760f
 
 
 
 
 
16bd001
 
 
 
 
 
 
 
d57d5ce
16bd001
d57d5ce
16bd001
 
 
 
 
 
d57d5ce
 
16bd001
 
1d5e5e8
 
 
e3c105a
1d5e5e8
 
e3c105a
1d5e5e8
16bd001
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83b771d
16bd001
83b771d
1a41ae7
9da760f
1a41ae7
fe0714b
1a41ae7
 
fe0714b
 
 
 
 
 
 
 
 
 
 
9da760f
fe0714b
 
15bb5c9
fe0714b
 
9da760f
 
 
 
 
 
 
 
15bb5c9
9da760f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0714b
1a41ae7
fe0714b
1a41ae7
 
fe0714b
 
 
 
 
 
 
 
 
 
c9591df
fe0714b
1a41ae7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: Bluemoon
description: "Bluemoon 1-1 Fandom RP+ERP cleaned and formatted for Fastchat"
build:
  conversationBatch: 100
  cleanDirectory: [ 'out/*' ]
  verifyRequirements: false
  verifyArtifacts: true
  sendPackedFiles: true
  gzipRemotePackedFiles: true
  gzipLocalPackedFiles: false
  #concurrency:
  #  local: 16

_input_steps:
  - step: &bluemoon
      type: CsvInput
      sync: main
      config:
        path: "data/rentry/bluemoon/bluemoon-fanbased-roleplays-1x1.csv"
        fields:
          conversation: 'thread_href'
          from: 'message_username'
          message: 'message'

_output_steps:
  - step: &bluemoon_fastchat
      type: FastChatOutput
      sync: main
      config:
        path: "out/bluemoon.json"
        indent: 2

_debug_steps:
  - step: &extract_ooc
      type: RegexExtract
      description: "Extract OOC matches for examination"
      config:
        path: 'out/ooc_%worker%.txt'
        dotAll: true
        multiLine: true
        escape: true
        patterns: [
          '\{.*\}', '\[.*?\]', '\(\(.*?(\)|\W)\)+', '^\(.*?\){1}', '\([^\(]+\)$',
          '(OOC|ooc|OoC|OCC|ooc|Ooc)(:| |-|;)\n?.*?(\n|$)',
          '(\n\nSee more|See more\n\n)', '^(RE|Re):.*?\n', '^NSFW:.*?\n$',
          '^Note to everyone.*\)\)\n', '_*Author.*\n*_',
          'x{3,}.*TEST?x*', '^- Let me.*-', '^.*\^\^;.*\){1}',
          '^As the title suggests.*Littleton.', '^.*\)\)\n'
        ]

  - step: &extract_links
      type: RegexExtract
      description: "Extract links for examination."
      config:
        path: 'out/links.txt'
        escape: true
        overwrite: true
        patterns: [
          '\[img|video.*\[\/img|video\]+',
          'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
        ]

  - step: &extract_trim_nonwords
      type: RegexExtract
      description: "Extract leading non-word data for examination."
      config:
        path: 'out/trim-nonwords.txt'
        dotAll: true
        multiLine: true
        escape: true
        overwrite: true
        patterns: [
          '^(-|,|\||\.|=|_|])\W*(s|\W)+\W(\b|\n)',
          '^([w_=x]{5,}|~\+\+~)(\b|\n)',
          '^(_|])+(\b|\n)', '^(\s|\.|,|\|)+'
        ]

_steps:
  - step: &html_linebreaks
      type: ExactReplace
      description: "Convert html <br/> line breaks to \n"
      config:
        replacements: [ [ '<br/>', "\n" ] ]

  - step: &html_strip
      type: HtmlStrip
      description: "Strip HTML"
      config:
        stripAnchorPatterns: [ '/', '.jpg', '.JPG', '.png', '.PNG', '.gif', '.GIF' ]
        stripDom: [ 'blockquote.bbCodeBlock' ]

  - step: &ooc_strip
      type: RegexReplace
      description: "Strip OOC content and some HTML errors."
      config:
        dotAll: true
        multiLine: true
        replacements: [
          # This might be a bit overzealous.
          [ '\{.*\}', "" ], [ '\[.*?\]', "" ], [ '\(\(.*?(\)|\W)\)+', "" ],
          # Match for (...) but only at the beginning and end of messages.
          [ '^\(.*?\){1}', "" ],  [ '\([^\(]+\)$', "" ],
          [ '(OOC|ooc|OoC|OCC|ooc|Ooc)(:| |-|;)\n?.*?(\n|$)', "" ],
          [ '(\n\nSee more|See more\n\n)', "" ], [ '^(RE|Re):.*?\n', "" ], [ '^NSFW:.*?\n$', "" ],
          # More author's notes and the like
          [ '^Note to everyone.*\)\)\n', "" ], [ '_*Author.*\n*_', "" ],
          [ 'x{3,}.*TEST?x*', "" ], [ '^- Let me.*-', "" ], [ '^.*\^\^;.*\){1}', "" ],
          [ '^As the title suggests.*Littleton.', "" ],
          [ '^.*\)\)\n', "" ]
        ]

  - step: &links
      type: RegexReplace
      description: "Remove all links"
      config:
        replacements: [
          [ '\[(img|video).*\].*\[(\/img|video)\]', "" ],
          [ '[hH]ttp[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', "" ]
        ]

  - step: &reduce_whitespace
      type: ExactReplace
      description: "Reduce standalone tabs that do not affect formatting, and newlines to maximum of two consecutive."
      config:
        recursive: true
        replacements: [
          [ "\t\n", "\n" ], [ "\n\n\n", "\n\n" ], [ '  ', ' ' ], [ " \n", "\n" ]
        ]

  - step: &reduce_separators
      type: ExactReplace
      description: "Reduce nonsensical separators to a maximum of 3 consecutive."
      config:
        recursive: true
        replacements: [ [ "~~~~", "~~~" ], [ "----", "---" ], [ "<>", "*" ], [ "****", "***" ], [ ".....", "...." ] ]

  - step: &reduce_punctuation
      type: ExactReplace
      description: "Reduce excessive punctuation"
      config:
        recursive: true
        replacements: [ [ "!!!!", "!!!" ], [ "????", "???" ], [ "?!?!?!", "?!?!" ], [ "!?!?!?", "!?!?" ] ]

  - step: &trim
      type: Trim
      description: "Trim leading and trailing whitespace."

  - step: &ooc_prune
      type: FullMatch
      description: "Prune fully OOC messages with known content."
      config:
        action: drop
        caseSensitive: false
        patterns: [
          "BUMP", "-BUMP-", "~BUMP~", "Closed...", "Closed", "Closed\n\n...", "This thread is closed", "bump.", "*DELETED*",
          "...", "Okay... so you didn't make a starting post??", "---", "~~~",
          "The End ^^\nshortest RP ever XDD", "the end^^", "i think so^^", "Fin^^", "Fin ^^", "-Placeholder-", "Molly was",
          "Hahahaha, Yeah, I was a little confused",
          "Lol do you want to delted this thread possibly and start a new one I'm sorry",
          "Sure, what ever you want!", "How about a demon/human what do you want the plot to be and if you could start it",
          "Okay, do you want to be the demon, or do you want me to be the demon?", "You be the demon", "Okay, do you want to start today or tomorrow?",
          "Today if possible and what's the plot", "Hmmmmm I have no idea hahahaha you?", "Hmmm demon falls for a human even though he ain't supposed to",
          "Ok, sounds good! Anything else you want in?",
          "Not really maybe demon fight\n\nAnd that the demon has to shroud him self in human form and reveals himself to her",
          "Okay, I'll make it a bit later.", "Okay can't wait",
          "THIS RP IS OFFICIALLY CLOSED NO FURTHER POSTS WILL BE POSTED AS I HAVE LOST INTEREST IN THE PLOT SORRY FOR THE LOSSES",
          # TODO Do some whitespace reduction before post.
          "This is a Supernatural Fandom Romance RP between Dean Winchester and Castiel the angel. \n\nWARNING! CONTAINS HOMOSEXUAL CONTENT! IF YOU'RE HOMOPHOBIC, GO AWAY!",
          "\n\nThis will be a one x one between myself and Iikaitlynii based off the AMC television series The Walking Dead​",
          "Well I doubt he is going to be able to contact me if he is banned....can somebody please tell me why he got banned? I was just rping with him and he role plays well and then I saw he got banned for Ban-Evasion but what exactly was he doing to get banned?",
          "title or something idk", "Geralt = \n\nDandelion = "
        ]
  - step: &strip_usernames
      type: ExactReplace
      pack: [ 'pack/gen/usernames.csv' ]
      config:
        caseSensitive: true
        packedReplacements: [ 'pack/gen/usernames.csv' ]

  - step: &strip_unicode
      type: Encoding
      description: "Strip unicode sequences not present in ascii. This doesn't affect output encoding."
      config:
        invalid: ""
        codec: us-ascii

  - step: &strip_nonwords
      type: RegexReplace
      description: "Consecutive non-word characters"
      config:
        dotAll: true
        multiLine: true
        replacements: [
          [ '^(-|,|\||\.|=|_|])\W*(s|\W)+\W(\b|\n)', "" ],
          [ '^([w_=x]{5,}|~\+\+~)(\b|\n)', "" ],
          [ '^(_|])+(\b|\n)', "" ], [ '^(\s|\.|,|\|)+', "" ],
          [ '([^a-zA-Z0-9 !?\.])\1{4,}', "" ],
        ]

  - step: &spelling
      type: ExactReplace
      description: "Spelling mistakes and typos."
      pack: [ 'pack/spelling.csv' ]
      config:
        caseSensitive: false
        packedReplacements: [ 'pack/spelling.csv' ]

  - step: &empty
      type: FullMatch
      description: "Drop empty messages."
      config:
        action: drop
        patterns: [ "" ]

  - step: &two_alternating_participants
      type: Participants
      description: "Require exactly 2 alternating participants"
      config:
        min: 2
        max: 2
        alternating: true

  - step: &rename_participants
      type: RenameParticipants
      description: "Rename participants to their conversation roles."
      config:
        names: [ "human", "gpt" ]

  - step: &edge_cases
      type: ExactReplace
      description: "Remove a few edge cases."
      pack: [ 'pack/edge_cases.csv' ]
      config:
        packedReplacements: [ 'pack/edge_cases.csv' ]
_passes:
  # Collect all usernames from source data
  - pass: &usernames
      required:
        - path: "data/rentry/bluemoon/bluemoon-fanbased-roleplays-1x1.csv"
          sha512: f31d6bd278bc4211736d6aace3917cd0c1d0143bec9bf9d07054f5f9b32060e17399b6ea0935774b2271ac45a88309a60ef8eec8c4ac5283d1b353a255529cc5
      steps:
        - *bluemoon
        - type: CsvOutput
          description: "Extract usernames"
          config:
            path: 'out/usernames_%worker%.csv'
            ignoreDuplicates: true
            fields: [ 'from' ]
        - type: FileConcatenate
          sync: main
          config:
            path: 'pack/gen/usernames_all.csv'
            files: [ 'out/usernames_*.csv' ]
            ignoreDuplicateLines: true
            eol: "\r\n"
            delete: true
      artifacts:
        - file: 'pack/gen/usernames_all.csv'
          sha512: ffcc8aa980f4d8b0cace9092280d07215337cc316cb3fa45742a5f5a735d21a31f581d27884a414df21ac99616d14c7ebec1ab68a5766c10faa4b1564ceb7c20


  # Count the occurrences of usernames in messages in the source data
  - pass: &count_usernames
      required:
        - path: "pack/gen/usernames_all.csv"
          sha512: ffcc8aa980f4d8b0cace9092280d07215337cc316cb3fa45742a5f5a735d21a31f581d27884a414df21ac99616d14c7ebec1ab68a5766c10faa4b1564ceb7c20
        - path: "data/rentry/bluemoon/bluemoon-fanbased-roleplays-1x1.csv"
          sha512: f31d6bd278bc4211736d6aace3917cd0c1d0143bec9bf9d07054f5f9b32060e17399b6ea0935774b2271ac45a88309a60ef8eec8c4ac5283d1b353a255529cc5
      steps:
        - *bluemoon
        - type: StatsCountOccurrences
          description: "Count occurrences of usernames."
          pack: [ 'pack/gen/usernames_all.csv' ]
          config:
            path: 'out/usernames_counted_%worker%.csv'
            packedPatterns: [ 'pack/gen/usernames_all.csv' ]
            countCol: 2
            regex: false
            min: 1
        - type: StatsAddColMerge
          description: "Merge username count csv files"
          sync: main
          config:
            path: 'pack/gen/usernames.csv'
            files: [ 'out/usernames_counted_*.csv' ]
            cols: [ 2 ]
            min: 1
      artifacts:
        - file: 'pack/gen/usernames.csv'


  - pass: &clean
      required:
        - path: "data/rentry/bluemoon/bluemoon-fanbased-roleplays-1x1.csv"
          sha512: f31d6bd278bc4211736d6aace3917cd0c1d0143bec9bf9d07054f5f9b32060e17399b6ea0935774b2271ac45a88309a60ef8eec8c4ac5283d1b353a255529cc5
      steps: [ *bluemoon,
               *html_linebreaks, *html_strip, *links, *trim, *reduce_whitespace,
               *ooc_strip, *reduce_separators, *reduce_punctuation, *spelling, *ooc_prune,
               *strip_unicode,
               *reduce_whitespace, *strip_nonwords, *edge_cases, *trim, *empty,
               *two_alternating_participants, *rename_participants,
               *bluemoon_fastchat,
      ]
      artifacts:
        - file: 'out/bluemoon.json'
          sha512: 1846fd5a901e4cbe1979d96b0cdf272275548891300ba78f523ffaecc407cc08ea556fa142ac478fb4e3a96b7ad811b4aff9c85191326b57eef1dcde2f473fb2

passes: [ *clean ]