This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def resume(sent_score): | |
| ''' | |
| Trouve les phrases les plus pertinentes dans un texte | |
| Input: | |
| - sent_score : liste de dictionnaires. Chaque dictionnare contient la phrase et le score | |
| Output: | |
| - resume : str composé des phrases les plus pertinentes | |
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def resume(sent_score): | |
| ''' | |
| Trouve les phrases les plus pertinentes dans un texte | |
| Input: | |
| - sent_score : liste de dictionnaires. Chaque dictionnare contient la phrase et le score | |
| Output: | |
| - resume : str composé des phrases les plus pertinentes | |
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def score_sent(doc): | |
| ''' | |
| Calcule le score de chaque phrase pour doc | |
| Input: | |
| - doc : liste de phrases | |
| Output: | |
| - sent_score : liste de score de chaque phrase | |
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.feature_extraction.text import TfidfTransformer | |
| from sklearn.feature_extraction.text import CountVectorizer | |
| from sklearn.feature_extraction.text import TfidfVectorizer | |
| #obtenir le vocabulaire | |
| vectorizer = TfidfVectorizer() | |
| vectorizer.fit(corpus) | |
| voc = vectorizer.get_feature_names() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def clean(text): | |
| ''' | |
| Permet de preprocess text. Attention, text est divisé en phrases. | |
| Exemple : [Fichtre ! dit Gavroche., Voilà qu'on me tue mes morts., Une deuxième balle fit étinceler le pavé | |
| à côté de lui., Une troisième renversa son panier.] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #on calcule les prédictions (a_1*x + a_2) | |
| y_hat = x@a | |
| #on calcule la valeur de la fonction de perte MSE | |
| loss = ((y_hat-y)**2).mean() | |
| #on clone les poids par soucis de code | |
| prev_wgts = a.data.clone() | |
| #on optimise selon les paramètres de Pytorch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #on calcule les prédictions (a_1*x + a_2) | |
| y_hat = x@a | |
| #on calcule la valeur de la perte MSE | |
| loss = ((y_hat-y)**2).mean() | |
| #on clone les poids par soucis de code | |
| prev_wgts = a.data.clone | |
| #on optimise selon les paraùètres de pytorch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd |