File: predict.html

package info (click to toggle)
fasttext 0.9.2%2Bds-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,952 kB
  • sloc: cpp: 5,459; python: 2,427; javascript: 635; sh: 621; makefile: 106; xml: 81; perl: 43
file content (42 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
    <script type="module">
        const printVector = function(predictions, limit) {
            limit = limit || Infinity;

            for (let i=0; i<predictions.size() && i<limit; i++){
                let prediction = predictions.get(i);
                console.log(predictions.get(i));
            }
        }

        import {FastText, addOnPostRun} from "./fasttext.js";

        addOnPostRun(() => {
            let ft = new FastText();

            const url = "lid.176.ftz";
            ft.loadModel(url).then(model => {
                let text = "Bonjour à tous. Ceci est du français";
                console.log(text);
                printVector(model.predict(text, 5, 0.0));

                text = "Hello, world. This is english";
                console.log(text);
                printVector(model.predict(text, 5, 0.0));

                text = "Merhaba dünya. Bu da türkçe"
                console.log(text);
                printVector(model.predict(text, 5, 0.0));
            });
        });

    </script>
</body>

</html>