sem6labs 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sem6labs-0.1.0/MANIFEST.in +1 -0
- sem6labs-0.1.0/PKG-INFO +3 -0
- sem6labs-0.1.0/pyproject.toml +3 -0
- sem6labs-0.1.0/sem6labs/__init__.py +0 -0
- sem6labs-0.1.0/sem6labs/scaffold/1) BFS_DFS.py +55 -0
- sem6labs-0.1.0/sem6labs/scaffold/2) AStar.py +67 -0
- sem6labs-0.1.0/sem6labs/scaffold/3) GreedySearch_SSSP.py +79 -0
- sem6labs-0.1.0/sem6labs/scaffold/4) CSP_using_Nqueens.py +61 -0
- sem6labs-0.1.0/sem6labs/scaffold/5) Elementary_chatbot.py +56 -0
- sem6labs-0.1.0/sem6labs/scaffold/6) expertSystem_SMT.py +53 -0
- sem6labs-0.1.0/sem6labs/scaffold/KVM_installation.txt +14 -0
- sem6labs-0.1.0/sem6labs.egg-info/PKG-INFO +3 -0
- sem6labs-0.1.0/sem6labs.egg-info/SOURCES.txt +15 -0
- sem6labs-0.1.0/sem6labs.egg-info/dependency_links.txt +1 -0
- sem6labs-0.1.0/sem6labs.egg-info/top_level.txt +1 -0
- sem6labs-0.1.0/setup.cfg +4 -0
- sem6labs-0.1.0/setup.py +24 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include sem6/scaffold *
|
sem6labs-0.1.0/PKG-INFO
ADDED
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from collections import defaultdict, deque
|
|
2
|
+
|
|
3
|
+
#class for dfs and bfs
|
|
4
|
+
|
|
5
|
+
class Graph:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self.graph = defaultdict(list);
|
|
8
|
+
def add_edge(self, u, v):
|
|
9
|
+
self.graph[u].append(v)
|
|
10
|
+
self.graph[v].append(u)
|
|
11
|
+
|
|
12
|
+
# DFS
|
|
13
|
+
|
|
14
|
+
def dfsRecursive(self, vertex, visitedNode=None):
|
|
15
|
+
if visitedNode is None:
|
|
16
|
+
visitedNode = set()
|
|
17
|
+
visitedNode.add(vertex)
|
|
18
|
+
print(vertex,end=" ")
|
|
19
|
+
for neighbour in self.graph[vertex]:
|
|
20
|
+
if neighbour not in visitedNode:
|
|
21
|
+
self.dfsRecursive(neighbour,visitedNode)
|
|
22
|
+
|
|
23
|
+
#BFS
|
|
24
|
+
|
|
25
|
+
def bfs(self,start):
|
|
26
|
+
visited=set();
|
|
27
|
+
queue = deque([start])
|
|
28
|
+
visited.add(start);
|
|
29
|
+
while queue:
|
|
30
|
+
vertex = queue.popleft()
|
|
31
|
+
print(vertex,end=" ")
|
|
32
|
+
for neighbour in self.graph[vertex]:
|
|
33
|
+
if neighbour not in visited:
|
|
34
|
+
queue.append(neighbour)
|
|
35
|
+
visited.add(neighbour)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
g = Graph()
|
|
39
|
+
edges=[(0,1),(0,2),(1,3),(1,4),(2,5),(2,6),(3,7),(4,8),(5,9),(6,10)]
|
|
40
|
+
for u,v in edges:
|
|
41
|
+
g.add_edge(u,v)
|
|
42
|
+
|
|
43
|
+
start = int(input("Enter Starting Node : "))
|
|
44
|
+
|
|
45
|
+
# printing the output
|
|
46
|
+
|
|
47
|
+
print(f"\ndepth first search starting from vertex {start} :")
|
|
48
|
+
g.dfsRecursive(start)
|
|
49
|
+
print("\n")
|
|
50
|
+
|
|
51
|
+
print(f"breadth first search starting from vertex {start} :")
|
|
52
|
+
g.bfs(start)
|
|
53
|
+
|
|
54
|
+
print("\n")
|
|
55
|
+
print('-' * 20)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import heapq
|
|
2
|
+
|
|
3
|
+
#Class for A-star algorithm
|
|
4
|
+
|
|
5
|
+
class a_star:
|
|
6
|
+
def __init__(self, grid, start, goal):
|
|
7
|
+
self.grid = grid
|
|
8
|
+
self.start = start
|
|
9
|
+
self.goal = goal
|
|
10
|
+
self.rows = len(grid)
|
|
11
|
+
self.coloumn = len(grid[0])
|
|
12
|
+
|
|
13
|
+
def heuristic(self,node):
|
|
14
|
+
return abs(node[0]-self.goal[0] + abs(node[1]-self.goal[1]))
|
|
15
|
+
|
|
16
|
+
def nebighbors(self,node):
|
|
17
|
+
dirs = [(0,1),(1,0),(0,-1),(-1,0)]
|
|
18
|
+
result =[]
|
|
19
|
+
for d in dirs:
|
|
20
|
+
nebighbor = (node[0]+d[0],node[1]+d[1])
|
|
21
|
+
if 0<=nebighbor[0]<self.rows and 0<=nebighbor[1]<self.coloumn:
|
|
22
|
+
if self.grid[nebighbor[0]][nebighbor[1]]==0:
|
|
23
|
+
result.append(nebighbor)
|
|
24
|
+
return result
|
|
25
|
+
|
|
26
|
+
def reconstruct_path(self, came_from, current):
|
|
27
|
+
total_path = [current]
|
|
28
|
+
while current in came_from:
|
|
29
|
+
current = came_from[current]
|
|
30
|
+
total_path.append(current)
|
|
31
|
+
return total_path[::-1]
|
|
32
|
+
|
|
33
|
+
#A-star
|
|
34
|
+
|
|
35
|
+
def a_star_search(self):
|
|
36
|
+
open_list=[]
|
|
37
|
+
heapq.heappush(open_list,(0,self.start))
|
|
38
|
+
came_from={}
|
|
39
|
+
g_score={self.start:0}
|
|
40
|
+
f_score={self.start:self.heuristic(self.start)}
|
|
41
|
+
while open_list:
|
|
42
|
+
current = heapq.heappop(open_list)[1]
|
|
43
|
+
if current == self.goal:
|
|
44
|
+
return self.reconstruct_path(came_from,current)
|
|
45
|
+
|
|
46
|
+
for neighbor in self.nebighbors(current):
|
|
47
|
+
tentaive_g_score = g_score[current]+1
|
|
48
|
+
if neighbor not in g_score or tentaive_g_score < g_score[neighbor]:
|
|
49
|
+
came_from[neighbor] = current
|
|
50
|
+
g_score[neighbor]=tentaive_g_score
|
|
51
|
+
f_score[neighbor]=tentaive_g_score + self.heuristic(neighbor)
|
|
52
|
+
heapq.heappush(open_list,(f_score[neighbor],neighbor))
|
|
53
|
+
return []
|
|
54
|
+
|
|
55
|
+
grid = [
|
|
56
|
+
[0,1,0,1,0],
|
|
57
|
+
[0,1,0,1,0],
|
|
58
|
+
[0,0,0,1,0],
|
|
59
|
+
[1,1,0,1,0],
|
|
60
|
+
[0,0,0,0,0]
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
start, goal = (0,1),(4,0)
|
|
64
|
+
aStar = a_star(grid,start,goal)
|
|
65
|
+
print("\nPath from start to global : ",aStar.a_star_search())
|
|
66
|
+
|
|
67
|
+
print('\n', '-' * 30)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
class Dijkstra:
|
|
2
|
+
def __init__(self) -> None:
|
|
3
|
+
self.vertices = int(input("Enter number of vertices: "))
|
|
4
|
+
self.graph = [[float('inf')]*self.vertices for _ in range(self.vertices)]
|
|
5
|
+
|
|
6
|
+
self.edges = int(input("Enter number of edges: "))
|
|
7
|
+
print()
|
|
8
|
+
print("Start End Distance")
|
|
9
|
+
|
|
10
|
+
edges_added = 0
|
|
11
|
+
while edges_added < self.edges:
|
|
12
|
+
try:
|
|
13
|
+
v1, v2, e = input().split(" ")
|
|
14
|
+
v1, v2, e = int(v1), int(v2), int(e)
|
|
15
|
+
if v1 == v2:
|
|
16
|
+
print("Self-loops not allowed, re-enter")
|
|
17
|
+
continue
|
|
18
|
+
if not (1 <= v1 <= self.vertices) or not (1 <= v2 <= self.vertices):
|
|
19
|
+
print(f"Invalid. Enter values between 1 and {self.vertices}")
|
|
20
|
+
continue
|
|
21
|
+
self.graph[v1-1][v2-1] = e
|
|
22
|
+
self.graph[v2-1][v1-1] = e
|
|
23
|
+
edges_added += 1 # only increments on valid input
|
|
24
|
+
except ValueError:
|
|
25
|
+
print("Invalid input. Enter: start end distance")
|
|
26
|
+
|
|
27
|
+
for i in range(self.vertices):
|
|
28
|
+
self.graph[i][i] = 0
|
|
29
|
+
|
|
30
|
+
def printMatrix(self):
|
|
31
|
+
print()
|
|
32
|
+
print("\t",end="")
|
|
33
|
+
for i in range(self.vertices):
|
|
34
|
+
print(i+1,end="\t")
|
|
35
|
+
print()
|
|
36
|
+
for i,row in enumerate(self.graph):
|
|
37
|
+
print(i+1,end="\t")
|
|
38
|
+
for ele in row:
|
|
39
|
+
print(ele,end="\t")
|
|
40
|
+
print()
|
|
41
|
+
print()
|
|
42
|
+
|
|
43
|
+
def solve(self):
|
|
44
|
+
source = int(input("Enter starting node : "))
|
|
45
|
+
print()
|
|
46
|
+
if not (1 <= source <= self.vertices):
|
|
47
|
+
print(f"Enter a value between 1 and {self.vertices}")
|
|
48
|
+
return
|
|
49
|
+
visited = set()
|
|
50
|
+
distances = [float('inf')] * self.vertices
|
|
51
|
+
distances[source - 1] = 0
|
|
52
|
+
|
|
53
|
+
while True:
|
|
54
|
+
minDist = float('inf')
|
|
55
|
+
minId = -1
|
|
56
|
+
for i,dist in enumerate(distances):
|
|
57
|
+
if dist < minDist and i not in visited:
|
|
58
|
+
minDist = dist
|
|
59
|
+
minId = i
|
|
60
|
+
|
|
61
|
+
if minId == -1:
|
|
62
|
+
break
|
|
63
|
+
|
|
64
|
+
for i,distance in enumerate(self.graph[minId]):
|
|
65
|
+
if distances[i] > minDist + distance:
|
|
66
|
+
distances[i] = minDist + distance
|
|
67
|
+
visited.add(minId)
|
|
68
|
+
|
|
69
|
+
print(f"Distances from source {source}:")
|
|
70
|
+
for i,distance in enumerate(distances):
|
|
71
|
+
print(f"Distance to {i+1}: {distance}")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
solver = Dijkstra()
|
|
76
|
+
solver.printMatrix()
|
|
77
|
+
solver.solve()
|
|
78
|
+
|
|
79
|
+
print('\n', '-' * 40)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
def print_board(board):
|
|
4
|
+
for row in board:
|
|
5
|
+
print(" ".join("Q" if col else "." for col in row))
|
|
6
|
+
print()
|
|
7
|
+
|
|
8
|
+
def is_safe(board, row, col, n):
|
|
9
|
+
for i in range(row):
|
|
10
|
+
if board[i][col]:return False
|
|
11
|
+
for i,j in zip(range(row-1,-1,-1),range(col-1,-1,-1)):
|
|
12
|
+
if board[i][j]:return False
|
|
13
|
+
for i,j in zip(range(row-1,-1,-1),range(col+1,n)):
|
|
14
|
+
if board[i][j]:return False
|
|
15
|
+
return True
|
|
16
|
+
|
|
17
|
+
#solving n-queens using backtracking
|
|
18
|
+
|
|
19
|
+
def solve_bt(board,row,n):
|
|
20
|
+
if row == n:
|
|
21
|
+
print_board(board)
|
|
22
|
+
return True
|
|
23
|
+
for col in range(n):
|
|
24
|
+
if is_safe(board, row, col, n):
|
|
25
|
+
board[row][col]=True
|
|
26
|
+
if solve_bt(board, row+1, n) : return True
|
|
27
|
+
board[row][col]=False
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
#solving n-queens using branch-n-bound
|
|
31
|
+
|
|
32
|
+
def solve_bnb(row,n,cols,d1,d2,board):
|
|
33
|
+
if row == n:
|
|
34
|
+
print_board(board)
|
|
35
|
+
return True
|
|
36
|
+
for col in range(n):
|
|
37
|
+
if not (cols[col] or d1[row + col] or d2[row - col + (n-1)]):
|
|
38
|
+
board[row][col] = cols[col] = d1[row + col] = d2[row - col + (n-1)] = True
|
|
39
|
+
if solve_bnb(row+1, n, cols, d1, d2, board) : return True
|
|
40
|
+
board[row][col] = cols[col] = d1[row + col] = d2[row - col + (n-1)] = False
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
# taking input from user
|
|
44
|
+
|
|
45
|
+
n = int(input("Enter Number N : "))
|
|
46
|
+
print()
|
|
47
|
+
|
|
48
|
+
print("Backtracking:\n")
|
|
49
|
+
start = time.time()
|
|
50
|
+
solve_bt([[False]*n for _ in range(n)],0,n)
|
|
51
|
+
end = time.time()
|
|
52
|
+
print(f"Time required: {(end - start) * 1000:.2f} ms")
|
|
53
|
+
print()
|
|
54
|
+
|
|
55
|
+
print("Branch and Bound:\n")
|
|
56
|
+
start = time.time()
|
|
57
|
+
solve_bnb(0, n, [False] * n, [False] * (2*n-1), [False] * (2*n-1), [[False] * n for _ in range(n)])
|
|
58
|
+
end = time.time()
|
|
59
|
+
print(f"Time required: {(end - start) * 1000:.2f} ms")
|
|
60
|
+
|
|
61
|
+
print('\n', '-' * 40)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from nltk.chat.util import Chat,reflections
|
|
2
|
+
|
|
3
|
+
pairs = [
|
|
4
|
+
[
|
|
5
|
+
r"My name is (.*)",
|
|
6
|
+
["Hello %1. How are you today?","How may I help you?"]
|
|
7
|
+
],
|
|
8
|
+
[
|
|
9
|
+
r"(.*) name?",
|
|
10
|
+
["I am a Chatbot. I don't have a particular name"]
|
|
11
|
+
],
|
|
12
|
+
[
|
|
13
|
+
r"How are you?",
|
|
14
|
+
["I am fine.","I am always happy to help"]
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
r"I am doing good",
|
|
18
|
+
["Nice to hear that"]
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
r"Hi|Hello|Hey|hi|hello",
|
|
22
|
+
["Hey there","hello"]
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
r"(.*) created?",
|
|
26
|
+
["I was made by a computer programmer"]
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
r"(.*) investments|money?",
|
|
30
|
+
["There are many options to invest money like mutual funds, regional banks, etc."]
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
r"(.*) stocks?",
|
|
34
|
+
["There are many companies to invest your money in."]
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
r"(.*) companies (.*) money?",
|
|
38
|
+
["Amazon,Tesla"]
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
r"(.*)",
|
|
42
|
+
["I'm not sure how to respond to that. Could you rephrase?"]
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
r"quit",
|
|
46
|
+
["exiting chatbot"]
|
|
47
|
+
]
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
def chat():
|
|
51
|
+
print("Hello I am a chatbot.Type 'quit' to exit")
|
|
52
|
+
obj = Chat(pairs,reflections)
|
|
53
|
+
obj.converse()
|
|
54
|
+
chat()
|
|
55
|
+
|
|
56
|
+
print('\n', '-' * 40)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
def get_float(prompt):
|
|
2
|
+
while True:
|
|
3
|
+
try: return float(input(prompt))
|
|
4
|
+
except ValueError: print("Invalid input")
|
|
5
|
+
|
|
6
|
+
def analyze(price, ma, rsi, vol, avg_vol, pe, eps):
|
|
7
|
+
signals = []
|
|
8
|
+
if price < ma: signals.append("Price below moving average (bearish trend)")
|
|
9
|
+
else: signals.append("Price above moving average (bullish trend)")
|
|
10
|
+
if rsi < 30: signals.append("RSI oversold - potential buy opportunity")
|
|
11
|
+
elif rsi > 70: signals.append("RSI overbought - potential sell opportunity")
|
|
12
|
+
else: signals.append("RSI neutral")
|
|
13
|
+
if vol > avg_vol * 1.5: signals.append("High volume - strong market conviction")
|
|
14
|
+
elif vol < avg_vol * 0.5: signals.append("Low volume - weak market conviction")
|
|
15
|
+
if pe < 15: signals.append("Low P/E - potentially undervalued")
|
|
16
|
+
elif pe > 30: signals.append("High P/E - potentially overvalued")
|
|
17
|
+
if eps > 0: signals.append("Positive EPS - company is profitable")
|
|
18
|
+
else: signals.append("Negative EPS - company is at a loss")
|
|
19
|
+
|
|
20
|
+
buys = sum(1 for s in signals if "buy" in s.lower() or "undervalued" in s.lower() or "profitable" in s.lower())
|
|
21
|
+
sells = sum(1 for s in signals if "sell" in s.lower() or "overvalued" in s.lower() or "loss" in s.lower())
|
|
22
|
+
|
|
23
|
+
print("\n--- Analysis ---")
|
|
24
|
+
for s in signals: print(f" • {s}")
|
|
25
|
+
print(f"\nBuy signals: {buys} | Sell signals: {sells}")
|
|
26
|
+
if buys > sells + 1:
|
|
27
|
+
print("Recommendation: STRONG BUY")
|
|
28
|
+
elif buys > sells:
|
|
29
|
+
print("Recommendation: BUY")
|
|
30
|
+
elif sells > buys + 1:
|
|
31
|
+
print("Recommendation: STRONG SELL")
|
|
32
|
+
elif sells > buys:
|
|
33
|
+
print("Recommendation: SELL")
|
|
34
|
+
else:
|
|
35
|
+
print("Recommendation: HOLD")
|
|
36
|
+
|
|
37
|
+
while True:
|
|
38
|
+
print("\n=== Stock Market Expert System ===")
|
|
39
|
+
print("1. Evaluate Stock\n2. Exit")
|
|
40
|
+
choice = input("Choice: ")
|
|
41
|
+
if choice == "2": break
|
|
42
|
+
elif choice == "1":
|
|
43
|
+
stock = input("Stock symbol: ").upper()
|
|
44
|
+
price = get_float("Current price: ")
|
|
45
|
+
ma = get_float("50-day moving average: ")
|
|
46
|
+
rsi = get_float("RSI (0-100): ")
|
|
47
|
+
vol = get_float("Today's volume: ")
|
|
48
|
+
avg = get_float("Average volume: ")
|
|
49
|
+
pe = get_float("P/E ratio: ")
|
|
50
|
+
eps = get_float("EPS: ")
|
|
51
|
+
print(f"\nEvaluating {stock}...")
|
|
52
|
+
analyze(price, ma, rsi, vol, avg, pe, eps)
|
|
53
|
+
else: print("Invalid choice")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Installation
|
|
2
|
+
- sudo apt install cpu-checker
|
|
3
|
+
|
|
4
|
+
- sudo kvm-ok
|
|
5
|
+
|
|
6
|
+
- sudo apt install -y qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager
|
|
7
|
+
|
|
8
|
+
- sudo systemctl status libvirtd
|
|
9
|
+
|
|
10
|
+
- sudo systemctl enable --now libvirtd
|
|
11
|
+
|
|
12
|
+
Configuration
|
|
13
|
+
|
|
14
|
+
- sudo virt-manager
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
sem6labs/__init__.py
|
|
5
|
+
sem6labs.egg-info/PKG-INFO
|
|
6
|
+
sem6labs.egg-info/SOURCES.txt
|
|
7
|
+
sem6labs.egg-info/dependency_links.txt
|
|
8
|
+
sem6labs.egg-info/top_level.txt
|
|
9
|
+
sem6labs/scaffold/1) BFS_DFS.py
|
|
10
|
+
sem6labs/scaffold/2) AStar.py
|
|
11
|
+
sem6labs/scaffold/3) GreedySearch_SSSP.py
|
|
12
|
+
sem6labs/scaffold/4) CSP_using_Nqueens.py
|
|
13
|
+
sem6labs/scaffold/5) Elementary_chatbot.py
|
|
14
|
+
sem6labs/scaffold/6) expertSystem_SMT.py
|
|
15
|
+
sem6labs/scaffold/KVM_installation.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sem6labs
|
sem6labs-0.1.0/setup.cfg
ADDED
sem6labs-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
from setuptools import setup, find_packages
|
|
4
|
+
from setuptools.command.install import install
|
|
5
|
+
|
|
6
|
+
class CustomInstall(install):
|
|
7
|
+
def run(self):
|
|
8
|
+
install.run(self)
|
|
9
|
+
dest = os.getcwd()
|
|
10
|
+
# locate scaffold relative to setup.py itself
|
|
11
|
+
scaffold_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sem6labs', 'scaffold')
|
|
12
|
+
for filename in os.listdir(scaffold_dir):
|
|
13
|
+
src = os.path.join(scaffold_dir, filename)
|
|
14
|
+
shutil.copy2(src, dest)
|
|
15
|
+
print(f"Installed: {filename} → {dest}")
|
|
16
|
+
|
|
17
|
+
setup(
|
|
18
|
+
name='sem6labs',
|
|
19
|
+
version='0.1.0',
|
|
20
|
+
packages=find_packages(),
|
|
21
|
+
package_data={'sem6labs': ['scaffold/*']},
|
|
22
|
+
include_package_data=True,
|
|
23
|
+
cmdclass={'install': CustomInstall},
|
|
24
|
+
)
|