Toggle navigation
Toggle navigation
This project
Loading...
Sign in
양지수
/
HCG_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
양지수
2021-05-19 02:14:54 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bd38d0c585df8c9f614ecedbf77e0c4454ecd5ec
bd38d0c5
1 parent
baf31ac8
가중치 조정코드 수정필요
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
33 deletions
knu/KnuSentiLex/KNU_edit.py
knu/KnuSentiLex/KNU_edit.py
View file @
bd38d0c
...
...
@@ -27,14 +27,14 @@ class KnuSL():
def
data_list
(
wordname
):
with
open
(
'KnuSentiLex/data/SentiWord_info.json'
,
encoding
=
'utf-8-sig'
,
mode
=
'r'
)
as
f
:
data
=
json
.
load
(
f
)
result
=
[
'X'
,
'X'
]
result
=
[
0
,
0
]
for
i
in
range
(
0
,
len
(
data
)):
if
data
[
i
][
'word'
]
==
wordname
:
result
.
pop
()
result
.
pop
()
result
.
append
(
data
[
i
][
'word_root'
])
result
.
append
(
data
[
i
][
'polarity'
]
)
result
.
append
(
int
(
data
[
i
][
'polarity'
])
)
r_word
=
result
[
0
]
#어근
s_word
=
result
[
1
]
#극성
...
...
@@ -106,7 +106,9 @@ for v in range(len(new_date)):
if
new_date
[
v
]
==
list_df
[
i
][
0
]:
Setlist
[
v
]
.
append
(
list_df
[
i
][
1
][
j
])
print
(
Setlist
)
print
(
Setlist
[
0
][
0
])
#2021.01.01
print
(
Setlist
[
0
][
1
][
1
])
#극성 0
print
(
type
(
Setlist
[
0
][
1
][
1
]))
#극성 모든 타입 int
#print(list_df[0][1][0]) 키워드와 극성 ['HMM…"체질개선해', 'X']
#print(list_df[0][1][0][1]) 극성 x
...
...
@@ -137,36 +139,37 @@ for i in range(len(Stock_data)):
del
Stock_data
[
i
][
7
]
#상장주식 수 삭제 / 결과:'일자', '종가', '등락률', '시가', '고가', '저가', '거래량'
print
(
Stock_data
)
def
Calpercentage
(
a
,
b
):
def
Calpercentage
(
a
,
b
):
#시초가 대비 고점/저점 비율
return
abs
(
a
-
b
)
/
a
*
100
'''
if(list_df[0][0].split('.')[:3]) == Stock_data[1][0].split('/'): # 날짜 비교
if Calpercentage(Stock_data[1][3],Stock_data[1][4]) > 2 : #당일 시가 대비 고가가 2퍼 높을때
for j in range(len(list_df[0][0])):
if list_df[0][1][j][1] == 'X':
list_df[0][1][j][1]= 1
else:
list_df[0][1][j][1]+=1
elif Calpercentage(Stock_data[1][3],Stock_data[1][5])< -2 : #당일 시가 대비 저가가 2퍼 낮을 때
for j in range(len(list_df[0][0])):
if list_df[0][1][j][1] == 'X':
list_df[0][1][j][1]= -1
for
i
in
range
(
len
(
Stock_data
)
-
1
):
for
k
in
range
(
len
(
Setlist
)):
if
(
Stock_data
[
i
][
0
]
.
split
(
'/'
)
==
Setlist
[
k
][
0
]
.
split
(
'.'
)[:
3
]):
# 날짜 비교
if
Calpercentage
(
Stock_data
[
i
][
3
],
Stock_data
[
i
][
4
])
>
2
:
#당일 시가 대비 고가가 2퍼 높을때
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
1
else
:
Setlist
[
0
][
j
][
1
]
+=
1
elif
Calpercentage
(
Stock_data
[
i
][
3
],
Stock_data
[
i
][
5
])
<
-
2
:
#당일 시가 대비 저가가 2퍼 낮을 때
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
-
1
else
:
Setlist
[
0
][
j
][
1
]
-=
1
else
:
list_df[0][1][j][1]-=1
else:
if Stock_data[2][2]>0: # 다음날 주가 등락률이 양수면
for j in range(len(list_df[0][0])): #어제뉴스는 호재 취급
if list_df[0][1][j][1] == 'X':
list_df[0][1][j][1] = 1
else:
list_df[0][1][j][1] += 1
else :
for j in range(len(list_df[0][0])): # 음수면 어제 뉴스는 악재 취급
if list_df[0][1][j][1] == 'X':
list_df[0][1][j][1] = -1
else:
list_df[0][1][j][1] -= 1
else:
while(
'''
if
Stock_data
[
i
+
1
][
2
]
>
0
:
# 다음날 주가 등락률이 양수면
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
#어제뉴스는 호재 취급
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
1
else
:
Setlist
[
0
][
j
][
1
]
+=
1
elif
Stock_data
[
i
+
1
][
2
]
<
0
:
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
# 음수면 어제 뉴스는 악재 취급
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
-
1
else
:
Setlist
[
0
][
j
][
1
]
-=
1
print
(
Setlist
)
...
...
Please
register
or
login
to post a comment