nltk.metrics.aline module

ALINE https://webdocs.cs.ualberta.ca/~kondrak/ Copyright 2002 by Grzegorz Kondrak.

ALINE is an algorithm for aligning phonetic sequences, described in [1]. This module is a port of Kondrak’s (2002) ALINE. It provides functions for phonetic sequence alignment and similarity analysis. These are useful in historical linguistics, sociolinguistics and synchronic phonology.

ALINE has parameters that can be tuned for desired output. These parameters are: - C_skip, C_sub, C_exp, C_vwl - Salience weights - Segmental features

In this implementation, some parameters have been changed from their default values as described in [1], in order to replicate published results. All changes are noted in comments.

Example usage

# Get optimal alignment of two phonetic sequences

>>> align('θin', 'tenwis') 
[[('θ', 't'), ('i', 'e'), ('n', 'n'), ('-', 'w'), ('-', 'i'), ('-', 's')]]

[1] G. Kondrak. Algorithms for Language Reconstruction. PhD dissertation, University of Toronto.

nltk.metrics.aline.align(str1, str2, epsilon=0)[source]

Compute the alignment of two phonetic strings.

Parameters
  • str2 (str1,) – Two strings to be aligned

  • epsilon (float (0.0 to 1.0)) – Adjusts threshold similarity score for near-optimal alignments

Return type

list(list(tuple(str, str)))

Returns

Alignment(s) of str1 and str2

(Kondrak 2002: 51)

nltk.metrics.aline.sigma_skip(p)[source]

Returns score of an indel of P.

(Kondrak 2002: 54)

nltk.metrics.aline.sigma_sub(p, q)[source]

Returns score of a substitution of P with Q.

(Kondrak 2002: 54)

nltk.metrics.aline.sigma_exp(p, q)[source]

Returns score of an expansion/compression.

(Kondrak 2002: 54)

nltk.metrics.aline.delta(p, q)[source]

Return weighted sum of difference between P and Q.

(Kondrak 2002: 54)

nltk.metrics.aline.diff(p, q, f)[source]

Returns difference between phonetic segments P and Q for feature F.

(Kondrak 2002: 52, 54)

nltk.metrics.aline.R(p, q)[source]

Return relevant features for segment comparison.

(Kondrak 2002: 54)

nltk.metrics.aline.V(p)[source]

Return vowel weight if P is vowel.

(Kondrak 2002: 54)

nltk.metrics.aline.demo()[source]

A demonstration of the result of aligning phonetic sequences used in Kondrak’s (2002) dissertation.