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