lexibank / lsi

CLDF dataset derived from Grierson's "Linguistic Survey of India" from 1928
https://lsi.clld.org
Creative Commons Attribution 4.0 International
1 stars 0 forks source link

command to visualize sound distribution #32

Open xrotwang opened 3 years ago

xrotwang commented 3 years ago

Mostly because I like the termgraph package so much, I cobbled together a command that shows distribution of sounds among the languages of the survey.

$ cldfbench lsi.sound_distribution | termgraph

INFO    How many sounds appear in how many languages in the survey?
1  : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 33.00
2  : ▇▇▇▇▇ 8.00 
3  : ▇▇▇▇▇ 8.00 
4  : ▇▇▇▇▇ 7.00 
5  : ▏ 1.00 
6  : ▇▇ 3.00 
8  : ▇ 2.00 
9  : ▇▇ 3.00 
10 : ▇ 2.00 
11 : ▇▇ 3.00 
12 : ▇ 2.00 
13 : ▏ 1.00 
16 : ▇ 2.00 
17 : ▏ 1.00 
18 : ▏ 1.00 
19 : ▇ 2.00 
20 : ▇ 2.00 
25 : ▏ 1.00 
27 : ▇ 2.00 
28 : ▇ 2.00 
30 : ▏ 1.00 
31 : ▏ 1.00 
32 : ▇▇ 3.00 
33 : ▇ 2.00 
34 : ▏ 1.00 
35 : ▏ 1.00 
36 : ▏ 1.00 
37 : ▏ 1.00 
39 : ▏ 1.00 
41 : ▇ 2.00 
44 : ▇ 2.00 
46 : ▏ 1.00 
47 : ▇▇ 3.00 
>50: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 68.00
xrotwang commented 3 years ago

@LinguList @PhyloStar we can keep this functionality or remove it. I just wanted to show off termgraph :)

LinguList commented 3 years ago

Cool package ;)

LinguList commented 3 years ago

I think we should keep some command functionality. One problem I had in the past were dependencies, since having extra deps like matplotlib and the like will yield a lot of warnings in fresh virtual environments. For this reason, I now switched to adding commands to a scripts folder and executing them with Python directly. So I am also hesitant with respect to commands we apply for the LSI in general.

xrotwang commented 3 years ago

Ah, yes, that's true. We wouldn't want to install matplotlib just to run the CLDF validation in CI, e.g.

LinguList commented 3 years ago

I was wondering if we have the chance to make a workaround here, similar to the different installation options one has.

xrotwang commented 3 years ago

We have a setup.py - so declaring matplotlib as optional requirement via extras_require should work.

LinguList commented 3 years ago

the problem is: if it is not installed, there will be a warning / error, since the commands are completely loaded when you call cldfbench. So the question is: can we suppress loading, or should we make a library check, like try: import matplotlib except matplotlib=None or similar?

xrotwang commented 3 years ago

Oh, yes. Optional requirements need a try ... except ImportError when loaded. Ideally with suitable info messages - something like install as pip install .[extra].