Skip to content

Commit

Permalink
kj
Browse files Browse the repository at this point in the history
  • Loading branch information
ym001 committed May 5, 2020
1 parent 4d741ed commit 3181f02
Show file tree
Hide file tree
Showing 30 changed files with 626 additions and 1,099 deletions.
2 changes: 1 addition & 1 deletion Exemples/exemple_Generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

def main(args):

Generation(documents=['text a','text b'])
Generation(seed='What do you do if a bird shits on your car?')
return 0

if __name__ == '__main__':
Expand Down
12 changes: 10 additions & 2 deletions Manteia.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Metadata-Version: 1.1
Metadata-Version: 2.1
Name: Manteia
Version: 0.0.10
Summary: deep learning,NLP,classification,text,bert,distilbert,albert,xlnet,roberta,gpt2
Expand All @@ -17,14 +17,21 @@ Description: Manteia - proclaim the good word

     pip install Manteia

Example of use:
Example of use Classification:

     >>> from Manteia.Classification import Classification
     >>> # Initializing a list of texts,labels
     >>> documents=['a text','text b']
     >>> labels=['a','b']
     >>> Classification(documents,labels)

Example of use Generation:

     >>> from Manteia.Generation import Generation
     >>> Generation(seed='What do you do if a bird shits on your car?')
If you're a car owner, you're supposed to be able to call the police
and have them take the bird off the car.

This code is licensed under MIT.

Platform: UNKNOWN
Expand All @@ -35,3 +42,4 @@ Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Communications
Description-Content-Type: text/markdown
14 changes: 13 additions & 1 deletion Manteia/Classification.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
"""
.. module:: useful_1
:platform: Unix, Windows
:synopsis: A useful module indeed.
.. moduleauthor:: Andrew Carter <andrew@invalid.com>
"""
import numpy as np
import random
import pandas as pd
Expand All @@ -7,7 +15,6 @@
import time
import datetime
import gc
############
from .Model import *
from .Preprocess import Preprocess

Expand All @@ -16,19 +23,24 @@ class Classification:
This is the class to classify text in categorie a NLP task.
Args:
model_name (:obj:`string`, optional, defaults to 'bert'):
give the name of a model.
documents (:obj:`list`, optional, defaults to None):
A list of documents.
labels (:obj:`float`, optional, defaults to None):
A list of labels.
Example::
from Manteia.Classification import Classification
# Initializing a list of texts,labels
documents=['a text','text b']
labels=['a','b']
Classification(documents,labels)
Attributes:
"""
def __init__(self,model_name ='bert',documents = None,labels = None):
Expand Down
19 changes: 11 additions & 8 deletions Manteia/Generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Generation:
This is the class to gnerate text in categorie a NLP task.
Args:
model_name (:obj:`string`, optional, defaults to 'bert'):
give the name of a model.
documents (:obj:`list`, optional, defaults to None):
Expand All @@ -24,30 +25,32 @@ class Generation:
A list of labels.
Example::
from Manteia.Classification import Classification
# Initializing a list of texts,labels
documents=['a text','text b']
labels=['a','b']
Classification(documents,labels)
Attributes:
"""
def __init__(self,model_name ='gpt2-medium',documents = None,labels = None):
def __init__(self,model_name ='gpt2-medium',documents = None,seed = None):


model = Model(model_name =model_name)
model.load()
text_loader = Create_DataLoader_generation(documents)
model.BATCH_SIZE = 16
model.EPOCHS = 10
model.LEARNING_RATE = 3e-5
model.WARMUP_STEPS = 500
model.MAX_SEQ_LEN = 400

model.fit_generation(text_loader)

output = model.predict_generation('joke')
output_text = decode_text(output,model.tokenizer)
print(output_text)
if documents!=None:
text_loader = Create_DataLoader_generation(documents)
model.fit_generation(text_loader)
if seed!=None:
output = model.predict_generation(seed)
output_text = decode_text(output,model.tokenizer)
print(output_text)


def test(self):
Expand Down
Binary file modified Manteia/Generation.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions Manteia/Preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Preprocess:
This is the class to preprocess text before task NLP.
Args:
lang='english',preprocess=True):
documents (:obj:`list`, optional, defaults to None):
Expand All @@ -61,6 +62,7 @@ class Preprocess:
make preprocess in init.
Example::
from Manteia.Preprocess import *
import pandas as pd
# Initializing a list of texts,labels
Expand All @@ -70,6 +72,7 @@ class Preprocess:
pp.load()
pp.df_documents=clean(pp.df_documents)
print(pp.df_documents.head())
Attributes:
"""
def __init__(self,documents=None,labels=None,percentage=1.0,size_by_nb_sample=False,nb_sample=None,path='./Document/',lang='english',preprocess=True):
Expand Down
2 changes: 1 addition & 1 deletion Manteia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
reminiscent.
"""

__version__ = "0.0.10"
__version__ = "0.0.11"


from Manteia import Classification
Expand Down
Binary file modified Manteia/__pycache__/Classification.cpython-37.pyc
Binary file not shown.
Binary file modified Manteia/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ You can install it with pip:

     pip install Manteia

Example of use:
Example of use Classification:

     >>> from Manteia.Classification import Classification
     >>> # Initializing a list of texts,labels
     >>> documents=['a text','text b']
     >>> labels=['a','b']
     >>> Classification(documents,labels)

Example of use Generation:

     >>> from Manteia.Generation import Generation
     >>> Generation(seed='What do you do if a bird shits on your car?')
If you're a car owner, you're supposed to be able to call the police
and have them take the bird off the car.

This code is licensed under MIT.
Binary file modified dist/Manteia-0.0.10.tar.gz
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/help.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 9705faf389976c454255769e850134fa
config: 1e88ebff7d9b4b70f98a7dbb0ba95ecd
tags: 645f666f9bcd5a90fca523b33c5a78b7
2 changes: 1 addition & 1 deletion docs/_build/html/_sources/help.rst.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Need helps
==========

lkk
lkkb
25 changes: 18 additions & 7 deletions docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@

Simple Documentation Tutorial : Mantéïa
=======================================

Another Head
------------

some texte.
print('Hello')
>>Hello

Guide
-----

.. automodule:: Manteia.Classification
:members:

.. automodule:: Manteia.Generation
:members:

.. automodule:: Manteia.Model
:members:

.. automodule:: Manteia.Preprocess
:members:

.. automodule:: Manteia.Visualisation
:members:

.. automodule:: Manteia.Statistic
:members:

.. automodule:: Manteia.Task
:members:

.. toctree::
:maxdepth: 2

Expand Down

0 comments on commit 3181f02

Please sign in to comment.