Commit 6247fb27 authored by 18김상언's avatar 18김상언

csv 파싱하는 js

Dictionary 함수를 선언해서 add, find, remove 기능을 넣음.
csv 파싱해서 얻어진 단어들을 단어의 grade와 함께 등급별 딕셔너리에 추가함.
parent f30281f5
This diff is collapsed.
function Dictionary() {
this.add = add;
this.datastore = new Array();
this.find = find;
this.remove = remove;
}
function add(key, value) {
this.datastore[key] = value;
}
function find(key, value) {
return this.datastore[key];
}
function remove(key) {
delete this.datastore[key];
}
var wordDic3 = new Dictionary();
var wordDic2 = new Dictionary();
var wordDic1 = new Dictionary();
var wordDic0 = new Dictionary();
function CSVParse($data) {
var allRows = $data.split('\n')
for(var singleRow = 0; singleRow < allRows.length; singleRow++)
{
var typing;
var grade;
typing = WordReader.getWordTyping(allRows[singleRow]);
grade = WordReader.getWordGrade(typing);
if(grade==3) {
wordDic3.add(allRows[singleRow], grade);
} else if(grade==2) {
wordDic2.add(allRows[singleRow], grade);
} else if(grade==1) {
wordDic1.add(allRows[singleRow], grade);
} else {
wordDic0.add(allRows[singleRow], grade);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment