Repository navigation
Develop #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
galaxyhm
wants to merge
3
commits into
master
Choose a base branch
from
develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Develop #99
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| db_connect.json | ||
| db_connect.json | ||
| fast_api.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,8 +12,8 @@ | |||||||||||
| import re | ||||||||||||
| from . import models | ||||||||||||
| from django.db.models import Q | ||||||||||||
| import random | ||||||||||||
| import pandas as pd | ||||||||||||
| from django.conf import settings | ||||||||||||
|
|
||||||||||||
| # Create your views here. | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
@@ -38,9 +38,6 @@ def index(request): | |||||||||||
| # return render(request, 'board/join_membership.html', context) | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| # def summarize(request): | ||||||||||||
| # return render() | ||||||||||||
|
|
||||||||||||
| @require_http_methods(['POST']) | ||||||||||||
| def news_summarizae_request_ajax(request): | ||||||||||||
| # print(request.body) | ||||||||||||
|
|
@@ -53,9 +50,9 @@ def news_summarizae_request_ajax(request): | |||||||||||
| url = regex.match(url) | ||||||||||||
| print(url) | ||||||||||||
|
|
||||||||||||
| if not url : | ||||||||||||
| if not url: | ||||||||||||
| print('error 올바르지 않는 url') | ||||||||||||
| # return 해서 어떻게 처리하셈 | ||||||||||||
| return JsonResponse({'status':'false', 'message': '잘못된 url'}, status=500) | ||||||||||||
| url = url[0] | ||||||||||||
|
|
||||||||||||
| # DB에서 해당 url에 맞는 데이터 필드 가져옴. | ||||||||||||
|
|
@@ -70,7 +67,7 @@ def news_summarizae_request_ajax(request): | |||||||||||
| # 입력받은 URL을 가진 기사가 데이터베이스에 존재하는지 확인. | ||||||||||||
| if models.NewsArticleInfo.objects.filter(url=url) : | ||||||||||||
| # 해당 URL을 가진 기사가 데이터베이스에 존재하면, 수정일자를 비교하여 최신 버전인지 확인. | ||||||||||||
| if models.NewsArticleInfo.objects.filter(Q(url=url) & Q(modify_date__isnull=True)) or models.NewsArticleInfo.objects.filter(Q(url=url) & Q(modify_date = crawl_data_dict.get('modify_date'))): | ||||||||||||
| if (models.NewsArticleInfo.objects.filter(Q(url=url) & Q(modify_date__isnull=True)) and crawl_data_dict.get('modify_date') != -1 ) or models.NewsArticleInfo.objects.filter(Q(url=url) & Q(modify_date = crawl_data_dict.get('modify_date'))): | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] This conditional is hard to read. Consider extracting parts into well-named boolean variables or simplifying the logic for clarity.
Suggested change
|
||||||||||||
| news_article = models.NewsArticleInfo.objects.get(url=url) | ||||||||||||
|
|
||||||||||||
| return JsonResponse( | ||||||||||||
|
|
@@ -83,7 +80,7 @@ def news_summarizae_request_ajax(request): | |||||||||||
| } | ||||||||||||
| ) | ||||||||||||
| # 최신 버전이 아닐 경우, 기사의 내용을 업데이트하고 요약을 다시 생성. | ||||||||||||
| else : | ||||||||||||
| else: | ||||||||||||
| news_article = models.NewsArticleInfo.objects.get(url=url) | ||||||||||||
| news_article.detail = crawl_data_dict['text'] | ||||||||||||
| news_article.modify_date = crawl_data_dict['modify_date'] | ||||||||||||
|
|
@@ -96,7 +93,7 @@ def news_summarizae_request_ajax(request): | |||||||||||
|
|
||||||||||||
| #정상적인 응답을 못 받았을때 | ||||||||||||
| if r.status_code != 200 : | ||||||||||||
| pass | ||||||||||||
| return JsonResponse({'status': 'false', 'message': 'fastapi가 응답 없음'}, status=500) | ||||||||||||
| json_data = r.json()['message'][0].get('summary_text').strip() | ||||||||||||
| news_article.summary = json_data | ||||||||||||
| news_article.update() | ||||||||||||
|
|
@@ -168,16 +165,7 @@ def news_comments_request_ajax(request): | |||||||||||
| # comments가 0 인지 확인 | ||||||||||||
| if crawl_comment_list == [] : | ||||||||||||
| return JsonResponse({'comments': []}) | ||||||||||||
| # crawl_comment_dict = dict() | ||||||||||||
| # crawl_comment_dict['comments_data'] = crawl_comment_list | ||||||||||||
|
|
||||||||||||
| # DB에 저장및 조회 할 수 있는 코드 보류 | ||||||||||||
| # for comment in crawl_comment_list: | ||||||||||||
| # comments_object.username = comment['userName'] | ||||||||||||
| # comments_object.contents = comment['contents'] | ||||||||||||
| # comments_object.sympathyCount = comment['sympathyCount'] | ||||||||||||
| # comments_object.antipathyCount = comment['antipathyCount'] | ||||||||||||
| # comments_object.save() | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| r = requests.post('http://13.208.62.74:8908/emotion/text/', data=json.dumps({'comments': crawl_comment_list})) | ||||||||||||
|
|
@@ -195,41 +183,7 @@ def news_comments_request_ajax(request): | |||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| @require_http_methods(['POST']) | ||||||||||||
| def text_summarizae_request_ajax(request): | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| cond = { | ||||||||||||
| "url" : "https://n.news.naver.com/article/018/0005472525" | ||||||||||||
|
|
||||||||||||
| } | ||||||||||||
| jsonData = json.dumps(cond) | ||||||||||||
| r = requests.post('http://localhost:10000/crawl/naver/', data=jsonData) | ||||||||||||
| json_data = r.json() | ||||||||||||
|
|
||||||||||||
| print(json_data) | ||||||||||||
| print(r.status_code) | ||||||||||||
| # print(r.json()) | ||||||||||||
| # data = json.loads(m.body) | ||||||||||||
| context = { | ||||||||||||
| 'result' : 'error ' | ||||||||||||
| } | ||||||||||||
| # if data['url'] : | ||||||||||||
| return JsonResponse(r.json()) | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def history_request_ajax(request): | ||||||||||||
| return render(request, 'board/history.html') | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def ajax_test(request) : | ||||||||||||
|
|
||||||||||||
| context = {'test' :'test'} | ||||||||||||
|
|
||||||||||||
| return JsonResponse(context) | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,4 @@ | ||
| asgiref==3.6.0 | ||
| beautifulsoup4==4.12.2 | ||
| certifi==2022.12.7 | ||
| charset-normalizer==3.1.0 | ||
| Django==3.2.18 | ||
| django-extensions==3.2.1 | ||
| idna==3.4 | ||
| lxml==4.9.2 | ||
| mpmath==1.3.0 | ||
| mysqlclient==2.1.1 | ||
| networkx==3.1 | ||
| numpy==1.24.3 | ||
| packaging==23.1 | ||
| pytz==2023.3 | ||
| PyYAML==6.0 | ||
| regex==2023.3.23 | ||
| requests==2.29.0 | ||
| six==1.16.0 | ||
| soupsieve==2.4.1 | ||
| sqlparse==0.4.4 | ||
| sympy==1.11.1 | ||
| tokenizers==0.13.3 | ||
| typing_extensions==4.5.0 | ||
| tzdata==2023.3 | ||
| urllib3==1.26.15 | ||
| lxml==4.9.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,4 @@ | ||
| transformers>=4.28.1 | ||
| fastapi>=0.95.1 | ||
| pydantic>=1.10.7 | ||
| pymysql>=1.0.3 | ||
| mariadb>=1.1.6 | ||
| requests>=2.28.2 | ||
| numpy>=1.24.3 | ||
| bs4>=0.0.1 | ||
| beautifulsoup4>=4.12.2 | ||
| lxml | ||
| pytorch | ||
| fastapi | ||
| uvicorn[standard] | ||
| torch |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
.close()on the file handle inside awith open(...)block is redundant becausewithalready handles closing.