wals.py

This is a file that describes how the WALS module works.

See WALS here: WALS

Please work this time.

Module Documentation

class wals.WALSLanguage(header, walslist)

This represents a single language in the WALS system. This contains a feature vector for the WALS features.

mp(x)

This turns the WALS vector into an integer vector. Each feature has the format: <int> <Description>. This just returns the int.

wals.compare(lang1, lang2)

Given two language names, get distance according to phonology scores.

Parameters:
  • lang1 – name of first lang (eg English)
  • lang2 – name of second lang
Returns:

the distance of the languages, or -1 if one or both langs not found.

wals.comparefeats(lang1, lang2)

What does this do???

Parameters:
  • lang1
  • lang2
Returns:

wals.getclosest(lang, threshold=0, only_hr=False, topk=20)

Gets a topk list of languages similar to this language, various parameters control this.

Parameters:
  • lang
  • threshold
  • only_hr
  • topk
Returns:

wals.getgensim(l1, l2)

Get genealogical similarity between languages. These are WALSLanguage objects.

Parameters:
  • l1
  • l2
Returns:

wals.getphonsim(l1, l2)

This gets the average number of identical values between vectors.

Parameters:
  • l1 – a WALSLanguage
  • l2 – a WALSLanguage
Returns:

a similarity value between 0 (not similar) and 1 (most similar)

wals.loadlangs()

This loads the WALS file into the WALSLanguage data structures

Returns:list of WALSLanguage objects