Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Advanced_Extractive_Text_Summarization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Advanced Extractive Text Summarization

An advanced extractive text summarization model using NLP techniques.

## Features
- Extracts key sentences from text
- Scores sentences using TF-IDF, sentence length, position, and named entities
- Clusters sentences via K-means to highlight critical points from thematic groups

## Usage
1. Install dependencies:
```bash
pip install nltk spacy scikit-learn
python -m spacy download en_core_web_sm
```
2. Run `summarizer.py`.
3. The script will print a summary of the sample text.

## Requirements
- Python 3.x
- nltk
- spacy
- scikit-learn

## License
MIT
3 changes: 3 additions & 0 deletions Advanced_Extractive_Text_Summarization/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nltk
spacy
scikit-learn
50 changes: 50 additions & 0 deletions Advanced_Extractive_Text_Summarization/summarizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
Advanced Extractive Text Summarization Model
Issue #100 for king04aman/All-In-One-Python-Projects
"""
import nltk
import spacy
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.cluster import KMeans
import numpy as np

nltk.download('punkt')
nlp = spacy.load('en_core_web_sm')

def extract_sentences(text):
return nltk.sent_tokenize(text)

def score_sentences(sentences):
tfidf = TfidfVectorizer().fit_transform(sentences)
scores = tfidf.sum(axis=1).A1
features = []
for i, sent in enumerate(sentences):
length = len(sent)
position = i / len(sentences)
doc = nlp(sent)
entities = len(doc.ents)
features.append([scores[i], length, position, entities])
return np.array(features)

def cluster_sentences(features, n_clusters=3):
kmeans = KMeans(n_clusters=n_clusters, random_state=42)
labels = kmeans.fit_predict(features)
return labels

def summarize(text, n_clusters=3):
sentences = extract_sentences(text)
features = score_sentences(sentences)
labels = cluster_sentences(features, n_clusters)
summary = []
for cluster in range(n_clusters):
idx = np.where(labels == cluster)[0]
if len(idx) > 0:
best = idx[np.argmax(features[idx, 0])]
summary.append(sentences[best])
return "\n".join(summary)

if __name__ == "__main__":
sample_text = """
Natural Language Processing (NLP) is a field of artificial intelligence that focuses on the interaction between computers and humans through language. NLP techniques are used to analyze text, extract information, and generate summaries. Extractive summarization selects key sentences from the original text to create a concise summary. Advanced models use features like TF-IDF, sentence length, position, and named entities to score sentences. Clustering helps group related sentences and highlight critical points from different themes. This approach is useful for summarizing reports, research papers, and news articles.
"""
print("Summary:\n", summarize(sample_text))
31 changes: 31 additions & 0 deletions Analog_Wall_Clock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Analog Wall Clock

A real-time analog wall clock built using Python’s turtle graphics and threading.

## Features
- Hour, minute, and second hands update in real time
- Decorative clock face with numbers and circles
- AM/PM indicator
- Hands rotate in sync with system time

## Technologies Used
- Python
- turtle (graphics)
- threading (concurrent hand updates)
- datetime (system time)

## Usage
1. Run `clock.py`.
2. The clock window will appear and update in real time.

## Requirements
- Python 3.x
- turtle (usually included with Python)

## Extensibility
- Add digital clock overlay
- Custom themes (dark/light mode)
- Alarm feature or tick sounds

## License
MIT
144 changes: 144 additions & 0 deletions Analog_Wall_Clock/clock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
"""
Analog Wall Clock using Python Turtle and Threading
Issue #107 for king04aman/All-In-One-Python-Projects
"""
import turtle
import threading
import time
from datetime import datetime

WIDTH, HEIGHT = 600, 600

# Setup screen
def setup_screen():
screen = turtle.Screen()
screen.title("Analog Wall Clock")
screen.bgcolor("white")
screen.setup(width=WIDTH, height=HEIGHT)
screen.tracer(0)
return screen

# Draw clock face
def draw_clock_face(clock_turtle):
clock_turtle.penup()
clock_turtle.goto(0, -250)
clock_turtle.pendown()
clock_turtle.pensize(5)
clock_turtle.color("black")
clock_turtle.circle(250)
clock_turtle.penup()
clock_turtle.goto(0, 0)
clock_turtle.pendown()
# Draw numbers
for i in range(1, 13):
angle = i * 30
x = 200 * turtle.sin(turtle.radians(angle))
y = 200 * turtle.cos(turtle.radians(angle))
clock_turtle.penup()
clock_turtle.goto(x, y-20)
clock_turtle.pendown()
clock_turtle.write(str(i), align="center", font=("Arial", 18, "bold"))
# Decorative circles
clock_turtle.penup()
clock_turtle.goto(0, -220)
clock_turtle.pendown()
clock_turtle.pensize(2)
clock_turtle.color("gray")
clock_turtle.circle(220)
clock_turtle.penup()
clock_turtle.goto(0, -180)
clock_turtle.pendown()
clock_turtle.circle(180)
clock_turtle.penup()
clock_turtle.goto(0, 0)
clock_turtle.pendown()

# Draw AM/PM indicator
def draw_ampm_indicator(clock_turtle):
now = datetime.now()
ampm = "AM" if now.hour < 12 else "PM"
clock_turtle.penup()
clock_turtle.goto(0, 120)
clock_turtle.pendown()
clock_turtle.color("blue")
clock_turtle.write(ampm, align="center", font=("Arial", 16, "italic"))
clock_turtle.penup()
clock_turtle.goto(0, 0)
clock_turtle.pendown()

# Hand drawing functions
def draw_hand(hand_turtle, length, angle, color, width):
hand_turtle.clear()
hand_turtle.penup()
hand_turtle.goto(0, 0)
hand_turtle.setheading(90)
hand_turtle.right(angle)
hand_turtle.pendown()
hand_turtle.pensize(width)
hand_turtle.color(color)
hand_turtle.forward(length)
hand_turtle.penup()
hand_turtle.goto(0, 0)
hand_turtle.pendown()

# Thread functions
def update_second_hand(hand_turtle):
while True:
now = datetime.now()
angle = now.second * 6
draw_hand(hand_turtle, 180, angle, "red", 2)
time.sleep(0.1)

def update_minute_hand(hand_turtle):
while True:
now = datetime.now()
angle = now.minute * 6 + now.second * 0.1
draw_hand(hand_turtle, 150, angle, "black", 4)
time.sleep(0.5)

def update_hour_hand(hand_turtle):
while True:
now = datetime.now()
angle = (now.hour % 12) * 30 + now.minute * 0.5
draw_hand(hand_turtle, 100, angle, "black", 6)
time.sleep(1)

def main():
screen = setup_screen()
clock_turtle = turtle.Turtle()
clock_turtle.hideturtle()
clock_turtle.speed(0)
draw_clock_face(clock_turtle)
draw_ampm_indicator(clock_turtle)

# Create turtles for hands
sec_turtle = turtle.Turtle()
sec_turtle.hideturtle()
sec_turtle.speed(0)
min_turtle = turtle.Turtle()
min_turtle.hideturtle()
min_turtle.speed(0)
hour_turtle = turtle.Turtle()
hour_turtle.hideturtle()
hour_turtle.speed(0)

# Start threads
threading.Thread(target=update_second_hand, args=(sec_turtle,), daemon=True).start()
threading.Thread(target=update_minute_hand, args=(min_turtle,), daemon=True).start()
threading.Thread(target=update_hour_hand, args=(hour_turtle,), daemon=True).start()

# Update AM/PM indicator every minute
def update_ampm():
while True:
clock_turtle.clear()
draw_clock_face(clock_turtle)
draw_ampm_indicator(clock_turtle)
time.sleep(60)
threading.Thread(target=update_ampm, daemon=True).start()

while True:
screen.update()
time.sleep(0.05)

if __name__ == "__main__":
main()
28 changes: 28 additions & 0 deletions Calendar_Generator_YearWise/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Calendar Generator YearWise

A simple GUI calendar application built with Python and Tkinter that displays the calendar for any given year.

## Features
- User-friendly interface
- Displays full year calendar in a clean format
- Responsive design
- Easy year input
- Error handling for invalid input

## Usage
1. Run `calendar_app.py`.
2. Enter a year in the input field.
3. Click "Show Calendar" to display the calendar for the entered year.
4. Use the "Exit" button to close the application.

## Requirements
- Python 3.x
- Tkinter (usually included with Python)

## Customization
- Change colors by modifying the `bg` parameters.
- Change fonts by editing the `font` parameters.
- Adjust window sizes via the `geometry` values.

## License
MIT
47 changes: 47 additions & 0 deletions Calendar_Generator_YearWise/calendar_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Calendar Generator YearWise
Issue #106 for king04aman/All-In-One-Python-Projects
"""
import tkinter as tk
from tkinter import messagebox
import calendar

class CalendarApp:
def __init__(self, root):
self.root = root
self.root.title("Yearly Calendar Generator")
self.root.geometry("350x150")
self.root.resizable(False, False)
self.root.configure(bg="#f0f0f0")

tk.Label(root, text="Enter Year:", font=("Arial", 12), bg="#f0f0f0").pack(pady=10)
self.year_entry = tk.Entry(root, font=("Arial", 12), width=15)
self.year_entry.pack(pady=5)

tk.Button(root, text="Show Calendar", command=self.show_calendar, font=("Arial", 12), bg="#4caf50", fg="white").pack(pady=10)
tk.Button(root, text="Exit", command=root.quit, font=("Arial", 12), bg="#f44336", fg="white").pack()

def show_calendar(self):
year = self.year_entry.get()
if not year.isdigit() or int(year) < 1:
messagebox.showerror("Invalid Input", "Please enter a valid positive year.")
return
year = int(year)
cal = calendar.TextCalendar(calendar.SUNDAY)
cal_str = cal.formatyear(year, 2, 1, 1, 3)
self.display_calendar(year, cal_str)

def display_calendar(self, year, cal_str):
cal_win = tk.Toplevel(self.root)
cal_win.title(f"Calendar for {year}")
cal_win.geometry("600x600")
cal_win.configure(bg="#e3f2fd")
text = tk.Text(cal_win, font=("Consolas", 10), bg="#e3f2fd", fg="#212121")
text.insert(tk.END, cal_str)
text.pack(expand=True, fill=tk.BOTH)
tk.Button(cal_win, text="Close", command=cal_win.destroy, font=("Arial", 12), bg="#1976d2", fg="white").pack(pady=10)

if __name__ == "__main__":
root = tk.Tk()
app = CalendarApp(root)
root.mainloop()
26 changes: 26 additions & 0 deletions GraphRAG/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# GraphRAG

GraphRAG implementation using Llama-Index and NetworkX.

## Features
- Builds a knowledge graph from documents
- Indexes data points in the graph
- Retrieves and generates contextually relevant responses using an LLM
- Visualizes the knowledge graph

## Usage
1. Install dependencies:
```bash
pip install llama-index networkx
```
2. Run `graphrag.py`.
3. Example query and knowledge graph visualization will be generated.

## Requirements
- Python 3.x
- llama-index
- networkx
- OpenAI API key (for LLM and embeddings)

## License
MIT
Loading