text_processing_and_machine_learning_tal
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
text_processing_and_machine_learning [2020/05/28 14:53] – [Installation] serge | text_processing_and_machine_learning_tal [2022/02/08 16:00] (Version actuelle) – Tag0 Removed: text_gen serge | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ======Text Processing and Machine Learning====== | + | ======Text Processing and Machine Learning |
- | + | <WRAP center round box 60% centeralign> | |
- | <WRAP center round box 80% centeralign> | + | **{{tagpage> |
- | **{{tagpage> | + | </ |
+ | <WRAP center round box 60% centeralign> | ||
+ | **[[les_pages_intelligence_artificielle_en_details|Les Pages Intelligence Artificielle en détails]]** | ||
</ | </ | ||
<WRAP center round box 80% centeralign> | <WRAP center round box 80% centeralign> | ||
- | **[[https:// | + | **{{tagpage> |
- | **[[https:// | + | |
</ | </ | ||
=====Définitions ===== | =====Définitions ===== | ||
Ligne 61: | Ligne 62: | ||
import nltk | import nltk | ||
+ | from nltk.corpus import treebank | ||
raw = """ | raw = """ | ||
Ligne 68: | Ligne 70: | ||
""" | """ | ||
+ | # ### Récupération d'un texte | ||
# Tokenize the text | # Tokenize the text | ||
tokens = nltk.wordpunct_tokenize(raw) | tokens = nltk.wordpunct_tokenize(raw) | ||
+ | print(f' | ||
# Je ne garde que du 2ème mot au 30ème | # Je ne garde que du 2ème mot au 30ème | ||
tokens =tokens[2: | tokens =tokens[2: | ||
+ | print(f' | ||
+ | # ### Normalizing 1 | ||
# Création d'un NLTK Text | # Création d'un NLTK Text | ||
text = nltk.Text(tokens) | text = nltk.Text(tokens) | ||
Ligne 86: | Ligne 92: | ||
vocab = sorted(set(words)) | vocab = sorted(set(words)) | ||
print(f' | print(f' | ||
+ | |||
+ | # ### Normalizing 2 | ||
+ | # Tous les mots sans exception | ||
+ | mots_brut = nltk.word_tokenize(raw) | ||
+ | print(f' | ||
+ | print(f' | ||
+ | |||
+ | # Sans la ponctuation et apostrophes | ||
+ | tokenizer = nltk.RegexpTokenizer(r' | ||
+ | bons_mots = tokenizer.tokenize(raw.lower()) | ||
+ | print(f' | ||
+ | print(f' | ||
+ | |||
+ | # Fréquence des mots, sans la ponctuation et apostrophes | ||
+ | tokenizer = nltk.RegexpTokenizer(r' | ||
+ | corpora = tokenizer.tokenize(raw.lower()) | ||
+ | freq = nltk.FreqDist(corpora) | ||
+ | print(f' | ||
+ | for k, v in freq.items(): | ||
+ | print(f' | ||
+ | |||
+ | # ### Some simple things you can do with NLTK | ||
+ | tokens = nltk.word_tokenize(raw) | ||
+ | tagged = nltk.pos_tag(tokens) | ||
+ | print(f' | ||
+ | |||
+ | # Identify named entities | ||
+ | entities = nltk.chunk.ne_chunk(tagged) | ||
+ | print(f' | ||
+ | |||
+ | # Display a parse tree: | ||
+ | t = treebank.parsed_sents(' | ||
+ | t.draw() | ||
</ | </ | ||
Ligne 102: | Ligne 141: | ||
Tous les mots bruts = [' | Tous les mots bruts = [' | ||
Nombre de mots brut = 37 | Nombre de mots brut = 37 | ||
- | |||
Tous les bons mots = [' | Tous les bons mots = [' | ||
Ligne 116: | Ligne 154: | ||
prince 1 | prince 1 | ||
l 1 | l 1 | ||
- | etc ..... | + | etc ... |
+ | tagged[0:6] = [(' | ||
+ | entities = (S | ||
+ | À/JJ | ||
+ | (ORGANIZATION Monseigneur/ | ||
+ | de/IN | ||
+ | (PERSON Bourgogne/ | ||
+ | ,/, | ||
+ | l/NN | ||
+ | ’/NNP | ||
+ | unique/NN | ||
+ | objet/NN | ||
+ | du/NN | ||
+ | soin/NN | ||
+ | des/NNS | ||
+ | (PERSON Immortels/ | ||
+ | ,/, | ||
+ | (GPE Souffrez/ | ||
+ | que/NN | ||
+ | mon/NN | ||
+ | encens/ | ||
+ | parfume/ | ||
+ | vos/NN | ||
+ | (PERSON Autels/ | ||
+ | | ||
+ | Je/NNP | ||
+ | vous/JJ | ||
+ | offre/NN | ||
+ | un/JJ | ||
+ | peu/NN | ||
+ | tard/NN | ||
+ | ces/VBZ | ||
+ | présents/ | ||
+ | de/IN | ||
+ | ma/NN | ||
+ | (ORGANIZATION Muse/NNP) | ||
+ | ;/:) | ||
</ | </ | ||
+ | {{ : | ||
- | ===Exploration du corpus=== | ||
- | =====Fin===== | + | =====Apprentissage avec des Fables de La Fontaine===== |
+ | [[TAL Traitement Automatique du Langage avec des Fables de La Fontaine]] | ||
- | {{tag> | + | {{tag> ia python |
text_processing_and_machine_learning_tal.1590677610.txt.gz · Dernière modification : 2020/05/28 14:53 de serge