Skip to main content

framework for detecting old loanwords

Project description

LOANPY

loanpy
Build Status

loanpy is a tool for historical linguists. It extracts sound changes and constraints from etymological dictionaries, generates pseudo-roots of L1, pseudo- sound substituted forms of L2, searches for matches and ranks them according to semantic similarity.

Installation

Type cmd into the search bar, open Command Prompt and type:

$ python -m pip install loanpy

Getting started

Change your working directory:

>>> import os
>>> os.chdir(lp.__file__[:-(len("\loanpy.py"))]+r"\data")

Get the path of your new working directory:

>>> import os
>>> print(str(os.getcwd())[:-(len("\loanpy.py"))]+r"\data")

Download pretrained vectors (3 Gigabyte) and save them to your new working directory. This step is needed to enable sorting phonetic matches according to their semantics. You can use your own vectors as well but make sure to name them "GoogleNews-vectors-negative300.bin".

Start python and type:

>>> from loanpy import loanpy as lp
>>> import pandas as pd

Define your input file.
loanpy comes with a csv generated from the annex of Gábor Zaicz's Hungarian etymological dictionary from 2006
If you use your own csv make sure to keep the same column names as in zaicz_in.csv

>>> myinput = pd.read_csv("zaicz_in.csv",encoding="utf-8")

Filter your input according to year and/or origin. E.g. if you want to keep only words of unknown origin that appear in texts before 1600 tpye:

>>> myinput=myinput[myinput.year <= 1600]
>>> myinput=myinput[myinput.origin == "G) ISMERETLEN EREDETŰ SZAVAK "]

Type in the timelayer in which you want to search for loans ("U" for Proto-Uralic, "FU" for Proto-Finno-Ugric or "Ug" for Proto-Ugric) and view your results in bestof[timelayer].csv (e.g. bestofUg.csv)

>>> lp.loandf("Ug",myinput)

Other functions

Get phonetic matches and their semantic similarity score for a single word. Output is not sorted.
(Use "n" for nouns, "v" for verbs, "a" for adjectives and "r" for everything else)

>>> import epitran
>>> epi = epitran.Epitran('hun-Latn')
>>> lp.loan(layer="Ug",wordipa=epi.transliterate("bor"),en="wine",word="bor",pos_hun="n")

Get phonetic matches without a semantic similarity score.

>>> import epitran
>>> epi = epitran.Epitran('hun-Latn')
>>> lp.loan_nosem(layer="Ug",wordipa=epi.transliterate("bor"),en="wine",word="bor",pos_hun="n")

Get semantic similarity of two words.

>>> lp.semsim("wine","beer","n","n")

Delete duplicate word pairs by keeping only the ones with the most likely reconstructed root

>>> inputfile=pd.read_csv("bestofUg.txt",encoding="utf-8")
>>> lp.delbynse(inputfile)

Add all other words from the etymological dictionary that exhibit the same sound changes

>>> inputfile=pd.read_csv("bestofUg.txt",encoding="utf-8")
>>> lp.addexamples(inputfile)

Get a list of pseudo-roots

>>> import epitran
>>> epi = epitran.Epitran('hun-Latn')
>>> lp.settimelayer("U")
>>> lp.structure(lp.shuffle(lp.posy(epi.transliterate("bor"))))

License

Academic Free License (AFL) (Creative Commons Attribution 4.0 International)

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

loanpy-0.1.4.tar.gz (457.7 kB view details)

Uploaded Source

File details

Details for the file loanpy-0.1.4.tar.gz.

File metadata

  • Download URL: loanpy-0.1.4.tar.gz
  • Upload date:
  • Size: 457.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for loanpy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b010ca6cb9a7e53a502df620cd36b7846c2fd2941f6e65ec3d3d1aaa85086f1d
MD5 cd018de27b0b82d3967f295496dbc8ba
BLAKE2b-256 f70eb677053e289a7f6244615f35106e2a9503a5b20f30eaed8a964911bb5f00

See more details on using hashes here.

Supported by

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