File size: 1,034 Bytes
a9ea03f
 
 
ca2592c
a9ea03f
 
 
 
 
 
 
ca2592c
 
 
 
 
a9ea03f
ca2592c
a9ea03f
 
 
 
 
 
 
 
ca2592c
 
 
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
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-output");

    const fixed = await fixCommas(commaFixingInput.value);

    commaFixingParagraph.textContent = `Our model: ${fixed.main}\n\nBaseline model: ${fixed.baseline}`
});