semvec/pypi-packages huggingface dataset:
cedict-utils 0.0.13
A Python parser for the CC-CEDICT Chinese-English dictionary
License: MIT
Keywords: cedict dictionary chinese cc-cedict

A Python parser for the CC-CEDICT Chinese-English dictionary
============================================================

[![Travis](https://img.shields.io/travis/rust-lang/rust.svg)](https://travis-ci.org/marcanuy/cedict_utils)
[![Pypi](https://img.shields.io/pypi/v/nine.svg)](https://pypi.python.org/pypi/cedict-utils/)

----

A parser for the CC-CEDICT Chinese-English dictionary.

# Install

## PIP

https://pypi.org/project/cedict-utils/

~~~
pip install cedict-utils
~~~

## REPO

1. Create virtualenv.

~~~
python3 -m venv ~/.virtualenvs/cedict-utils
~~~

2. Activate venv.

~~~
source ~/.virtualenvs/cedict-utils/bin/activate
~~~

3. Install requirements.
   
~~~
pip install -r requirements.txt
~~~

# Dictionary

Download dictionary

~~~
wget -O - https://www.mdbg.net/chinese/export/cedict/cedict_1_0_ts_utf-8_mdbg.txt.gz | gunzip > data/cedict_ts.u8
~~~

# Usage

~~~ python
$ python
>>> from cedict_utils.cedict import CedictParser
>>> parser = CedictParser()
>>> parser.read_file()
>>> entries = parser.parse()
>>> for e in entries:
...     print(e)
... 
..
龟缩 (龜縮) - gui1 suo1
龟背竹 (龜背竹) - gui1 bei4 zhu2
龟船 (龜船) - gui1 chuan2
..
>>> entries[200].simplified
'敦'
>>> entries[200].traditional
'㪟'
>>> entries[200].pinyin
'dun1'
>>> entries[200].raw_line
'㪟 敦 [dun1] /variant of 敦[dun1]/'
>>> entries[200].meanings
['variant of 敦[dun1]']
>>> 
~~~


# Tests

Running tests

~~~
$ make test
pytest
================================================================ test session starts ================================================================
platform linux -- Python 3.6.8, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /Development/cedict-utils, inifile:
collected 8 items                                                                                                                                    

tests/test_cedict.py ........

============================================================= 8 passed in 0.09 seconds ==============================================================
~~~

# Resources

- Cedict project https://www.mdbg.net/chinese/dictionary?page=cc-cedict
ndlearn 0.0.2
Learning from and reconstructing networks using Nonnegative Matrix Factorization
License: MIT
Requires Python: >=3.6
Keywords: ndlearn

<p align="center">
<img width="600" src="https://github.com/jvendrow/Network-Dictionary-Learning/blob/master/NDL_logo.png" alt="logo">
</p>


# Network-Dictionary-Learning
Learning from and reconstructing networks using MCMC motif sampling and Nonnegative Matrix Factorization

## Installation

To install the Network Dictionary Learning package, run this command in your terminal:

```bash
$ pip install ndlearn
```

This is the preferred method to install Network Dictionary Learning. If you don't have [pip](https://pip.pypa.io) installed, these [installation instructions](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through the process.

## Usage

Our package lies on the backbone of the NNetwork class (see https://github.com/HanbaekLyu/NNetwork). 

```python
>>> from ndl import Wtd_NNetwork
>>> G = Wtd_NNetwork()
>>> G.load_add_edges_wtd("example.txt", use_genfromtxt=True, delimiter=",")
```
#### Learning a Dictionary

```python
>>> from ndl import NetDictLearner
>>> NDL = NetDictLearner(G=G, n_components=25, k=21)
>>> NDL.train_dict()
>>> W = NDL.get_dictionary()
```

Display and save the learned dictionary:
```python
>>> NDL.display_dict(path="example_dict.npy")
```

Replace the dictionary with a pre-trained dictionary and/or replace the network:
```python
>>> NDL.set_dict(W)
>>> NDL.set_network(G)
```
#### Reconstructing a Network

```python
>>> G_recons = NDL.reconstruct(recons_iter=10000)
```


The NetDictLearner class provices the base code to perform network dictionary learning and network reconstruction, but we also provide a series of helper fuctions to use alongside the NetDictLearner class to assist on performing tasks related to Network Dictionary Learning and evaluate performance. 

#### Measure Accuracy of Reconstruction (Jaccard)

```python
>>> from ndl import utils
>>> utils.recons_accuracy(G, G_recons)
0.92475345
```

#### Network Denoising Application

To add positive corruption (overlaying edges) or negative corruption (deleting edges) from a networks:
```python
>>> len(G.edges())
1000
>>> G_add = utils.corrupt(G, p=0.1, noise_type="ER")
>>> G_remove_10 = utils.corrupt(G, p=0.1, noise_type="negative")
>>>len(G_remove_10.edges())
900
```

To measure the AUC of network denoising with positive (or negative) noise:
```python
>>> G_corrupt = utils.corrupt(G, p=0.1, noise_type="ER")
>>> NDL_corrupt = NetDictLearner(G=G_corrupt)
>>> NDL_corrupt.train_dict()
>>> G_corrupt_recons = NDL_corrupt.reconstruct(recons_iter=10000)
>>> utils.auc(original=G, corrupt=G_corrupt, corrupt_recons=G_corrupt_recons, type="positive")
0.864578
```