<commit_before>import AutomatonManipulation from './AutomatonManipulation'
import NFA from '../automata/nfa'
import NFAe from '../automata/nfa-e'
import { epsilon } from '../constants'

export default class NFAManipulation extends AutomatonManipulation {
    constructor(automaton = null, data) {
        super(automaton, data)

        $('.opt.nfa').show()
        $('#convert-btn').off('click')
        $('#convert-btn').click(e => this.toDFA())
        $('#epsilon-toggle').change(this.onEpsilonToggleChange.bind(this))
    }
    editEdge(nodeData, cb) {
        const from     = this.nodes.get(nodeData.from).label
        const to       = this.nodes.get(nodeData.to).label
        const original = this.edges.get(nodeData.id)
        const o_from   = this.nodes.get(original.from).label
        const o_to     = this.nodes.get(original.to).label
        try {
            this.automaton.editTransition(o_from, nodeData.label, o_to, { from, to })
            cb(nodeData)
        } catch (e) {
            alert(e.message)
            cb(null)
        }
        console.log(this.automaton.states)
    }
    deleteEdge(nodeData, cb) {
        if (confirm('Are you sure you want to delete this edge?')) {
            const edge = this.edges.get(nodeData.edges[0])
            const from = this.nodes.get(edge.from).label
            const to   = this.nodes.get(edge.to).label
            this.automaton.removeTransition(from, edge.label, to)
            cb(nodeData)
        } else
            cb(null)
        console.log(this.automaton.states)
    }
    toDFA() {
        let dfa

        try {
            dfa = this.automaton.toDFA()
        } catch (e) {
            alert(e.message)
            return
        }

        this.buildFromAutomaton(dfa)
    }
    onEpsilonToggleChange(e) {
        const { checked } = e.target

        let newAutomaton = checked ?  new NFAe([]) : new NFA([])

        newAutomaton.setFromAutomaton(this.automaton)
        this.automaton = newAutomaton

        if (!checked)
            this.removeAllTransitionsWithChar(epsilon)
    }
}<commit_msg>Convert btn id fix<commit_after>import AutomatonManipulation from './AutomatonManipulation'
import NFA from '../automata/nfa'
import NFAe from '../automata/nfa-e'
import { epsilon } from '../constants'

export default class NFAManipulation extends AutomatonManipulation {
    constructor(automaton = null, data) {
        super(automaton, data)

        $('.opt.nfa').show()
        $('#todfa-btn').off('click')
        $('#todfa-btn').click(e => this.toDFA())
        $('#epsilon-toggle').change(this.onEpsilonToggleChange.bind(this))
    }
    editEdge(nodeData, cb) {
        const from     = this.nodes.get(nodeData.from).label
        const to       = this.nodes.get(nodeData.to).label
        const original = this.edges.get(nodeData.id)
        const o_from   = this.nodes.get(original.from).label
        const o_to     = this.nodes.get(original.to).label
        try {
            this.automaton.editTransition(o_from, nodeData.label, o_to, { from, to })
            cb(nodeData)
        } catch (e) {
            alert(e.message)
            cb(null)
        }
        console.log(this.automaton.states)
    }
    deleteEdge(nodeData, cb) {
        if (confirm('Are you sure you want to delete this edge?')) {
            const edge = this.edges.get(nodeData.edges[0])
            const from = this.nodes.get(edge.from).label
            const to   = this.nodes.get(edge.to).label
            this.automaton.removeTransition(from, edge.label, to)
            cb(nodeData)
        } else
            cb(null)
        console.log(this.automaton.states)
    }
    toDFA() {
        let dfa

        try {
            dfa = this.automaton.toDFA()
        } catch (e) {
            alert(e.message)
            return
        }

        this.buildFromAutomaton(dfa)
    }
    onEpsilonToggleChange(e) {
        const { checked } = e.target

        let newAutomaton = checked ?  new NFAe([]) : new NFA([])

        newAutomaton.setFromAutomaton(this.automaton)
        this.automaton = newAutomaton

        if (!checked)
            this.removeAllTransitionsWithChar(epsilon)
    }
}
{'fraction_non_alphanumeric': 0.12497007421594446, 'fraction_numerical': 0.00047881254488867607, 'mean_word_length': 2.027536231884058, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5507013', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1278, 'n_words': 237}