première version
This commit is contained in:
76
cat.svg
Normal file
76
cat.svg
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 128 128" style="enable-background:new 0 0 128 128;" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path style="fill:#FFC022;" d="M110.47,59.02c9.51-24.83,3.65-43.83,0.29-49.28c-1.33-2.16-3.89-2.76-6.25-2.02
|
||||
C98.29,9.68,81.5,23.4,74.08,42.6"/>
|
||||
</g>
|
||||
<path style="fill:#FFC022;" d="M17.53,59.02c-9.51-24.83-3.65-43.83-0.29-49.28c1.33-2.16,3.89-2.76,6.25-2.02
|
||||
C29.71,9.68,46.5,23.4,53.92,42.6"/>
|
||||
<path style="fill:#FFC022;" d="M114.11,70.76C112.31,44.78,94.44,26.3,64,26.3S15.69,44.78,13.89,70.76
|
||||
c-1.05,15.14,5.05,28.01,17.09,36.21c0,0,12.21,9.88,33.02,10.14c20.81-0.26,33.02-10.14,33.02-10.14
|
||||
C109.05,98.77,115.16,85.9,114.11,70.76z"/>
|
||||
<path style="opacity:0.47;fill:#FF7043;" d="M54.12,45.02c1.13,0.96,3.42,0.82,4.75-0.72c1.61-1.87,3.29-8.17,2.24-17.91
|
||||
c-4.67,0.17-9.09,0.84-13.21,1.97C51.23,33.82,52.03,43.24,54.12,45.02z"/>
|
||||
<path style="opacity:0.47;fill:#FF7043;" d="M73.88,45.02c-1.13,0.96-3.42,0.82-4.75-0.72c-1.61-1.87-3.29-8.17-2.24-17.91
|
||||
c4.67,0.17,9.09,0.84,13.21,1.97C76.77,33.82,75.97,43.24,73.88,45.02z"/>
|
||||
<g>
|
||||
<g>
|
||||
|
||||
<line style="fill:none;stroke:#9E9E9E;stroke-width:3;stroke-linecap:round;stroke-miterlimit:10;" x1="122.41" y1="64.63" x2="105.49" y2="72.96"/>
|
||||
|
||||
<line style="fill:none;stroke:#9E9E9E;stroke-width:3;stroke-linecap:round;stroke-miterlimit:10;" x1="124.51" y1="76.83" x2="106.36" y2="79.99"/>
|
||||
|
||||
<line style="fill:none;stroke:#9E9E9E;stroke-width:3;stroke-linecap:round;stroke-miterlimit:10;" x1="122.41" y1="92.97" x2="105.49" y2="87.19"/>
|
||||
</g>
|
||||
<g>
|
||||
|
||||
<line style="fill:none;stroke:#9E9E9E;stroke-width:3;stroke-linecap:round;stroke-miterlimit:10;" x1="5.59" y1="64.63" x2="22.51" y2="72.96"/>
|
||||
|
||||
<line style="fill:none;stroke:#9E9E9E;stroke-width:3;stroke-linecap:round;stroke-miterlimit:10;" x1="3.49" y1="76.83" x2="21.64" y2="79.99"/>
|
||||
|
||||
<line style="fill:none;stroke:#9E9E9E;stroke-width:3;stroke-linecap:round;stroke-miterlimit:10;" x1="5.59" y1="92.97" x2="22.51" y2="87.19"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path d="M32.56,70.26c-0.3,0-0.6-0.06-0.89-0.19c-1.12-0.49-1.64-1.8-1.14-2.92c0.35-0.8,3.6-7.85,9.35-7.85
|
||||
c5.68,0,9.17,6.74,9.55,7.51c0.54,1.1,0.09,2.43-1.01,2.97c-1.1,0.54-2.17-0.12-2.97-1.01c-0.97-1.08-3.08-3.5-5.57-3.5
|
||||
c-2.5,0-4.58,2.59-5.28,3.65C34.09,69.69,33.41,70.26,32.56,70.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path d="M95.44,70.26c0.3,0,0.6-0.06,0.89-0.19c1.12-0.49,1.64-1.8,1.14-2.92c-0.35-0.8-3.6-7.85-9.35-7.85
|
||||
c-5.68,0-9.17,6.74-9.55,7.51c-0.54,1.1-0.09,2.43,1.01,2.97c1.1,0.54,2.17-0.12,2.97-1.01c0.97-1.08,3.08-3.5,5.57-3.5
|
||||
c2.5,0,4.58,2.59,5.28,3.65C93.91,69.69,94.59,70.26,95.44,70.26z"/>
|
||||
</g>
|
||||
</g>
|
||||
<path d="M55.96,76.98c-0.05-2.86,4.06-4.24,7.95-4.3c3.89-0.07,8.07,1.2,8.12,4.06s-4.86,6.64-7.95,6.64S56.01,79.84,55.96,76.98z"
|
||||
/>
|
||||
<path style="fill:#FFFFFF;" d="M90.06,90.38c-1.64-1.67-4.29-2.16-6.75-1.24c-2.71,1.02-11,4.13-15.22,1.45
|
||||
c-3.71-2.35-3.51-7.13-3.51-7.13h-1.57c0,0,0.25,5.21-3.11,7.13c-4.35,2.5-12.51-0.44-15.22-1.45c-2.45-0.92-5.1-0.43-6.75,1.24
|
||||
c-1.55,1.57-1.82,3.82-0.72,5.88c2.32,4.35,10.58,11.71,26.78,11.77c16.2-0.05,24.46-7.42,26.78-11.77
|
||||
C91.88,94.2,91.61,91.95,90.06,90.38z"/>
|
||||
<path d="M91.58,88.8c-1.74-1.89-4.54-2.44-7.14-1.4c-2.87,1.15-11.64,4.68-16.11,1.64c-3.93-2.66-2.33-6.8-2.33-6.8h-4
|
||||
c0,0,1.22,4.62-2.33,6.8c-4.61,2.83-13.24-0.5-16.11-1.64c-2.6-1.04-5.4-0.49-7.14,1.4c-1.64,1.78-1.93,4.33-0.76,6.66
|
||||
c2.46,4.92,11.2,13.26,28.34,13.32c17.15-0.06,25.88-8.4,28.34-13.32C93.51,93.13,93.22,90.58,91.58,88.8z M89.66,94.12
|
||||
c-2.01,4.01-9.95,11.61-25.66,11.66c-15.71-0.06-23.65-7.65-25.66-11.66c-0.61-1.23-0.51-2.43,0.28-3.29
|
||||
c0.57-0.62,1.4-0.95,2.3-0.95c0.49,0,1.01,0.1,1.52,0.3c5.61,2.25,13.68,4.83,18.89,1.36c1.2-0.8,2.04-1.46,2.64-2
|
||||
c0.01,0.01,0.02,0.02,0.03,0.02c0.01-0.01,0.02-0.02,0.03-0.02c0.6,0.54,1.45,1.2,2.64,2c5.21,3.47,13.28,0.89,18.89-1.36
|
||||
c0.51-0.2,1.02-0.3,1.52-0.3c0.9,0,1.73,0.33,2.3,0.95C90.17,91.7,90.27,92.89,89.66,94.12z"/>
|
||||
<g>
|
||||
<line style="fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;" x1="42.93" y1="89.54" x2="42.93" y2="101.87"/>
|
||||
<line style="fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;" x1="53.47" y1="91.5" x2="53.47" y2="105.15"/>
|
||||
<line style="fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;" x1="64" y1="86.8" x2="64" y2="106.71"/>
|
||||
<line style="fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;" x1="85.07" y1="88.39" x2="85.07" y2="100.72"/>
|
||||
<line style="fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;" x1="74.53" y1="90.48" x2="74.53" y2="104.66"/>
|
||||
</g>
|
||||
<g>
|
||||
<path style="fill:#FFD1D1;" d="M92.16,36.23c-1.54-1.29-1.5-3.37-0.6-5.16c2.16-4.31,7.33-8.78,9.16-10.23
|
||||
c3-2.38,5.32-3.18,6.21,0.65c1.65,7.08,1.52,16.69-0.25,21.99c-0.62,1.87-2.54,2.86-4.02,1.57L92.16,36.23z"/>
|
||||
</g>
|
||||
<path style="fill:#FFD1D1;" d="M35.84,36.23c1.54-1.29,1.5-3.37,0.6-5.16c-2.16-4.31-7.33-8.78-9.16-10.23
|
||||
c-3-2.38-5.32-3.18-6.21,0.65c-1.65,7.08-1.52,16.69,0.25,21.99c0.62,1.87,2.54,2.86,4.02,1.57L35.84,36.23z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
9971
fra_mixed_2009_10K-sentences.txt
Normal file
9971
fra_mixed_2009_10K-sentences.txt
Normal file
File diff suppressed because it is too large
Load Diff
84
index.php
Normal file
84
index.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ChatEB</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
|
||||
<link rel="icon" type="image/svg+xml" href="cat.svg">
|
||||
<style>
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
#conversation {
|
||||
flex-grow: 2;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="container">
|
||||
<h1>ChatEB</h1>
|
||||
<div id="conversation">
|
||||
<p>😸 Posez-moi toutes vos questions !</p>
|
||||
</div>
|
||||
<form id="formulaire" action="question.php" method="post" role="group">
|
||||
<textarea id="question" name="question" placeholder="Ma question" required></textarea>
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>
|
||||
</main>
|
||||
<script>
|
||||
const formulaire = document.getElementById('formulaire');
|
||||
const bouton = document.querySelector('button[type="submit"]');
|
||||
const conversation = document.getElementById('conversation');
|
||||
const question = document.getElementById('question');
|
||||
|
||||
question.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter' && !e.ctrlKey && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
e.target.form.requestSubmit();
|
||||
}
|
||||
});
|
||||
|
||||
formulaire.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
bouton.disabled = true;
|
||||
bouton.setAttribute("aria-busy", true)
|
||||
const formulaireData = new FormData(formulaire);
|
||||
const citation = document.createElement('blockquote');
|
||||
citation.innerText = formulaireData.get('question');
|
||||
conversation.appendChild(citation);
|
||||
|
||||
formulaire.reset();
|
||||
const requete = await fetch(formulaire.action, {
|
||||
method: formulaire.method,
|
||||
body: formulaireData
|
||||
});
|
||||
|
||||
const paragraphe = document.createElement('p');
|
||||
paragraphe.setAttribute('aria-busy', 'true');
|
||||
conversation.appendChild(paragraphe);
|
||||
const reponse = await requete.text();
|
||||
paragraphe.setAttribute('aria-busy', 'false');
|
||||
Array.from(reponse).forEach((lettre, i) => {
|
||||
setTimeout(() => {
|
||||
if (lettre == "\n") paragraphe.innerHTML += "<br>";
|
||||
else paragraphe.innerHTML += lettre;
|
||||
}, i * 40);
|
||||
});
|
||||
setTimeout(() => {
|
||||
conversation.innerHTML += "<p>😸 Voulez-vous que je réponde à une autre question ?</p>";
|
||||
conversation.scrollTop = conversation.scrollHeight;
|
||||
bouton.disabled = false;
|
||||
bouton.setAttribute("aria-busy", false);
|
||||
}, reponse.length * 40);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
22
markov.py
Normal file
22
markov.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from collections import defaultdict
|
||||
from random import choice, randrange
|
||||
|
||||
suivants = defaultdict(list)
|
||||
|
||||
with open("fra_mixed_2009_10K-sentences.txt", "r", encoding="utf-8") as fichier:
|
||||
for phrase in fichier:
|
||||
antepenultieme, penultieme = "", ""
|
||||
for word in phrase.split():
|
||||
suivants[(antepenultieme, penultieme)].append(word)
|
||||
antepenultieme, penultieme = penultieme, word
|
||||
|
||||
phrases = []
|
||||
for _ in range(randrange(1, 4)):
|
||||
antepenultieme, penultieme = "", ""
|
||||
phrase = []
|
||||
while mots_possibles := suivants[(antepenultieme, penultieme)]:
|
||||
mot_suivants = choice(mots_possibles)
|
||||
phrase.append(mot_suivants)
|
||||
antepenultieme, penultieme = penultieme, mot_suivants
|
||||
phrases.append(" ".join(phrase))
|
||||
print("\n".join(phrases))
|
||||
1
question.php
Normal file
1
question.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php echo `python markov.py`; ?>
|
||||
BIN
thumbnail.png
Normal file
BIN
thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
Reference in New Issue
Block a user