File size: 1,183 Bytes
a9ea03f
 
 
ca2592c
a9ea03f
 
 
 
 
 
 
ca2592c
 
 
 
 
a9ea03f
ca2592c
a9ea03f
 
 
 
 
 
c33d981
 
a9ea03f
ca2592c
 
c33d981
 
a9ea03f
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
const commaFixingForm = document.querySelector(".comma-fixing-form");

const fixCommas = async (text) => {
    let request = {
        method: "POST",
        body: JSON.stringify({
            s: text
        }),
        headers: {
            "Content-type": "application/json; charset=UTF-8"
        }
    };
    const baselineResponse = await fetch(`baseline/fix-commas/`, request);
    const fixerResponse = await fetch(`fix-commas/`, request);
    const baselineJson = await baselineResponse.json();
    const inferJson = await fixerResponse.json();

    return {baseline: baselineJson.s, main: inferJson.s};
};

commaFixingForm.addEventListener("submit", async (event) => {
    event.preventDefault();

    const commaFixingInput = document.getElementById("comma-fixing-input");
    const commaFixingParagraph = document.querySelector(".comma-fixing-main-output");
    const commaFixingBaselineParagraph = document.querySelector(".comma-fixing-baseline-output");

    const fixed = await fixCommas(commaFixingInput.value);

    commaFixingParagraph.textContent = `Our model: ${fixed.main}`
    commaFixingBaselineParagraph.textContent = `Baseline model: ${fixed.baseline}`
});