CryptoAssist/other/frequencies/digraphs/index.js

21 lines
407 B
JavaScript
Raw Normal View History

2017-02-26 13:19:28 +00:00
var data = require("fs").readFileSync("data.txt").toString();
console.log(
JSON.stringify(
data
.replace(/\r/g, "")
.split("\n")
.filter((a)=>(a))
.map((line)=>(
line
.split("\t")
.filter((a)=>(a))
))
.map((sections)=>([sections[0], parseFloat(sections[4])]))
.reduce((freqs, freq)=>{
freqs[freq[0]] = freq[1];
return freqs;
}, {})
)
)