Skip to main content

A package for quantiative linguistics

Project description

QuantLing

QuantLing:A python package for quantitative syntax analysis.

PyPI version Build Status License

Description

QuantLing is a Python package for Quantitative Linguistics. It provides functionality to quantify linguistic structures and explore language patterns.

This package is consisted of three main parts:

  • depval.py: some indicators about dependency structures and valency structures.
  • lawfitter.py: a small fitter for some laws in QL.
  • lingnet.py: a module for complex network construction.

Installation

You can install QuantLing via pip:

pip install quantling

nltk and conllu are required.

pip install nltk conllu

Quick Start

Here's a simple example of how to use QuantLing:

1. depval

from quantling.depval import DepValAnalyzer   
data = open(r'your_treebank.conllu',encoding='utf-8')
dv = DependencyAnalyzer(data) 

# dependency distance distribution
dv.dd_distribution()
# mean dependency distance of specific wordclasses
dv.mdd(pos='NOUN')
# mean dependency distance of specific dependency relations
dv.mdd(dependency='nsubj')
# proportion of dependency distance
dv.pdd()
# tree width and tree depth
dv.tree()
# tree width distirbution and tree depth distribution
dv.tree_distribution()

# mean valency
dv.mean_valency()
# valency distribution
dv.valency_distribution()
# probalistic valency pattern 
dv.pvp()

or:

dv = getDepFeatures(data)
print(dv)

2. lawfitter

from quantling.lawfitter import fit   
#results = fit(data,model,variant)
results = fit([[1,2,3,4,5,6],[3,4,2,6,8,15]],'zipf')
print(resluts)

3. lingnet

from quantling.lingnet import conllu2edge
import networkx as nx   
# use a conllu file to construction a network
data = open(r'your_treebank.conllu',encoding='utf-8')
edges = conllu2edge(data,mode='dependency')
# or to construct a co-occurance network 
#edges = conllu2edge(data,mode='adjacency')
G = nx.Graph()
G.add_edges_from(edges)

# to estimate the degree exponents
degree =[i[1] for i in G.degree()]
degree_exponents = fitPowerLaw(degree)
print(degree_exponents)

Documentation

For more detailed information, please refer to the video (in Chinese).

Features

  • Dependency distance distribution
  • Mean dependency distance of specific wordclasses
  • Mean dependency distance of specific dependency relations
  • Proportion of dependency distance
  • Tree width and tree depth
  • Tree width distribution and tree depth distribution
  • Mean valency
  • Valency distribution
  • Probabilistic valency pattern
  • Law fitter
  • Complex network construction

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Citing

If our project has been helpful to you, please give it a star and cite our articles. We would be very grateful.

@article{Yang_2022,
doi = {10.1209/0295-5075/ac8bf2},
url = {https://dx.doi.org/10.1209/0295-5075/ac8bf2},
year = {2022},
month = {sep},
publisher = {EDP Sciences, IOP Publishing and Società Italiana di Fisica},
volume = {139},
number = {6},
pages = {61002},
author = {Mu Yang and Haitao Liu},
title = {The role of syntax in the formation of scale-free language networks},
journal = {Europhysics Letters},
abstract = {The overall structure of a network is determined by its micro features, which are different in both syntactic and non-syntactic networks. However, the fact that most language networks are small-world and scale-free raises the question: does syntax play a role in forming the scale-free feature? To answer this question, we build syntactic networks and co-occurrence networks to compare the generation mechanisms of nodes, and to investigate whether syntactic and non-syntactic factors have distinct roles. The results show that frequency is the foundation of the scale-free feature, while syntax is beneficial to enhance this feature. This research introduces a microscopic approach, which may shed light on the scale-free feature of language networks.}
}

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

quantling-0.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

quantling-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quantling-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for quantling-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb60900b4c77d3b76fd9c333816d9068a255ac18613c558ec763aaaab3f81e4b
MD5 6ca5a33d1ed1e512d3edf46620f44fad
BLAKE2b-256 80e3f1a6a5c356ec37809375394a4340e45194c2e83ea2c700fad359d16ffc54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quantling-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for quantling-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 147464d4d7f624c3a6017182b7db9ac800f9f338d0d5b67bf730216a3de56929
MD5 b99740ccd5ae8d56759fc612b21d8c8d
BLAKE2b-256 4233a61687f14ea9151a9a1d970a0edc1706e4599a80710ee2edcd7c443eba6e

See more details on using hashes here.

Supported by

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