<commit_before>//  Copyright (c) 2015 <NAME>. All rights reserved.

import Cocoa
import MusicKit

class ViewController: NSViewController {

    var noteNumberToPitchSet = [UInt : PitchSet]()

    override func viewDidLoad() {
        super.viewDidLoad()

        let midi = MIDI(name: "ChaosHarmonizer")
        midi.noteHandler = { messages in
            if let first = messages.first {
                if first.on {
                    let possibleChords = [
//                        ChordQuality.Major,
//                        ChordQuality.Minor,
//                        ChordQuality.Sus2,
//                        ChordQuality.Sus4,
//                        ChordQuality.DominantSeventh,
//                        ChordQuality.DominantEleventhFlatNineFlatThirteen,
//                        ChordQuality.DominantEleventhFlatNineFlatThirteen,
//                        ChordQuality.DominantNinthSharpElevenFlatThirteen,
//                        ChordQuality.DominantThirteenthSharpEleven,
                    ] + ChordQuality.Heptads
                    let index = arc4random_uniform(UInt32(possibleChords.count))
                    let quality = possibleChords[Int(index)]
                    let intervals = quality.intervals
                    let indices = MKUtil.semitoneIndices(intervals)
                    let transposition = indices[indices.count - 1]*(-1)
                    let harmonizer = Harmony.transpose(Harmony.create(intervals), semitones: transposition)
                    let pitch = Pitch(midi: Float(first.noteNumber))
                    var pitchSet = harmonizer(pitch)
                    self.noteNumberToPitchSet[first.noteNumber] = pitchSet
                    var messages = first.harmonize(harmonizer)
                    messages.append(first)
                    midi.send(messages)
                }
                else {
                    var offMessages = [MIDINoteMessage]()
                    if let pitchSet = self.noteNumberToPitchSet[first.noteNumber] {
                        for pitch in pitchSet {
                            let message = MIDINoteMessage(on: false,
                                channel: first.channel,
                                noteNumber: UInt(pitch.midi), velocity: 0)
                            offMessages.append(message)
                            offMessages.append(first)
                        }
                        midi.send(offMessages)
                    }
                }
            }
        }
    }

    override var representedObject: AnyObject? {
        didSet {
        }
    }


}

<commit_msg>update example<commit_after>//  Copyright (c) 2015 <NAME>. All rights reserved.

import Cocoa
import MusicKit

class ViewController: NSViewController {

    var noteNumberToPitchSet = [UInt : PitchSet]()

    override func viewDidLoad() {
        super.viewDidLoad()

        let midi = MIDI(name: "ChaosHarmonizer")
        midi.noteHandler = { messages in
            if let first = messages.first {
                if first.on {
                    let possibleChords = [
                        ChordQuality.Major,
                        ChordQuality.Minor,
                        ChordQuality.Sus2,
                        ChordQuality.Sus4,
                    ]
//                    + ChordQuality.Pentads
                    let index = arc4random_uniform(UInt32(possibleChords.count))
                    let quality = possibleChords[Int(index)]
                    let intervals = quality.intervals
                    let indices = MKUtil.semitoneIndices(intervals)
                    let transposition = indices[indices.count - 1]*(-1)
                    let harmonizer = Harmony.transpose(Harmony.create(intervals), semitones: transposition)
                    let pitch = Pitch(midi: Float(first.noteNumber))
                    var pitchSet = harmonizer(pitch)
                    self.noteNumberToPitchSet[first.noteNumber] = pitchSet
                    var messages = first.harmonize(harmonizer)
                    messages.append(first)
                    midi.send(messages)
                }
                else {
                    var offMessages = [MIDINoteMessage]()
                    if let pitchSet = self.noteNumberToPitchSet[first.noteNumber] {
                        for pitch in pitchSet {
                            let message = MIDINoteMessage(on: false,
                                channel: first.channel,
                                noteNumber: UInt(pitch.midi), velocity: 0)
                            offMessages.append(message)
                            offMessages.append(first)
                        }
                        midi.send(offMessages)
                    }
                }
            }
        }
    }

    override var representedObject: AnyObject? {
        didSet {
        }
    }


}


{'fraction_non_alphanumeric': 0.07236304170073589, 'fraction_numerical': 0.004905968928863451, 'mean_word_length': 1.238334858188472, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6887551', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1159, 'n_words': 222}