From f3ca6920bb7d08800a936fec65dd76445c7c503f Mon Sep 17 00:00:00 2001 From: kirk gardner Date: Tue, 3 Apr 2018 01:13:23 -0400 Subject: [PATCH] crude oop --- wff_type.jl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 wff_type.jl diff --git a/wff_type.jl b/wff_type.jl new file mode 100755 index 0000000..18ffb42 --- /dev/null +++ b/wff_type.jl @@ -0,0 +1,40 @@ +#!/usr/local/bin/julia + +const files = length(ARGS) == 0 ? (println("please provide at least one file name!"); exit()) : ARGS +const delims = [' ','\n','\t','.',',','(',')','?'] # single quotes: character literal + +function getstr(file) + f = open(file) + str = readstring(f) + close(f) + str +end + +type wordlist + file::String + words::Dict{String,Int} + string::String + addword::Function + function wordlist(file::String) + this = new(file) + this.words = Dict{String,Int}() + this.string = getstr(this.file) + this.addword = function(word) + haskey(this.words, word) ? this.words[word] += 1 : this.words[word] = 1 + this.words[word] + end + map(word->this.addword(word),split(this.string,delims)) + this + end +end + + +file_o = [wordlist(file) for file in files] +for wl in file_o + println("$(typeof(wl)) \"obj\"") + for field in fieldnames(wl) + s = String(field) + println("\n__wl.$(s)__") + println(getfield(wl,Symbol(field))) + end +end