Skip to main content

Spatial centrality scores for syntactic dependency trees

Project description

spatial_centrality

This package provides spatial centrality scores (D, coverage, and D') for syntactic dependency trees, as introduced in this publication:

Ferrer-i-Cancho, R., & Arias, M. (2025). Who is the root in a syntactic dependency structure? arXiv:2501.15188

The scores are designed for use with undirected syntactic dependency trees, combined with the linear order of words in a sentence. These measures help identify the root of a dependency tree using spatial and topological information.

This package is an independent implementation based on the algorithms described in the paper. All credit for the concepts and theoretical work goes to the original authors. This implementation is provided under an open-source license to facilitate use and experimentation by the NLP and computational linguistics community.

Installation

pip install .

Usage

import networkx as nx
from spatial_centrality import d_centrality, coverage_centrality, d_prime_centrality

# Create an undirected syntactic dependency tree
G = nx.Graph()
G.add_edges_from([(0, 1), (1, 2), (1, 3)])  # edges represent syntactic relations

# Define the linear order of words in the sentence
linear_order = [0, 1, 2, 3]  # e.g., token indices from left to right

# Compute scores
print(d_centrality(G, linear_order))
print(coverage_centrality(G, linear_order))
print(d_prime_centrality(G, linear_order))

License

MIT License


If you use this package in academic work, please cite the original paper and feel free to mention this implementation in your acknowledgments or supplementary materials.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spatial_centrality-0.1.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spatial_centrality-0.1.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file spatial_centrality-0.1.0.tar.gz.

File metadata

  • Download URL: spatial_centrality-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for spatial_centrality-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aa06dc39d25649b6d4c14d9e6f183dcbc8e5a514f5408b2e09e722d8a405e41b
MD5 15524ef6ee880dd8f0d06d84d82b1ef3
BLAKE2b-256 6a2cbece49164ec3c91aa6874258537324b9401f7002653ceb492b837f8d97f6

See more details on using hashes here.

File details

Details for the file spatial_centrality-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spatial_centrality-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 553324496fd7c05ae6528d9630dc955f91d4d1f20903ffc10eb38766a12e21c3
MD5 76db71b353b1cc3961f030108c91e498
BLAKE2b-256 c613cba81169c82f091735f841a2a28f2dfe65951aac72ed685b25e4616e5906

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page