Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
strategy_embedding
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
strategy_embedding
Commits
671df37a
Commit
671df37a
authored
Nov 17, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update path
parent
bcc01f2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
11 deletions
+8
-11
api.py
word_vector/api.py
+1
-6
tractate.py
word_vector/tractate.py
+7
-5
No files found.
word_vector/api.py
View file @
671df37a
...
...
@@ -12,7 +12,7 @@ from utils.es import es_scan
from
utils.files
import
DATA_PATH
,
MODEL_PATH
from
utils.message
import
send_msg_to_dingtalk
from
word_vector.tractate
import
tractate_click_ids_model_path
from
word_vector.tractate
import
TRACTATE_CLICK_IDS_MODEL
model_output_name
=
"w2v_model"
model_path
=
os
.
path
.
join
(
MODEL_PATH
,
model_output_name
)
...
...
@@ -21,11 +21,6 @@ try:
except
Exception
as
e
:
print
(
e
)
try
:
TRACTATE_CLICK_IDS_MODEL
=
word2vec
.
Word2Vec
.
load
(
tractate_click_ids_model_path
)
except
Exception
as
e
:
print
(
e
)
class
W2vSentences
:
def
__init__
(
self
,
f_name
):
...
...
word_vector/tractate.py
View file @
671df37a
import
multiprocessing
import
os
import
sys
import
time
from
collections
import
defaultdict
sys
.
path
.
append
(
os
.
path
.
realpath
(
"."
))
import
time
from
gensim.models
import
Word2Vec
,
word2vec
from
utils.date
import
get_ndays_before_no_minus
,
get_ndays_before_with_format
from
utils.files
import
DATA_PATH
,
MODEL_PATH
from
utils.spark
import
get_spark
from
word_vector.api
import
clicked_tractate_ids_item2vec_model
tractate_click_ids_model_path
=
os
.
path
.
join
(
MODEL_PATH
,
"tractate_click_ids_item2vec_model"
)
try
:
TRACTATE_CLICK_IDS_MODEL
=
word2vec
.
Word2Vec
.
load
(
tractate_click_ids_model_path
)
except
Exception
as
e
:
print
(
e
)
def
get_tracate_click_data
(
spark
,
start
,
end
):
reg
=
r"""^\\d+$"""
...
...
@@ -165,7 +167,7 @@ if __name__ == "__main__":
save_clicked_tractate_ids_item2vec
()
for
id
in
[
"84375"
,
"148764"
,
"368399"
]:
print
(
clicked_tractate_ids_item2vec_model
(
id
,
n
=
5
))
print
(
TRACTATE_CLICK_IDS_MODEL
.
wv
.
most_similar
(
id
,
top
n
=
5
))
print
(
"total cost: {:.2f}mins"
.
format
((
time
.
time
()
-
begin_time
)
/
60
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment