-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from achen12/origin/develop
Completing Entity Analysis
- Loading branch information
Showing
24 changed files
with
94,681 additions
and
47,136 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,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'); |
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,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"); |
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,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)) | ||
|
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,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); | ||
|
||
|
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,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 |
Oops, something went wrong.