Package 'hood2net'

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

Help Index


Returns the neighborhood clustering (i.e., local transitivity or local clustering coefficient) for all or a subset of nodes in the language network.

Description

Returns the neighborhood clustering (i.e., local transitivity or local clustering coefficient) for all or a subset of nodes in the language network.

Usage

get_neighbor_clustering(network, node_name = NULL)

Arguments

network

An igraph network object, generated by make_network() or make_network_sep() functions.

node_name

A vector containing node names to obtain values for. Node names must be found in igraph::V(network)$name. If unspecified, the default is to return values for all nodes in the network.

Value

A named numeric vector.

Examples

# 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.

Description

Returns the mean of a neighborhood's attribute for all or a subset of nodes in the language network.

Usage

get_neighbor_mean(network, node_name = NULL, attribute)

Arguments

network

An igraph network object, generated by make_network() or make_network_sep() functions.

node_name

A vector containing node names to obtain values for. Node names must be found in igraph::V(network)$name. If unspecified, the default is to return values for all nodes in the network.

attribute

A string stating the node attribute to obtain the mean values for. The attribute must be found in igraph::vertex_attr_names(network). Typically it will be one of the node attribute columns in the item_df data frame object used to create the network.

Value

A named numeric vector.

Examples

# 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.

Description

Returns the neighborhood size (i.e., degree) for all or a subset of nodes in the language network.

Usage

get_neighbor_size(network, node_name = NULL)

Arguments

network

An igraph network object, generated by make_network() or make_network_sep() functions.

node_name

A vector containing node names to obtain values for. Node names must be found in igraph::V(network)$name. If unspecified, the default is to return values for all nodes in the network.

Value

A named numeric vector.

Examples

# 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.

Description

Returns a summary of global network characteristics of the language network.

Usage

get_network_info(network)

Arguments

network

An igraph network object, generated by make_network() or make_network_sep() functions.

Value

A named vector of global network metrics. For more information about these metrics, refer to the package vignette.

Examples

#' # 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.

Description

Create a language network from a list of items. This version takes each single character as an individual segment when specifying neighbors.

Usage

make_network(
  item_df,
  neighbor_type = "lv",
  network_name = "test",
  edit_size = 1
)

Arguments

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.

Value

An igraph network object.

Examples

# 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.

Description

Create a language network from a list of items. This version segments items based on a specified separator when specifying neighbors.

Usage

make_network_sep(
  item_df,
  separator = ".",
  neighbor_type = "lv",
  network_name = "test",
  edit_size = 1
)

Arguments

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.

Value

An igraph network object.

Examples

#' # 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)

sample1 data

Description

for testing make_network.R

Usage

sample1

Format

sample1

A data frame with 9 rows and 2 columns:

item

word transcriptions

length

number of letters, node attribute


sample2 data

Description

for testing make_network_sep.R with period separator, single characters

Usage

sample2

Format

sample2

A data frame with 9 rows and 2 columns:

item

word transcriptions

length

number of letters, node attribute


sample3 data

Description

for testing make_network_sep.R with space separator, multiple characters

Usage

sample3

Format

sample3

A data frame with 8 rows and 3 columns:

item

word transcriptions

ortho

node label

length

number of "chunks", node attribute