<commit_before>/**
 * @user Joseph
 */

function addBatch(text){
    var lines=text.split('\n')
    var defs={}
    var words=[];
    lines.map(function(line){
        var index=line.trim().indexOf(',')
        var word=''
        if(-1==index) {
            word=line;
        }
        else {
            word=line.substr(0,index).trim()
            var meaning=line.substr(index+1).trim()
            defs[word]=meaning;
        }
        words.push(word)
    })
    for (var i=0;i<words.length;i+=10)
        $.ajax({
            url: "http://www.shanbay.com/bdc/vocabulary/add/batch/?words="+words.slice(i,i+10).join("%0A"),
            type: 'GET',
            dataType: 'JSON',
            contentType: "application/json; charset=utf-8",
            success: function(data) {
                var json=$.parseJSON(data)
                var nf=json['notfound_words']
//                $('#words').val($('#words').val()+'\n'+nf.join('\n'))
//                if(nf.length>0) for (i=0;i<nf.length;i+=1)
//                    $.get("http://www.shanbay.com/bdc/sentence/add/?",{sentence:nf[i],definition:defs[i]})
            }
        });
}
$(function(){
    $('input[type=submit]').click(function(){
        addBatch($('textarea[name=words]').val())
        return false;<commit_msg>add batch insertion<commit_after>/**
 * @user Joseph
 */

function addBatch(text){
    var lines=text.split('\n')
    var defs={}
    var words=[];
    lines.map(function(line){
        var index=line.trim().indexOf(',')
        var word=''
        if(-1==index) {
            word=line;
        }
        else {
            word=line.substr(0,index).trim()
            var meaning=line.substr(index+1).trim()
            defs[word]=meaning;
        }
        words.push(word)
    })
    for (var i=0;i<words.length;i+=10)
        $.ajax({
            url: "http://www.shanbay.com/bdc/vocabulary/add/batch/?words="+words.slice(i,i+10).join("%0A"),
            type: 'GET',
            dataType: 'JSON',
            contentType: "application/json; charset=utf-8",
            success: function(data) {
                var nf=data['notfound_words']
                if(0<nf.length){
                    var ch=nf.join('\n')
                    var ds=nf.map(function(e){
                        return e+','+defs[e]
                    }).join('\n')
                    console.log(ch)
                    var t=$('textarea[name=words]')
                    t.val(t.val()+'\n'+ds)
                }
//                if(nf.length>0) for (i=0;i<nf.length;i+=1)
//                    $.get("http://www.shanbay.com/bdc/sentence/add/?",{sentence:nf[i],definition:defs[i]})
            }
        });
}
$(function(){
    $('input[type=submit]').click(function(){
        var t=$('textarea[name=words]')
        addBatch(t.val())
        t.val('')
        return false;
{'fraction_non_alphanumeric': 0.19444444444444445, 'fraction_numerical': 0.00949367088607595, 'mean_word_length': 1.6915799432355725, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '1303011', 'n_tokens_mistral': 953, 'n_tokens_neox': 918, 'n_words': 119}