| Title: | Create a Language Network from Neighborhoods of Words |
|---|---|
| Description: | Input a list of words and/or their phonological transcriptions and this package creates a language network based on their neighborhood structure. First, the phonological/orthographic neighbors for each item in the list are identified based on various definitions of a neighbor (e.g., edit-distance (substitution, deletion, or addition), substitution-only; distance size (1-edit or more); based on single characters or segments indicated by separators) and summarizes this information in an 'igraph' network object for subsequent analyses. For more details see Luce & Pisoni (1998) <doi:10.1097/00003446-199802000-00001> and Vitevitch (2008) <doi:10.1044/1092-4388(2008/030)>. Helper functions for extracting network metrics, neighbors, and other information from the language network are provided. This package is intended for psycholinguists interested in modeling language networks and word neighborhoods in various languages. |
| Authors: | Cynthia Siew [aut, cre, cph] |
| Maintainer: | Cynthia Siew <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-07-17 16:57:17 UTC |
| Source: | https://github.com/cran/hood2net |
Returns the neighborhood clustering (i.e., local transitivity or local clustering coefficient) for all or a subset of nodes in the language network.
get_neighbor_clustering(network, node_name = NULL)get_neighbor_clustering(network, node_name = NULL)
network |
An |
node_name |
A vector containing node names to obtain values for. Node names must be found in |
A named numeric vector.
# Use the demo data for executing examples test <- make_network(sample1) get_neighbor_clustering(network = test) # all nodes get_neighbor_clustering(network = test, node_name = "cat") # for 1 node# Use the demo data for executing examples test <- make_network(sample1) get_neighbor_clustering(network = test) # all nodes get_neighbor_clustering(network = test, node_name = "cat") # for 1 node
Returns the mean of a neighborhood's attribute for all or a subset of nodes in the language network.
get_neighbor_mean(network, node_name = NULL, attribute)get_neighbor_mean(network, node_name = NULL, attribute)
network |
An |
node_name |
A vector containing node names to obtain values for. Node names must be found in |
attribute |
A string stating the node attribute to obtain the mean values for. The attribute must be found in |
A named numeric vector.
# Use the demo data for executing examples test <- make_network(sample1) get_neighbor_mean(network = test, attribute = "length") # all nodes get_neighbor_mean(network = test, node_name = "cat", attribute = "length") # for 1 node# Use the demo data for executing examples test <- make_network(sample1) get_neighbor_mean(network = test, attribute = "length") # all nodes get_neighbor_mean(network = test, node_name = "cat", attribute = "length") # for 1 node
Returns the neighborhood size (i.e., degree) for all or a subset of nodes in the language network.
get_neighbor_size(network, node_name = NULL)get_neighbor_size(network, node_name = NULL)
network |
An |
node_name |
A vector containing node names to obtain values for. Node names must be found in |
A named numeric vector.
# Use the demo data for executing examples test <- make_network(sample1) get_neighbor_size(network = test) # all nodes get_neighbor_size(network = test, node_name = "cat") # for 1 node# Use the demo data for executing examples test <- make_network(sample1) get_neighbor_size(network = test) # all nodes get_neighbor_size(network = test, node_name = "cat") # for 1 node
Returns a summary of global network characteristics of the language network.
get_network_info(network)get_network_info(network)
network |
An |
A named vector of global network metrics. For more information about these metrics, refer to the package vignette.
#' # Use the demo data for executing examples test <- make_network(sample1) get_network_info(network = test)#' # Use the demo data for executing examples test <- make_network(sample1) get_network_info(network = test)
Create a language network from a list of items. This version takes each single character as an individual segment when specifying neighbors.
make_network( item_df, neighbor_type = "lv", network_name = "test", edit_size = 1 )make_network( item_df, neighbor_type = "lv", network_name = "test", edit_size = 1 )
item_df |
A data frame containing the list of items and other node-level attributes that are appended to the network (optional). Must minimally contain one character class column labeled "item". |
neighbor_type |
A string indicating neighbor type: "lv" (default) is 1-edit neighbors by substitution, deletion, or addition; "osa" is 1-edit neighbors by substitution, deletion, addition, or transposition; "hamming" is 1-edit neighbors by substitution only. |
network_name |
A string, the name of the network. Becomes a network-level attribute. |
edit_size |
An integer that indicates the maximum edit distance allowed between word pairs that are connected in the network. Default value is 1. |
An igraph network object.
# Use the demo data for executing examples g <- make_network(item_df = sample1) # substitution, addition, deletion summary(g) g_sub <- make_network(item_df = sample1, neighbor_type = 'hamming') # substitution only summary(g_sub)# Use the demo data for executing examples g <- make_network(item_df = sample1) # substitution, addition, deletion summary(g) g_sub <- make_network(item_df = sample1, neighbor_type = 'hamming') # substitution only summary(g_sub)
Create a language network from a list of items. This version segments items based on a specified separator when specifying neighbors.
make_network_sep( item_df, separator = ".", neighbor_type = "lv", network_name = "test", edit_size = 1 )make_network_sep( item_df, separator = ".", neighbor_type = "lv", network_name = "test", edit_size = 1 )
item_df |
A data frame containing the list of items and other node-level attributes that are appended to the network (optional). Must minimally contain one character class column labeled "item". |
separator |
A single character. The default is '.'. This is used to segment items into sub-units to base the neighborhood computation on. |
neighbor_type |
A string indicating neighbor type: "lv" (default) is 1-edit neighbors by substitution, deletion, or addition; "hamming" is 1-edit neighbors by substitution only. |
network_name |
A string, the name of the network. Becomes a network-level attribute. |
edit_size |
An integer that indicates the maximum edit distance allowed between word pairs that are connected in the network. Default value is 1. |
An igraph network object.
#' # Use the demo data for executing examples g_sep <- make_network_sep(item_df = sample2) # substitution, addition, deletion summary(g_sep) # substitution only g_sep_sub <- make_network_sep(item_df = sample2, neighbor_type = 'hamming') summary(g_sep_sub)#' # Use the demo data for executing examples g_sep <- make_network_sep(item_df = sample2) # substitution, addition, deletion summary(g_sep) # substitution only g_sep_sub <- make_network_sep(item_df = sample2, neighbor_type = 'hamming') summary(g_sep_sub)
for testing make_network.R
sample1sample1
sample1A data frame with 9 rows and 2 columns:
word transcriptions
number of letters, node attribute
for testing make_network_sep.R with period separator, single characters
sample2sample2
sample2A data frame with 9 rows and 2 columns:
word transcriptions
number of letters, node attribute
for testing make_network_sep.R with space separator, multiple characters
sample3sample3
sample3A data frame with 8 rows and 3 columns:
word transcriptions
node label
number of "chunks", node attribute