Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| import redis | |
| import sys | |
| import time | |
| import json | |
| import random | |
| redis_conn = redis.Redis(host='localhost', port=6379) | |
| def producer(): | |
| for i in range(20): |
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
| #[no_mangle] | |
| pub extern "C" fn cosine_similarity(array1:*const i32,array2:*const i32,len: isize) -> f32{ | |
| let mut numerator: i32 = 0; | |
| for i in 0..len { | |
| numerator += unsafe { *array1.offset(i) } * unsafe { *array2.offset(i) }; | |
| } | |
| let mut x: i32 = 0; | |
| for i in 0..len{ | |
| println!("{}",unsafe { *array1.offset(i) } as f32); |
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
| import multiprocessing | |
| import queue | |
| class TaskManager: | |
| def __init__(self): | |
| self.taskq = multiprocessing.Queue() | |
| self.resultq = multiprocessing.Queue() | |
| def worker(self): | |
| while True: |
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
| from gensim.parsing.preprocessing import STOPWORDS | |
| import re | |
| import numpy as np | |
| from numpy.linalg import norm | |
| def find_similarity(x,y): | |
| #print(STOPWORDS) | |
| token_rules = r'\s+|[,\.]' |
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
| import numpy as np | |
| from numpy.linalg import norm | |
| import math | |
| vector1 = np.array([1, 2]) | |
| vector2 = np.array([4, 5]) | |
| cosine_similarity = np.dot(vector1,vector2)/(norm(vector1)*norm(vector2)) | |
| print("cosine similarity:",cosine_similarity) |
NewerOlder