Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
crude oop
  • Loading branch information
kirk gardner committed Apr 3, 2018
1 parent 7553036 commit f3ca692
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions 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

0 comments on commit f3ca692

Please sign in to comment.