Skip to content
Snippets Groups Projects
Commit 5184facd authored by Tarek Shah's avatar Tarek Shah
Browse files

added BERT summarizer to frontend

parent 090e32be
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import os
#summarizers
import summarizer_implementations.t5 as t5
import summarizer_implementations.nltk_summarizer as nltk
import summarizer_implementations.bert as bert
app = Flask(__name__)
app.config['JWT_SECRET_KEY'] = 'PI'
......@@ -297,8 +298,7 @@ def v1_summarize_bert():
glob += f.read()
# summary = t5.summarize(collection["collection_data"]["glob"])
# summary = bert.summarize(glob)
summary = nltk.summarize(glob)
summary = bert.summarize(glob)
if summary:
database.update_collection_summary(collection_info["collection_id"],summary)
......
// import './login.css';
import { Backdrop, Box, Button, CircularProgress, TextField, List, ListItem, ListItemButton, ListItemText, ListItemIcon } from '@mui/material';
import React, { useState, useEffect } from 'react'
import { dbGetCollection, dbGetItems, dbUpdateCollectionGlob, dbUpdateCollectionSummary, dbUpdateCollectionSummaryNLTK } from './database_util';
import { dbGetCollection, dbGetItems, dbUpdateCollectionGlob, dbUpdateCollectionSummary, dbUpdateCollectionSummaryNLTK, dbUpdateCollectionSummaryBERT } from './database_util';
import AddIcon from '@mui/icons-material/Add';
......@@ -54,6 +54,16 @@ const CollectionEditor = (props) => {
setOpen(false);
}
const generateBERTSummary = async () => {
setOpen(true);
let id = props.collection["collection_id"]
await saveGlob()
await dbUpdateCollectionSummaryBERT(id)
console.log(id,props.collection)
props.onCollectionUpdate(await dbGetCollection(id))
setOpen(false);
}
// console.log("loadedRawFiles", props.loadedRawFiles)
......@@ -96,6 +106,7 @@ const CollectionEditor = (props) => {
<Button onClick={saveGlob}>(Debug) Save Glob</Button>
<Button onClick={generateT5Summary}>Generate T5 Summary</Button>
<Button onClick={generateNLTKSummary}>Generate NLTK summary</Button>
<Button onClick={generateBERTSummary}>Generate BERT summary</Button>
<Backdrop
open={open}
......
......@@ -157,4 +157,32 @@ export const dbUpdateCollectionSummaryNLTK = async (collection_id) => {
return result
};
export const dbUpdateCollectionSummaryBERT = async (collection_id) => {
let result = await fetch(
"http://127.0.0.1:5000/api/v1/summarize/bert",
{
method: "POST", // or 'PUT'
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(
{
"collection_info":{
"collection_id": collection_id,
}
}
),
}
)
.then((response) => response.json())
.then((response) => {
if (response["status"] == "success") {
return response;
}
});
return result
};
export default dbCreateCollection;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment