Skip to content

Commit

Permalink
Merge pull request #250 from osamhack2021/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
cjnghn committed Oct 20, 2021
2 parents e9fa7ba + 92f12c4 commit 2f34d01
Show file tree
Hide file tree
Showing 17 changed files with 291 additions and 232 deletions.
10 changes: 10 additions & 0 deletions AI(BE)/riskout/extractive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Extractive Summarization
========================

## Gensim summarizer?
- Summarizing is based on ranks of text sentences using a variation of the TextRank algorithm.


## References
- [RaRe-Technologies/gensim](https://github.com/RaRe-Technologies/gensim)
- [Variations of the Similarity Function of TextRank for Automated Summarization, 2016](https://arxiv.org/abs/1602.03606)
19 changes: 19 additions & 0 deletions AI(BE)/riskout/fakenews/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Fake News Classifier
========================
## Model
| Model Accuracy | Train | Validation | Test |
|----------------|-------|------------|------|
| LSTM | 0.9774 | 0.98381 | 0.7544 |
| SenCNN | 0.9624 | 0.8016 | 0.7827 |
| BERT | 0.9662 | 0.8299 | 0.8070 |

- ์„ธ ๊ฐœ ๋ชจ๋ธ ๋ชจ๋‘ Early Stopping ์„ ์ ์šฉํ•œ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค.

## Dataset
๋ฐ์ดํ„ฐ์…‹์€ [SNU factcheck](https://factcheck.snu.ac.kr/)๋ฅผ ํฌ๋กค๋งํ•˜์—ฌ ์‚ฌ์‹ค, ๊ฑฐ์ง“์œผ๋กœ ๋ผ๋ฒจ๋งํ•˜์˜€์Œ.
๊ฑฐ์ง“ ๋ฐ์ดํ„ฐ์…‹์˜ ์–‘์ด ๋” ๋งŽ์•„์„œ ๋„ค์ด๋ฒ„ ๋‰ด์Šค์—์„œ ์ถ”๊ฐ€๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ชจ์•„ ๋‘ ๋ผ๋ฒจ๋ง๋œ ๋ฐ์ดํ„ฐ์˜ ํฌ๊ธฐ๊ฐ€ ๊ฐ™๊ฒŒ ํ•จ.

## References
- [A Study on Korean Fake news Detection Model Using Word Embedding, 2020](https://www.koreascience.or.kr/article/CFKO202022449680088.pdf)
- [Research Analysis in Automatic Fake News Detection, 2019](http://hiai.co.kr/wp-content/uploads/2019/12/%EB%85%BC%EB%AC%B8%EC%A6%9D%EB%B9%99_2019_02.pdf)

5 changes: 3 additions & 2 deletions WEB(BE)/analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def main():
if tup[9] not in date_list:
date_list.append(tup[9])

for date in date_list:
for date in date_list[:len(date_list) - 1]:
cur.execute("SELECT * FROM CrawlContents WHERE isAnalyzed = 0 AND category = 'news' AND created_at = ?", (date,))
ranked_list = dataRanker(cur.fetchall())

Expand All @@ -321,7 +321,8 @@ def main():
cur.execute("UPDATE CrawlContents SET isAnalyzed = 1 WHERE isAnalyzed = 0 AND category = 'news' AND created_at = ?", (date,))
conn.commit()

cur.execute("SELECT * FROM CrawlContents WHERE isAnalyzed = 0") # news๋Š” ์ด๋ฏธ analyzed ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— sns์™€ community๋งŒ ๋‚จ๋Š”๋‹ค
# ์˜ค๋Š˜ ์ด์ „์˜ news๋Š” ์ด๋ฏธ analyzed ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— "ํฌ๋กค๋ง ์‹œ์  ์˜ค๋Š˜ ๋‰ด์Šค ์ „๋ถ€", sns, community๊ฐ€ ๋‚จ๋Š”๋‹ค
cur.execute("SELECT * FROM CrawlContents WHERE isAnalyzed = 0")
important_data_list.extend(cur.fetchall())


Expand Down
Binary file removed WEB(BE)/crawler/crawler/database.db-journal
Binary file not shown.
2 changes: 1 addition & 1 deletion WEB(BE)/crawler/crawler/model/naver/NaverNewsSite.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_articleID(self, contents_url):
return article_id

def contentCheck(self, content):
if(len(content.body) < 800 or len(content.body) > 2000):
if(len(content.body) < 500 or len(content.body) > 2000):
raise length_error

return
2 changes: 1 addition & 1 deletion WEB(BE)/drf/detection_status/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ def getAnalyzedData(self, articleIds, period):
db_result = mongo.find_item(query, "riskout", "analyzed")
db_filtered = self.datetimeFormatter([v for _, v in enumerate(db_result)]) if (db_result.count()) else []

now = datetime.utcnow() + timedelta(hours=9)
now = datetime.utcnow() + timedelta(hours=9) - timedelta(days=4)
today_datetime = datetime(now.year, now.month, now.day)
today = datetime(now.year, now.month, now.day).strftime('%y-%m-%d')

Expand Down
18 changes: 9 additions & 9 deletions WEB(BE)/drf/secrets.example.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"SECRET_KEY": "asdfasdfasdfasdf",
"DEBUG": "True",
"ALLOWED_HOSTS": ["localhost", "http://localhost:3000"],
"EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend",
"EMAIL_HOST": "smtp.googlemail.com",
"EMAIL_USE_TLS": "True",
"EMAIL_PORT": 587,
"EMAIL_HOST_USER": "your.email@example.com",
"EMAIL_HOST_PASSWORD": "asdfasdfasdf*"
"SECRET_KEY": "asdfasdfasdfasdf",
"DEBUG": "False",
"ALLOWED_HOSTS": ["localhost", "http://localhost:3000"],
"EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend",
"EMAIL_HOST": "smtp.googlemail.com",
"EMAIL_USE_TLS": "True",
"EMAIL_PORT": 587,
"EMAIL_HOST_USER": "your.email@example.com",
"EMAIL_HOST_PASSWORD": "asdfasdfasdf*"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"overview": "๋ถํ•œ ๋Œ€์™ธ์„ ์ „๋งค์ฒด ์šฐ๋ฆฌ๋ฏผ์กฑ๋ผ๋ฆฌ ์™€ ํ†ต์ผ์˜ ๋ฉ”์•„๋ฆฌ, ์กฐ์„ ์˜ ์˜ค๋Š˜ ์€ ๊ฐ๊ฐ ๊น€์ •์€ ์ง‘๊ถŒ 10๋…„์„ ๊ธฐ๋…ํ•˜๋Š” ํŠน๋ณ„ ์›นํŽ˜์ด์ง€๋ฅผ ์‹ ์„คํ•˜๊ณ  ํ™ˆํŽ˜์ด์ง€ ์ฒซ ํ™”๋ฉด์— ์—ฐ๊ฒฐ ๋ฐฐ๋„ˆ๋ฅผ ๋„์› ๋‹ค.",
"period": 24,
"isDone": true,
"briefingGraphData": {
"secretsCount": 52,
"fakeNewsCount": 4,
Expand Down
87 changes: 50 additions & 37 deletions WEB(FE)/frontend/src/components/DetectionStatus/DetectionTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
Typography,
} from '@mui/material';
import SecretsTableRow from './SecretsTableRow';
import { searchState, useContents } from '../../atoms/searchState';
import { useSessionStorage } from '../../js/util';
import { useContents } from '../../atoms/searchState';
import useSearchInitEffect from '../../hooks/useSearchInitEffect';

import { useTheme } from '@mui/material/styles';
Expand All @@ -24,6 +24,7 @@ import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft';
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
import LastPageIcon from '@mui/icons-material/LastPage';
import PropTypes from 'prop-types';
import { useRecoilValue } from 'recoil';

function TablePaginationActions(props) {
const theme = useTheme();
Expand Down Expand Up @@ -97,9 +98,9 @@ TablePaginationActions.propTypes = {
export default function DetectionTable({ showDetailModal, toggleScrap }) {
useSearchInitEffect();
const contents = useContents();
const { isDone } = useRecoilValue(searchState);
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(4);

// Avoid a layout jump when reaching the last page with empty rows.
const emptyRows =
page > 0 ? Math.max(0, (1 + page) * rowsPerPage - contents.length) : 0;
Expand Down Expand Up @@ -165,41 +166,53 @@ export default function DetectionTable({ showDetailModal, toggleScrap }) {
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{contents &&
(rowsPerPage > 0
? contents.slice(
page * rowsPerPage,
page * rowsPerPage + rowsPerPage
)
: contents
).map((article, id) => (
<SecretsTableRow
key={id}
isAlreadyScrapped={isInCart(article._id)}
{...{ article, showDetailModal, toggleScrap }}
/>
))}
{emptyRows > 0 && (
<TableRow style={{ height: 53 * emptyRows }}>
<TableCell colSpan={6} />
</TableRow>
)}
</TableBody>
<TableFooter>
<TableRow>
<TablePagination
rowsPerPageOptions={[4]}
colSpan={4}
count={contents.length}
rowsPerPage={rowsPerPage}
page={page}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
ActionsComponent={TablePaginationActions}
/>
</TableRow>
</TableFooter>
{contents || isDone ? (
<>
<TableBody>
{(rowsPerPage > 0
? contents.slice(
page * rowsPerPage,
page * rowsPerPage + rowsPerPage
)
: contents
).map((article, id) => (
<SecretsTableRow
key={id}
isAlreadyScrapped={isInCart(article._id)}
{...{ article, showDetailModal, toggleScrap }}
/>
))}
{emptyRows > 0 && (
<TableRow style={{ height: 53 * emptyRows }}>
<TableCell colSpan={6} />
</TableRow>
)}
</TableBody>
<TableFooter>
<TableRow>
<TablePagination
rowsPerPageOptions={[4]}
colSpan={4}
count={contents.length}
rowsPerPage={rowsPerPage}
page={page}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
ActionsComponent={TablePaginationActions}
/>
</TableRow>
</TableFooter>
</>
) : (
<TableBody>
<TableCell></TableCell>
<TableCell align="center">
<Typography>ํ˜„์žฌ ๋ฐ์ดํ„ฐ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.</Typography>
</TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
</TableBody>
)}
</Table>
</TableContainer>
);
Expand Down
105 changes: 68 additions & 37 deletions WEB(FE)/frontend/src/components/Modal/LoginModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ const LoginModal = (props) => {
setUserPassword(e.target.value);
};

const onSubmit = (e) => {
e.preventDefault();
fetch('/api/user/login/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((json) => {
if (json.token) {
props.userHasAuthenticated(true, data.username, json.token);
alert('ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค.' + username + '๋‹˜.');
history.push('/presstrends');
props.setModal(true);
console.log(json);
} else {
alert('์•„์ด๋”” ๋˜๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํ™•์ธํ•ด์ฃผ์„ธ์š”.');
}
})
.catch((error) => alert(error));
};

const paperStyle = {
padding: '60px 68px 40px',
width: 450,
Expand All @@ -52,7 +76,7 @@ const LoginModal = (props) => {
};

const onClick = () => {
alert('๋ฐ๋ชจ ๋ฒ„์ „์—์„œ๋Š” ์ œ๊ณตํ•˜์ง€ ์•Š๋Š” ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค')
alert('๋ฒ ํƒ€ ๋ฒ„์ „์€ ์‚ฌ์ „์— ์Šน์ธ๋œ ์ธ์›๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.')
};

const fetchLoginApi = (e) => {
Expand Down Expand Up @@ -93,43 +117,50 @@ const LoginModal = (props) => {
<Grid align="left">
<h1 style={{ fontSize: '32px' }}>๋กœ๊ทธ์ธ</h1>
</Grid>
<Grid align="center">
<Box
sx={{ width: 314, height: 50, marginBottom: '1.2em', marginTop: 5 }}
>
<TextField
label="์•„์ด๋””"
placeholder="์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”"
fullWidth
required
onChange={handleNameChange}
variant="outlined"
/>
</Box>
<Box sx={{ width: 314, height: 50, marginBottom: '2em' }}>
<TextField
label="๋น„๋ฐ€๋ฒˆํ˜ธ"
placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”."
fullWidth
type="password"
required
variant="outlined"
onChange={handlePasswordChange}
onKeyDown={keyDown}
/>
</Box>
{/* */}
<Link sx={{ textDecoration: 'none' }}>
<Button
variant="contained"
style={btnstyle}
className="JoinLoign-button"
onClick={fetchLoginApi}

<form onSubmit={onSubmit}>
<Grid align="center">
<Box
sx={{
width: 314,
height: 50,
marginBottom: '1.2em',
marginTop: 5,
}}
>
๋กœ๊ทธ์ธ
</Button>
</Link>
</Grid>
<TextField
label="์•„์ด๋””"
placeholder="์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”"
fullWidth
required
onChange={handleNameChange}
variant="outlined"
/>
</Box>
<Box sx={{ width: 314, height: 50, marginBottom: '2em' }}>
<TextField
label="๋น„๋ฐ€๋ฒˆํ˜ธ"
placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”."
fullWidth
type="password"
required
variant="outlined"
onChange={handlePasswordChange}
/>
</Box>
{/* */}
<Link sx={{ textDecoration: 'none' }}>
<Button
type="submit"
variant="contained"
style={btnstyle}
className="JoinLoign-button"
>
๋กœ๊ทธ์ธ
</Button>
</Link>
</Grid>
</form>
<Box sx={{ display: 'flex', marginBottom: '5em' }}>
<Typography variant="subtitle1" sx={{}}>
<input type="checkbox" style={{ marginTop: '7px' }} />
Expand Down
40 changes: 18 additions & 22 deletions WEB(FE)/frontend/src/hooks/useSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,25 @@ export default function useSeacrh() {
alert('๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•œ ํ™”๋ฉด ์ž…๋‹ˆ๋‹ค.');
history.push('/login');
} else {
fetch('/api/nlp/analyze/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Token ${token}`,
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((json) => {
console.log('=========[api/nlp/analyze/]========');
console.log(json);
if (process.env.REACT_APP_USE_STATIC_RESPONSE == 'True') {
const searchUrl = `/static/SecretData.example.json`;
client.get(searchUrl).then((data) => {
setSearchList(data.data);
});
} else {
fetch('/api/nlp/analyze/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Token ${token}`,
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((json) => {
console.log(json);
});
}
}

const searchUrl = `/static/SecretData.example.json`;
async function fetchSearch() {
client.get(searchUrl).then((data) => {
setSearchList(data.data);
console.log(data.data);
});
}

fetchSearch();
}, [filterList]);
}
2 changes: 1 addition & 1 deletion WEB(FE)/frontend/src/hooks/useSearchInitEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useSearchInitEffect() {
const searchSetting = useRecoilValue(searchSettingState);
/* TODO searchSetting ์„ ์ด์šฉํ•ด์„œ params ๋„˜๊ฒจ์ฃผ๋Š” ์ฝ”๋“œ ์ž‘์„ฑ */
useEffect(() => {
if (Object.keys(search.contents).length !== 0) return;
if (!search.contents || Object.keys(search.contents).length !== 0) return;

//TODO: API ์„œ๋ฒ„ ๋ฐฐํฌ์‹œ ์ˆ˜์ •
async function fetchData() {
Expand Down
Loading

0 comments on commit 2f34d01

Please sign in to comment.