Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
modules
- Loading branch information
kirk gardner
committed
Apr 3, 2018
1 parent
f3ca692
commit 89136f3
Showing
7 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module WFF | ||
export wordlist | ||
|
||
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 | ||
print::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 | ||
this.print = function() | ||
println("\nword frequencies for $(this.file)") | ||
[println("\t$kv") for kv in this.words] # word_dicts is object scope! | ||
end | ||
map(word->this.addword(word),split(this.string,delims)) | ||
this | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
echo | ||
echo "testing wff_dict.jl" | ||
./wff_dict.jl tests/* | ||
echo | ||
echo "testing wff_type.jl" | ||
./wff_type.jl tests/* | ||
echo | ||
echo "testing wff_mod.jl" | ||
./wff_mod.jl tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/local/bin/julia | ||
|
||
const files = length(ARGS) == 0 ? (println("please provide at least one file name!"); exit()) : ARGS | ||
include("modules/wff.jl") | ||
using WFF | ||
|
||
file_o = [wordlist(file) for file in files] | ||
|
||
map(x->x.print(),file_o) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters