Packages

Semantic Network Basics

To demonstrate the method we will turn two small corpi into semantic networks and compare them.

These are frivolous examples but interestin in that they have an identical set of words, but different punctuation. We will create networks between all words that occur within sentences.


Dear John:

I want a man who knows what love is all about.

You are generous, kind, thoughtful.

People who are not like you admit to being useless and inferior.

You have ruined me for other men.

I yearn for you.

I have no feelings whatsoever when we’re apart.

I can be forever happy.

Will you let me be yours?

Gloria


Dear John:

I want a man who knows what love is.

All about you are generous, kind, thoughtful people, who are not like you.

Admit to being useless and inferior.

You have ruined me.

For other men, I yearn.

For you, I have no feelings whatsoever.

When we’re apart, I can be forever happy.

Will you let me be?

Yours,

Gloria


## [1] "DEAR JOHN"                                                                                                                                                                                                                                                                    
## [2] ""                                                                                                                                                                                                                                                                             
## [3] "I WANT A MAN WHO KNOWS WHAT LOVE IS ALL ABOUT. YOU ARE GENEROUS KIND THOUGHTFUL. PEOPLE WHO ARE NOT LIKE YOU ADMIT TO BEING USELESS AND INFERIOR. YOU HAVE RUINED ME FOR OTHER MEN. I YEARN FOR YOU. I HAVE NO FEELINGS WHATSOEVER WHEN WE ARE APART. I CAN BE FOREVER HAPPY."
## [4] ""                                                                                                                                                                                                                                                                             
## [5] "WILL YOU LET ME BE YOURS"                                                                                                                                                                                                                                                     
## [6] ""                                                                                                                                                                                                                                                                             
## [7] "GLORIA"
## [1] "DEAR JOHN"                                                                                                                                                                                                                                                                    
## [2] "I WANT A MAN WHO KNOWS WHAT LOVE IS ALL ABOUT. YOU ARE GENEROUS KIND THOUGHTFUL. PEOPLE WHO ARE NOT LIKE YOU ADMIT TO BEING USELESS AND INFERIOR. YOU HAVE RUINED ME FOR OTHER MEN. I YEARN FOR YOU. I HAVE NO FEELINGS WHATSOEVER WHEN WE ARE APART. I CAN BE FOREVER HAPPY."
## [3] "WILL YOU LET ME BE YOURS"                                                                                                                                                                                                                                                     
## [4] "GLORIA"

Break paragraphs into sentences:

## [[1]]
## [1] "DEAR JOHN"
## 
## [[2]]
## [1] "I WANT A MAN WHO KNOWS WHAT LOVE IS ALL ABOUT"                   
## [2] " YOU ARE GENEROUS KIND THOUGHTFUL"                               
## [3] " PEOPLE WHO ARE NOT LIKE YOU ADMIT TO BEING USELESS AND INFERIOR"
## [4] " YOU HAVE RUINED ME FOR OTHER MEN"                               
## [5] " I YEARN FOR YOU"                                                
## [6] " I HAVE NO FEELINGS WHATSOEVER WHEN WE ARE APART"                
## [7] " I CAN BE FOREVER HAPPY"                                         
## 
## [[3]]
## [1] "WILL YOU LET ME BE YOURS"
## 
## [[4]]
## [1] "GLORIA"

Turn sentences into networks.

First turn sentences into tokens:

## [1] "YOU"        "ARE"        "GENEROUS"   "KIND"       "THOUGHTFUL"

Then turn tokens into word pairs:

##       [,1]       [,2]        
##  [1,] "YOU"      "ARE"       
##  [2,] "YOU"      "GENEROUS"  
##  [3,] "YOU"      "KIND"      
##  [4,] "YOU"      "THOUGHTFUL"
##  [5,] "ARE"      "GENEROUS"  
##  [6,] "ARE"      "KIND"      
##  [7,] "ARE"      "THOUGHTFUL"
##  [8,] "GENEROUS" "KIND"      
##  [9,] "GENEROUS" "THOUGHTFUL"
## [10,] "KIND"     "THOUGHTFUL"

Now apply this to all sentences, one at a time:

##      [,1]  [,2]        
## [1,] "YOU" "ARE"       
## [2,] "YOU" "GENEROUS"  
## [3,] "YOU" "KIND"      
## [4,] "YOU" "THOUGHTFUL"
## [5,] "ARE" "GENEROUS"  
## [6,] "ARE" "KIND"

LETTER 1

LETTER 2

Read Mission Data

## tokens from 3 documents.
## 10716217-2016 :
##  [1] ""            "corpor"      "specif"      "purpos"      ""           
##  [6] ""            "support"     "afford"      "hous"        "communiti"  
## [11] "develop"     ""            "econom"      "develop"     ""           
## [16] ""            "citi"        ""            "counti"      ""           
## [21] "san"         "francisco"   "econom"      "disadvantag" "individu"   
## [26] ""            "communiti"   ""            "lend"        ""           
## [31] "invest"      ""            ""            "direct"      "acquir"     
## [36] ""            "afford"      "hous"        ""            "relat"      
## [41] "communiti"   "develop"     "real"        "estat"       "asset"      
## 
## 10842551-2015 :
## [1] "support"    "hartland"   "creeksid"   "elementari" "school"    
## 
## 20792368-2011 :
## [1] "communiti" "sport"     "program"
##  [1] "corpor"      "specif"      "purpos"      "support"     "afford"     
##  [6] "hous"        "communiti"   "develop"     "econom"      "develop"    
## [11] "citi"        "counti"      "san"         "francisco"   "econom"     
## [16] "disadvantag" "individu"    "communiti"   "lend"        "invest"     
## [21] "direct"      "acquir"      "afford"      "hous"        "relat"      
## [26] "communiti"   "develop"     "real"        "estat"       "asset"

Sanity check, nets should have n * (n-1) / 2 nodes.

## [1] 793658      2
## IGRAPH 57993a6 UN-- 4826 793658 -- 
## + attr: name (v/c)

Comparison by Mission

## 
##    0    1 
## 2961  447
## [1] 447
## [1] 2961
## IGRAPH 5801fef UN-- 1452 104179 -- 
## + attr: name (v/c)
## IGRAPH 582dea7 UN-- 4438 689479 -- 
## + attr: name (v/c)
## IGRAPH 584eb40 UN-- 1452 45910 -- 
## + attr: name (v/c)
## IGRAPH 58634a7 UN-- 4438 211114 -- 
## + attr: name (v/c)
## IGRAPH 587485f UN-- 1449 31804 -- 
## + attr: name (v/c)

These need to be filtered using a probabalistic method to identify only the ties that are statistically meaningful (would not occur by chance) within each group.

Religious Purpose Nonprofits

Non-Religious Purpose Nonprofits