cereja


Namecereja JSON
Version 2.0.5 PyPI version JSON
download
home_pageNone
SummaryCereja is a bundle of useful functions that I don't want to rewrite.
upload_time2024-10-26 10:47:35
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseCopyright (c) 2019 The Cereja Project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords progress bar utils array pln file utils
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cereja 🍒

![Python package](https://github.com/jlsneto/cereja/workflows/Python%20package/badge.svg)
[![PyPI version](https://badge.fury.io/py/cereja.svg)](https://badge.fury.io/py/cereja)
[![Downloads](https://pepy.tech/badge/cereja)](https://pepy.tech/project/cereja)
[![MIT LICENSE](https://img.shields.io/pypi/l/pyzipcode-cli.svg)](LICENSE)
[![Issues](https://camo.githubusercontent.com/926d8ca67df15de5bd1abac234c0603d94f66c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/jlsneto/cereja/issues/new/choose)
[![Get start on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jlsneto/cereja/blob/master/docs/cereja_example.ipynb)

<div align="center">
 <img src="https://i.ibb.co/Fw8SSfd/cereja-logo.png" height="300" width="300" alt="CEREJA">
</div>

*Cereja was written only with the Standard Python Library, and it was a great way to improve knowledge in the Language
also to avoid the rewriting of code.*

## Getting Started DEV

Don't be shy \0/ ... Clone the repository and submit a function or module you made or use some function you liked.

See [CONTRIBUTING](CONTRIBUTING.md) 💻

## Setup

* [Python 3.6+](https://www.python.org/downloads/ "Download python")
* [Pip3](https://pip.pypa.io "Download Pip")

## Install

```
pip install --user cereja
```

or for all users

```
pip install cereja
```

## Cereja Example usage

See some of the Cereja tools

To access the *Cereja's* tools you need to import it `import cereja as cj`.

### 📝 [FileIO](docs/file.md)

#### Create new files

```python
import cereja as cj

file_json = cj.FileIO.create('./json_new_file.json', data={'k': 'v', 'k2': 'v2'})

file_txt = cj.FileIO.create('./txt_new_file.txt', ['line1', 'line2', 'line3'])

file_json.save()
file_txt.save()

print(file_json.exists)
# True
print(file_txt.exists)
# True


# see what you can do .txt file
print(cj.can_do(file_txt))

# see what you can do .json file
print(cj.can_do(file_json))
```

#### Load and edit files

```python
import cereja as cj

file_json = cj.FileIO.load('./json_new_file.json')

print(file_json.data)
# {'k': 'v', 'k2': 'v2'}

file_json.add(key='new_key', value='value')
print(file_json.data)
# {'k': 'v', 'k2': 'v2', 'new_key': 'value'}

file_txt = cj.FileIO.load('./txt_new_file.txt')

print(file_txt.data)
# ['line1', 'line2', 'line3']

file_txt.add('line4')
print(file_txt.data)
# ['line1', 'line2', 'line3', 'line4']

file_txt.save(exist_ok=True)  # Override
file_json.save(exist_ok=True)  # Override
```

### 📍 Path

```python
import cereja as cj

file_path = cj.Path('/my/path/file.ext')
print(cj.can_do(file_path))
# ['change_current_dir', 'cp', 'created_at', 'exists', 'get_current_dir', 'is_dir', 'is_file', 'is_hidden', 'is_link', 'join', 'last_access', 'list_dir', 'list_files', 'mv', 'name', 'parent', 'parent_name', 'parts', 'path', 'rm', 'root', 'rsplit', 'sep', 'split', 'stem', 'suffix', 'updated_at', 'uri']
```

### 🆗 HTTP Requests

```python
import cereja as cj

# Change url, headers and data values.
url = 'localhost:8000/example'
headers = {'Authorization': 'TOKEN'} # optional
data = {'q': 'test'} # optional

response = cj.request.post(url, data=data, headers=headers)

if response.code == 200:
    data = response.data
    # have a fun!
```

### ⏳ [Progress](docs/display.md)

```python
import cereja as cj
import time

my_iterable = ['Cereja', 'is', 'very', 'easy']

for i in cj.Progress.prog(my_iterable):
    print(f"current: {i}")
    time.sleep(2)

# Output on terminal ...

# 🍒 Sys[out] » current: Cereja 
# 🍒 Sys[out] » current: is 
# 🍒 Cereja Progress » [▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱▱▱▱▱▱▱] - 50.00% - 🕢 00:00:02 estimated


```

### 🧠 [Data Preparation](docs/ml.md)

📊 **Freq**

```python
import cereja as cj

freq = cj.Freq([1, 2, 3, 3, 10, 10, 4, 4, 4, 4])
# Output -> Freq({1: 1, 2: 1, 3: 2, 10: 2, 4: 4})

freq.most_common(2)
# Output -> {4: 4, 3: 2}

freq.least_freq(2)
# Output -> {2: 1, 1: 1}

freq.probability
# Output -> OrderedDict([(4, 0.4), (3, 0.2), (10, 0.2), (1, 0.1), (2, 0.1)])

freq.sample(min_freq=1, max_freq=2)
# Output -> {3: 2, 10: 2, 1: 1, 2: 1}

# Save json file.
freq.to_json('./freq.json')
```

🧹 **Text Preprocess**

```python
import cereja as cj

text = "Oi tudo bem?? meu nome é joab!"

text = cj.preprocess.remove_extra_chars(text)
print(text)
# Output -> 'Oi tudo bem? meu nome é joab!'

text = cj.preprocess.separate(text, sep=['?', '!'])
# Output -> 'Oi tudo bem ? meu nome é joab !'

text = cj.preprocess.accent_remove(text)
# Output -> 'Oi tudo bem ? meu nome e joab !'

# and more ..

# You can use class Preprocessor ...
preprocessor = cj.Preprocessor(stop_words=(),
                               punctuation='!?,.', to_lower=True, is_remove_punctuation=False,
                               is_remove_stop_words=False,
                               is_remove_accent=True)

print(preprocessor.preprocess(text))
# Output -> 'oi tudo bem ? meu nome e joab !'

print(preprocessor.preprocess(text, is_destructive=True))
# Output -> 'oi tudo bem meu nome e joab'

```

🔣 **Tokenizer**

```python
import cereja as cj

text = ['oi tudo bem meu nome é joab']

tokenizer = cj.Tokenizer(text, use_unk=True)

# tokens 0 to 9 is UNK
# hash_ used to replace UNK
token_sequence, hash_ = tokenizer.encode('meu nome é Neymar Júnior')
# Output -> [([10, 12, 11, 0, 1], 'eeb755960ce70c')]

decoded_sequence = tokenizer.decode(token_sequence, hash_=hash_)
# Output -> 'meu nome é Neymar Júnior'

```

⏸ **Corpus**

Great training and test separator.

```python
import cereja as cj

X = ['how are you?', 'my name is Joab', 'I like coffee', 'how are you joab?', 'how', 'we are the world']
Y = ['como você está?', 'meu nome é Joab', 'Eu gosto de café', 'Como você está joab?', 'como', 'Nós somos o mundo']

corpus = cj.Corpus(source_data=X, target_data=Y, source_name='en', target_name='pt')
print(corpus)  # Corpus(examples: 6 - source_vocab_size: 13 - target_vocab_size:15)
print(corpus.source)  # LanguageData(examples: 6 - vocab_size: 13)
print(corpus.target)  # LanguageData(examples: 6 - vocab_size: 15)

corpus.source.phrases_freq
# Counter({'how are you': 1, 'my name is joab': 1, 'i like coffee': 1, 'how are you joab': 1, 'how': 1, 'we are the world': 1})

corpus.source.word_freq
# Counter({'how': 3, 'are': 3, 'you': 2, 'joab': 2, 'my': 1, 'name': 1, 'is': 1, 'i': 1, 'like': 1, 'coffee': 1, 'we': 1, 'the': 1, 'world': 1})

corpus.target.phrases_freq
# Counter({'como você está': 1, 'meu nome é joab': 1, 'eu gosto de café': 1, 'como você está joab': 1, 'como': 1, 'nós somos o mundo': 1})

corpus.target.words_freq
# Counter({'como': 3, 'você': 2, 'está': 2, 'joab': 2, 'meu': 1, 'nome': 1, 'é': 1, 'eu': 1, 'gosto': 1, 'de': 1, 'café': 1, 'nós': 1, 'somos': 1, 'o': 1, 'mundo': 1})

# split_data function guarantees test data without data identical to training
# and only with vocabulary that exists in training
train, test = corpus.split_data()  # default percent of training is 80%
```

### 🔢 Array

```python
import cereja as cj

cj.array.is_empty(data)  # False
cj.array.get_shape(data)  # (2, 3)

data = cj.array.flatten(data)  # [1, 2, 3, 3, 3, 3]
cj.array.prod(data)  # 162
cj.array.sub(data)  # -13
cj.array.div(data)  # 0.006172839506172839

cj.array.rand_n(0.0, 2.0, n=3)  # [0.3001196087729699, 0.639679494102923, 1.060200897124107]
cj.array.rand_n(1, 10)  # 5.086403830031244
cj.array.array_randn((3, 3,
                      3))  # [[[0.015077210355770374, 0.014298110484612511, 0.030410666810216064], [0.029319083335697604, 0.0072365209507707666, 0.010677361074992], [0.010576754075922935, 0.04146379877648334, 0.02188348813336284]], [[0.0451851551098092, 0.037074906805326824, 0.0032484586475421007], [0.025633380630695347, 0.010312669541918484, 0.0373624007621097], [0.047923908102496145, 0.0027939333359724224, 0.05976224377251878]], [[0.046869510719106486, 0.008325638358172866, 0.0038702998343255893], [0.06475268683502387, 0.0035638592537234623, 0.06551037943638163], [0.043317416824708604, 0.06579372884523939, 0.2477564291871006]]]
cj.chunk(data=[1, 2, 3, 4], batch_size=3, fill_with=0)  # [[1, 2, 3], [4, 0, 0]]
cj.array.remove_duplicate_items(['hi', 'hi', 'ih'])  # ['hi', 'ih'] 
cj.array.get_cols([['line1_col1', 'line1_col2'],
                   ['line2_col1', 'line2_col2']])  # [['line1_col1', 'line2_col1'], ['line1_col2', 'line2_col2']]
cj.array.dotproduct([1, 2], [1, 2])  # 5

a = cj.array.array_gen((3, 3), 1)  # [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
b = cj.array.array_gen((3, 3), 1)  # [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
cj.array.dot(a, b)  # [[3, 3, 3], [3, 3, 3], [3, 3, 3]]
cj.mathtools.theta_angle((2, 2), (0, -2))  # 135.0

```

### 🧰 Utils

```python
import cereja.utils.time
import cereja as cj

data = {"key1": 'value1', "key2": 'value2', "key3": 'value3', "key4": 'value4'}

cj.utils.chunk(list(range(10)), batch_size=3)
# [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
cj.utils.chunk(list(range(10)), batch_size=3, fill_with=0, is_random=True)
# [[9, 7, 8], [0, 3, 2], [4, 1, 5], [6, 0, 0]]

# Invert Dict
cj.utils.invert_dict(data)
# Output -> {'value1': 'key1', 'value2': 'key2', 'value3': 'key3', 'value4': 'key4'}

# Get sample of large data
cj.utils.sample(data, k=2, is_random=True)
# Output -> {'key1': 'value1', 'key4': 'value4'}

cj.utils.fill([1, 2, 3, 4], max_size=20, with_=0)
# Output -> [1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

cj.utils.rescale_values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], granularity=4)
# Output -> [1, 3, 5, 7]

cj.utils.import_string('cereja.file._io.FileIO')
# Output -> <class 'cereja.file._io.FileIO'>

cj.utils.list_methods(cj.Path)
# Output -> ['change_current_dir', 'cp', 'get_current_dir', 'join', 'list_dir', 'list_files', 'mv', 'rm', 'rsplit', 'split']


cj.utils.string_to_literal('[1,2,3,4]')
# Output -> [1, 2, 3, 4]

cereja.utils.time.time_format(3600)
# Output -> '01:00:00'

cj.utils.truncate("Cereja is fun.", k=3)
# Output -> 'Cer...'

data = [[1, 2, 3], [3, 3, 3]]
cj.utils.is_iterable(data)  # True
cj.utils.is_sequence(data)  # True
cj.utils.is_numeric_sequence(data)  # True
```

[See Usage - Jupyter Notebook](./docs/cereja_example.ipynb)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cereja",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "progress bar, utils, array, pln, file utils",
    "author": null,
    "author_email": "Joab Leite <leitejoab@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fa/c0/3e988af33d68bfa32a77a33a3a715790041441bff79ff05974846f5e62b8/cereja-2.0.5.tar.gz",
    "platform": null,
    "description": "# Cereja \ud83c\udf52\n\n![Python package](https://github.com/jlsneto/cereja/workflows/Python%20package/badge.svg)\n[![PyPI version](https://badge.fury.io/py/cereja.svg)](https://badge.fury.io/py/cereja)\n[![Downloads](https://pepy.tech/badge/cereja)](https://pepy.tech/project/cereja)\n[![MIT LICENSE](https://img.shields.io/pypi/l/pyzipcode-cli.svg)](LICENSE)\n[![Issues](https://camo.githubusercontent.com/926d8ca67df15de5bd1abac234c0603d94f66c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/jlsneto/cereja/issues/new/choose)\n[![Get start on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jlsneto/cereja/blob/master/docs/cereja_example.ipynb)\n\n<div align=\"center\">\n <img src=\"https://i.ibb.co/Fw8SSfd/cereja-logo.png\" height=\"300\" width=\"300\" alt=\"CEREJA\">\n</div>\n\n*Cereja was written only with the Standard Python Library, and it was a great way to improve knowledge in the Language\nalso to avoid the rewriting of code.*\n\n## Getting Started DEV\n\nDon't be shy \\0/ ... Clone the repository and submit a function or module you made or use some function you liked.\n\nSee [CONTRIBUTING](CONTRIBUTING.md) \ud83d\udcbb\n\n## Setup\n\n* [Python 3.6+](https://www.python.org/downloads/ \"Download python\")\n* [Pip3](https://pip.pypa.io \"Download Pip\")\n\n## Install\n\n```\npip install --user cereja\n```\n\nor for all users\n\n```\npip install cereja\n```\n\n## Cereja Example usage\n\nSee some of the Cereja tools\n\nTo access the *Cereja's* tools you need to import it `import cereja as cj`.\n\n### \ud83d\udcdd [FileIO](docs/file.md)\n\n#### Create new files\n\n```python\nimport cereja as cj\n\nfile_json = cj.FileIO.create('./json_new_file.json', data={'k': 'v', 'k2': 'v2'})\n\nfile_txt = cj.FileIO.create('./txt_new_file.txt', ['line1', 'line2', 'line3'])\n\nfile_json.save()\nfile_txt.save()\n\nprint(file_json.exists)\n# True\nprint(file_txt.exists)\n# True\n\n\n# see what you can do .txt file\nprint(cj.can_do(file_txt))\n\n# see what you can do .json file\nprint(cj.can_do(file_json))\n```\n\n#### Load and edit files\n\n```python\nimport cereja as cj\n\nfile_json = cj.FileIO.load('./json_new_file.json')\n\nprint(file_json.data)\n# {'k': 'v', 'k2': 'v2'}\n\nfile_json.add(key='new_key', value='value')\nprint(file_json.data)\n# {'k': 'v', 'k2': 'v2', 'new_key': 'value'}\n\nfile_txt = cj.FileIO.load('./txt_new_file.txt')\n\nprint(file_txt.data)\n# ['line1', 'line2', 'line3']\n\nfile_txt.add('line4')\nprint(file_txt.data)\n# ['line1', 'line2', 'line3', 'line4']\n\nfile_txt.save(exist_ok=True)  # Override\nfile_json.save(exist_ok=True)  # Override\n```\n\n### \ud83d\udccd Path\n\n```python\nimport cereja as cj\n\nfile_path = cj.Path('/my/path/file.ext')\nprint(cj.can_do(file_path))\n# ['change_current_dir', 'cp', 'created_at', 'exists', 'get_current_dir', 'is_dir', 'is_file', 'is_hidden', 'is_link', 'join', 'last_access', 'list_dir', 'list_files', 'mv', 'name', 'parent', 'parent_name', 'parts', 'path', 'rm', 'root', 'rsplit', 'sep', 'split', 'stem', 'suffix', 'updated_at', 'uri']\n```\n\n### \ud83c\udd97 HTTP Requests\n\n```python\nimport cereja as cj\n\n# Change url, headers and data values.\nurl = 'localhost:8000/example'\nheaders = {'Authorization': 'TOKEN'} # optional\ndata = {'q': 'test'} # optional\n\nresponse = cj.request.post(url, data=data, headers=headers)\n\nif response.code == 200:\n    data = response.data\n    # have a fun!\n```\n\n### \u23f3 [Progress](docs/display.md)\n\n```python\nimport cereja as cj\nimport time\n\nmy_iterable = ['Cereja', 'is', 'very', 'easy']\n\nfor i in cj.Progress.prog(my_iterable):\n    print(f\"current: {i}\")\n    time.sleep(2)\n\n# Output on terminal ...\n\n# \ud83c\udf52 Sys[out] \u00bb current: Cereja \n# \ud83c\udf52 Sys[out] \u00bb current: is \n# \ud83c\udf52 Cereja Progress \u00bb [\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b0\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1\u25b1] - 50.00% - \ud83d\udd62 00:00:02 estimated\n\n\n```\n\n### \ud83e\udde0 [Data Preparation](docs/ml.md)\n\n\ud83d\udcca **Freq**\n\n```python\nimport cereja as cj\n\nfreq = cj.Freq([1, 2, 3, 3, 10, 10, 4, 4, 4, 4])\n# Output -> Freq({1: 1, 2: 1, 3: 2, 10: 2, 4: 4})\n\nfreq.most_common(2)\n# Output -> {4: 4, 3: 2}\n\nfreq.least_freq(2)\n# Output -> {2: 1, 1: 1}\n\nfreq.probability\n# Output -> OrderedDict([(4, 0.4), (3, 0.2), (10, 0.2), (1, 0.1), (2, 0.1)])\n\nfreq.sample(min_freq=1, max_freq=2)\n# Output -> {3: 2, 10: 2, 1: 1, 2: 1}\n\n# Save json file.\nfreq.to_json('./freq.json')\n```\n\n\ud83e\uddf9 **Text Preprocess**\n\n```python\nimport cereja as cj\n\ntext = \"Oi tudo bem?? meu nome \u00e9 joab!\"\n\ntext = cj.preprocess.remove_extra_chars(text)\nprint(text)\n# Output -> 'Oi tudo bem? meu nome \u00e9 joab!'\n\ntext = cj.preprocess.separate(text, sep=['?', '!'])\n# Output -> 'Oi tudo bem ? meu nome \u00e9 joab !'\n\ntext = cj.preprocess.accent_remove(text)\n# Output -> 'Oi tudo bem ? meu nome e joab !'\n\n# and more ..\n\n# You can use class Preprocessor ...\npreprocessor = cj.Preprocessor(stop_words=(),\n                               punctuation='!?,.', to_lower=True, is_remove_punctuation=False,\n                               is_remove_stop_words=False,\n                               is_remove_accent=True)\n\nprint(preprocessor.preprocess(text))\n# Output -> 'oi tudo bem ? meu nome e joab !'\n\nprint(preprocessor.preprocess(text, is_destructive=True))\n# Output -> 'oi tudo bem meu nome e joab'\n\n```\n\n\ud83d\udd23 **Tokenizer**\n\n```python\nimport cereja as cj\n\ntext = ['oi tudo bem meu nome \u00e9 joab']\n\ntokenizer = cj.Tokenizer(text, use_unk=True)\n\n# tokens 0 to 9 is UNK\n# hash_ used to replace UNK\ntoken_sequence, hash_ = tokenizer.encode('meu nome \u00e9 Neymar J\u00fanior')\n# Output -> [([10, 12, 11, 0, 1], 'eeb755960ce70c')]\n\ndecoded_sequence = tokenizer.decode(token_sequence, hash_=hash_)\n# Output -> 'meu nome \u00e9 Neymar J\u00fanior'\n\n```\n\n\u23f8 **Corpus**\n\nGreat training and test separator.\n\n```python\nimport cereja as cj\n\nX = ['how are you?', 'my name is Joab', 'I like coffee', 'how are you joab?', 'how', 'we are the world']\nY = ['como voc\u00ea est\u00e1?', 'meu nome \u00e9 Joab', 'Eu gosto de caf\u00e9', 'Como voc\u00ea est\u00e1 joab?', 'como', 'N\u00f3s somos o mundo']\n\ncorpus = cj.Corpus(source_data=X, target_data=Y, source_name='en', target_name='pt')\nprint(corpus)  # Corpus(examples: 6 - source_vocab_size: 13 - target_vocab_size:15)\nprint(corpus.source)  # LanguageData(examples: 6 - vocab_size: 13)\nprint(corpus.target)  # LanguageData(examples: 6 - vocab_size: 15)\n\ncorpus.source.phrases_freq\n# Counter({'how are you': 1, 'my name is joab': 1, 'i like coffee': 1, 'how are you joab': 1, 'how': 1, 'we are the world': 1})\n\ncorpus.source.word_freq\n# Counter({'how': 3, 'are': 3, 'you': 2, 'joab': 2, 'my': 1, 'name': 1, 'is': 1, 'i': 1, 'like': 1, 'coffee': 1, 'we': 1, 'the': 1, 'world': 1})\n\ncorpus.target.phrases_freq\n# Counter({'como voc\u00ea est\u00e1': 1, 'meu nome \u00e9 joab': 1, 'eu gosto de caf\u00e9': 1, 'como voc\u00ea est\u00e1 joab': 1, 'como': 1, 'n\u00f3s somos o mundo': 1})\n\ncorpus.target.words_freq\n# Counter({'como': 3, 'voc\u00ea': 2, 'est\u00e1': 2, 'joab': 2, 'meu': 1, 'nome': 1, '\u00e9': 1, 'eu': 1, 'gosto': 1, 'de': 1, 'caf\u00e9': 1, 'n\u00f3s': 1, 'somos': 1, 'o': 1, 'mundo': 1})\n\n# split_data function guarantees test data without data identical to training\n# and only with vocabulary that exists in training\ntrain, test = corpus.split_data()  # default percent of training is 80%\n```\n\n### \ud83d\udd22 Array\n\n```python\nimport cereja as cj\n\ncj.array.is_empty(data)  # False\ncj.array.get_shape(data)  # (2, 3)\n\ndata = cj.array.flatten(data)  # [1, 2, 3, 3, 3, 3]\ncj.array.prod(data)  # 162\ncj.array.sub(data)  # -13\ncj.array.div(data)  # 0.006172839506172839\n\ncj.array.rand_n(0.0, 2.0, n=3)  # [0.3001196087729699, 0.639679494102923, 1.060200897124107]\ncj.array.rand_n(1, 10)  # 5.086403830031244\ncj.array.array_randn((3, 3,\n                      3))  # [[[0.015077210355770374, 0.014298110484612511, 0.030410666810216064], [0.029319083335697604, 0.0072365209507707666, 0.010677361074992], [0.010576754075922935, 0.04146379877648334, 0.02188348813336284]], [[0.0451851551098092, 0.037074906805326824, 0.0032484586475421007], [0.025633380630695347, 0.010312669541918484, 0.0373624007621097], [0.047923908102496145, 0.0027939333359724224, 0.05976224377251878]], [[0.046869510719106486, 0.008325638358172866, 0.0038702998343255893], [0.06475268683502387, 0.0035638592537234623, 0.06551037943638163], [0.043317416824708604, 0.06579372884523939, 0.2477564291871006]]]\ncj.chunk(data=[1, 2, 3, 4], batch_size=3, fill_with=0)  # [[1, 2, 3], [4, 0, 0]]\ncj.array.remove_duplicate_items(['hi', 'hi', 'ih'])  # ['hi', 'ih'] \ncj.array.get_cols([['line1_col1', 'line1_col2'],\n                   ['line2_col1', 'line2_col2']])  # [['line1_col1', 'line2_col1'], ['line1_col2', 'line2_col2']]\ncj.array.dotproduct([1, 2], [1, 2])  # 5\n\na = cj.array.array_gen((3, 3), 1)  # [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\nb = cj.array.array_gen((3, 3), 1)  # [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\ncj.array.dot(a, b)  # [[3, 3, 3], [3, 3, 3], [3, 3, 3]]\ncj.mathtools.theta_angle((2, 2), (0, -2))  # 135.0\n\n```\n\n### \ud83e\uddf0 Utils\n\n```python\nimport cereja.utils.time\nimport cereja as cj\n\ndata = {\"key1\": 'value1', \"key2\": 'value2', \"key3\": 'value3', \"key4\": 'value4'}\n\ncj.utils.chunk(list(range(10)), batch_size=3)\n# [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]\ncj.utils.chunk(list(range(10)), batch_size=3, fill_with=0, is_random=True)\n# [[9, 7, 8], [0, 3, 2], [4, 1, 5], [6, 0, 0]]\n\n# Invert Dict\ncj.utils.invert_dict(data)\n# Output -> {'value1': 'key1', 'value2': 'key2', 'value3': 'key3', 'value4': 'key4'}\n\n# Get sample of large data\ncj.utils.sample(data, k=2, is_random=True)\n# Output -> {'key1': 'value1', 'key4': 'value4'}\n\ncj.utils.fill([1, 2, 3, 4], max_size=20, with_=0)\n# Output -> [1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n\ncj.utils.rescale_values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], granularity=4)\n# Output -> [1, 3, 5, 7]\n\ncj.utils.import_string('cereja.file._io.FileIO')\n# Output -> <class 'cereja.file._io.FileIO'>\n\ncj.utils.list_methods(cj.Path)\n# Output -> ['change_current_dir', 'cp', 'get_current_dir', 'join', 'list_dir', 'list_files', 'mv', 'rm', 'rsplit', 'split']\n\n\ncj.utils.string_to_literal('[1,2,3,4]')\n# Output -> [1, 2, 3, 4]\n\ncereja.utils.time.time_format(3600)\n# Output -> '01:00:00'\n\ncj.utils.truncate(\"Cereja is fun.\", k=3)\n# Output -> 'Cer...'\n\ndata = [[1, 2, 3], [3, 3, 3]]\ncj.utils.is_iterable(data)  # True\ncj.utils.is_sequence(data)  # True\ncj.utils.is_numeric_sequence(data)  # True\n```\n\n[See Usage - Jupyter Notebook](./docs/cereja_example.ipynb)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2019 The Cereja Project  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Cereja is a bundle of useful functions that I don't want to rewrite.",
    "version": "2.0.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/cereja-project/cereja/issues/new/choose",
        "Homepage": "https://github.com/cereja-project/cereja"
    },
    "split_keywords": [
        "progress bar",
        " utils",
        " array",
        " pln",
        " file utils"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf224c97aa0fda749945f1f4d333b0e0082b6fcdf3b5fe945068530ba7ff08ac",
                "md5": "89350289f3e8313fd1de64d13a635087",
                "sha256": "352dd55d813631dd1458965265ea7154922da6b75bf65f23cbef390c4dd44141"
            },
            "downloads": -1,
            "filename": "cereja-2.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89350289f3e8313fd1de64d13a635087",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 143237,
            "upload_time": "2024-10-26T10:47:34",
            "upload_time_iso_8601": "2024-10-26T10:47:34.067856Z",
            "url": "https://files.pythonhosted.org/packages/bf/22/4c97aa0fda749945f1f4d333b0e0082b6fcdf3b5fe945068530ba7ff08ac/cereja-2.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fac03e988af33d68bfa32a77a33a3a715790041441bff79ff05974846f5e62b8",
                "md5": "4ebb61755470c14573fb8c5d5e3d0a8e",
                "sha256": "c73d54548b3739b4fc44e9449ff463db8bab0e2d0c412e677e43198f6bca56d9"
            },
            "downloads": -1,
            "filename": "cereja-2.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "4ebb61755470c14573fb8c5d5e3d0a8e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 125918,
            "upload_time": "2024-10-26T10:47:35",
            "upload_time_iso_8601": "2024-10-26T10:47:35.791185Z",
            "url": "https://files.pythonhosted.org/packages/fa/c0/3e988af33d68bfa32a77a33a3a715790041441bff79ff05974846f5e62b8/cereja-2.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-26 10:47:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cereja-project",
    "github_project": "cereja",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cereja"
}
        
Elapsed time: 0.34465s