Skip to content

Commit

Permalink
Merge pull request #18 from achen12/origin/develop
Browse files Browse the repository at this point in the history
Completing Entity Analysis
  • Loading branch information
achen12 committed Mar 25, 2016
2 parents 7adf90e + 15cf07b commit 2a8d23f
Show file tree
Hide file tree
Showing 24 changed files with 94,681 additions and 47,136 deletions.
94,179 changes: 47,090 additions & 47,089 deletions EntityCopy.csv

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions examples/2Apps/1EntityAnalysis/EA1_ReadTEST.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


file_dir = Pkg.dir("D4M")*"/examples/2Apps/1EntityAnalysis/Entity.csv";
E = ReadCSV(file_dir);
print(E[1:5,:]);

~,~,doc_val = find(E[:,"doc,"]);
~,~,entity_val = find(E[:,"entity,"]);
~,~,position_val = find(E[:,"position,"]);
~,~,type_val = find(E[:,"type,"]);

typeEntity_val = CatStr(type_val, "/" , entity_val);

E = Assoc(doc_val,typeEntity_val,position_val);

using JLD
save(Pkg.dir("D4M")*"/examples/2Apps/1EntityAnalysis/Entity.jld" , "E",E );


print(E[1,:]);


using PyPlot
spy(E');
16 changes: 16 additions & 0 deletions examples/2Apps/1EntityAnalysis/EA2_StatTEST.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
file_dir = Pkg.dir("D4M")*"/examples/2Apps/1EntityAnalysis/Entity.jld";

using JLD

E = load(file_dir)["E"]

sum(logical(col2type(E,"/")),1);

En = sum(logical(E),1);

~,entity,count = find(En);

An = Assoc(count,entity,1);

using PyPlot
loglog(full(sum(Adj(An[:,StartsWith("LOCATION/,")]),2)) ,"o");
16 changes: 16 additions & 0 deletions examples/2Apps/1EntityAnalysis/EA3_FacetTEST.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
file_dir = Pkg.dir("D4M")*"/examples/2Apps/1EntityAnalysis/Entity.jld";

using JLD

E = load(file_dir)["E"]

E = logical(E)

x = "LOCATION/new york,";
p = "PERSON/michael chang,";
F = ( nocol(E[:,x]) & nocol(E[:,p]))' * E;
print(F' > 1 )

Fn = F./ sum(E,1)
print((Fn' > 0.02))

17 changes: 17 additions & 0 deletions examples/2Apps/1EntityAnalysis/EA4_GraphTEST.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
file_dir = Pkg.dir("D4M")*"/examples/2Apps/1EntityAnalysis/Entity.jld";

using JLD

E = load(file_dir)["E"]


Es = E;
E = logical(E);

Ae = sqIn(E);
Ae
using PyPlot
figure;
spy(Ae);


42 changes: 42 additions & 0 deletions examples/2Apps/1EntityAnalysis/EA5_GraphQueryTEST.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
file_dir = Pkg.dir("D4M")*"/examples/2Apps/1EntityAnalysis/Entity.jld";

using JLD

E = load(file_dir)["E"]

E = logical(E);

A = sqIn(E);

d = diag(Adj(A))

A = putAdj(A,Adj(A)-diagm(d));


####

i,j,v = findnz(Adj(A));

An = putAdj(A, sparse(i,j,v ./ min(d[i],d[j])));

####

x = "LOCATION/new york,";

p = StartsWith("PERSON/,");

print( (A[p,x] > 4) & (An[p,x] > 0.3));

####

p0 = "PERSON/john kennedy,";

p1 = Row(A[p,p0] + A[p0,p]);

using PyPlot

spy(A[p1,p1])

p2 = Row( A[p1,p1] - (A[p,p0]+ A[p0,p]));

A[p2,p2] > 1
Loading

0 comments on commit 2a8d23f

Please sign in to comment.