Sys-Traceback-1

Sat 17 May 2025

import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml311; pyv: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
haystack-ai==2.8.0
ollama-haystack is not installed in the current environment.
python-dotenv==0.21.0
import traceback
def divide_numbers …

Category: basics

Read More

Sys Version

Sat 17 May 2025

title: "Sys Version" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import sys
print(sys.version)
3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]


Score: 0

Category: basics

Read More

Template

Sat 17 May 2025

title: "Template" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false




Score: 0

Category: basics

Read More

Text-Diff

Sat 17 May 2025

title: "Text Diff" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import difflib
str1 = "I understand how customers do their choice. Difference"
str2 = "I understand how customers do their choice."
seq = difflib.SequenceMatcher(None, str1, str2)
d = seq.ratio()*100
d
88.65979381443299
def get_similarity(str1, str2 …

Category: basics

Read More

Text-Similarity

Sat 17 May 2025

title: "Text Similarity" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


import nltk, string
from sklearn.feature_extraction.text import TfidfVectorizer
stemmer = nltk.stem.porter.PorterStemmer()
remove_punctuation_map = dict((ord(char), None) for char in string.punctuation)
def stem_tokens(tokens):
    return [stemmer.stem(item) for item in tokens]
'''remove …

Category: basics

Read More

Text-Similarity-Finder

Sat 17 May 2025

title: "Text Similarity Finder" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity  
def findSimilarity(param1, param2):
    documents = (
        param1,
        param2
    )
    tfidf_vectorizer = TfidfVectorizer()
    tfidf_matrix = tfidf_vectorizer.fit_transform(documents)
    cosine = cosine_similarity(tfidf_matrix[0:1], tfidf_matrix)

    print(cosine)
findSimilarity("In …

Category: basics

Read More

Time With Periods

Sat 17 May 2025

title: "Time With Periods" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import pandas as pd
times = pd.date_range('2000-01-01', periods=4)

print(times)
DatetimeIndex(['2000-01-01', '2000-01-02', '2000-01-03', '2000-01-04'], dtype='datetime64[ns]', freq='D')
for time in times:
    print(time)
2000-01-01 00:00:00
2000-01-02 …

Category: basics

Read More

Timeit-Simple

Sat 17 May 2025

title: "Timeit Simple" author: "Rj" date: 2019-04-24 description: "-" type: technical_note draft: false


import timeit
import numpy as np
def add(x, y):
    return x + y
repeat_number = 100000
e = timeit.repeat(
    stmt='''add(a, b)''', 
    setup='''a=2; b=3;from __main__ import add''', 
    repeat=3,
    number=repeat_number)
print('Method: {}, Avg …

Category: basics

Read More

Timeit-Simple-2

Sat 17 May 2025

title: "Timeit Simple 2" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import timeit
def some_function():
    return map(lambda x: x^2, range(10))
time1 = timeit.timeit(some_function)
print(time1)
0.39235781200113706
print(time1)
0.39235781200113706

Score: 5

Category: basics

Read More

Total-Score-Calculator

Sat 17 May 2025

import random
total_score_list = []
for i in range(6):

    current_score = random.randint(0, 6)

    print(f'ball {i}, current score: {current_score}')
    total_score_list.append(current_score)
ball 0, current score: 3
ball 1, current score: 0
ball 2, current score: 5
ball 3, current score: 1
ball 4, current score: 5
ball 5 …

Category: basics

Read More
Page 15 of 17

« Prev Next »