Skip to content

Commit

Permalink
This is my Software 1 project
Browse files Browse the repository at this point in the history
My intro project
  • Loading branch information
Luxosaucer committed Feb 13, 2024
1 parent 6ec00d8 commit 573b8c8
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
Binary file added Test.pdf
Binary file not shown.
51 changes: 51 additions & 0 deletions getSummary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import pika, sys, os, PyPDF2
from transformers import pipeline

summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-base", framework="tf")

def main():
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='sendPDF')

def callback(ch, method, properties, body):
print(f" [x] Received {body}")

pdfGet = body.decode()
# Open the PDF file in read-binary mode
with open(pdfGet, 'rb') as file:
# Create a PDF object
pdf = PyPDF2.PdfReader(file)
# Get the number of pages in the PDF
page = pdf.pages[6]
text = page.extract_text()
summary = summarizer(text, max_length=100, min_length=30, do_sample=False)
sum = (summary[0]['summary_text'])
channel.queue_declare(queue='sendTxt')
channel.basic_publish(exchange='', routing_key='sendTxt', body=sum)
print(" [x] Sent 'A message getText'")


channel.basic_consume(queue='sendPDF', on_message_callback=callback, auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')

channel.start_consuming()


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('Interrupted')
try:
sys.exit(0)
except SystemExit:
os._exit(0)






22 changes: 22 additions & 0 deletions getText.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import glob
import pika

"""""
import glob, os
os.chdir("./")
for file in glob.glob("*.pdf"):
print(file)
"""

file = input("Enter your file name: ")

connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='sendPDF')


channel.basic_publish(exchange='', routing_key='sendPDF', body=file)
print(" [x] Sent 'A message getText'")
connection.close()
31 changes: 31 additions & 0 deletions output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pika, sys, os, PyPDF2
from transformers import pipeline


def main():
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='sendTxt')

def callback(ch, method, properties, body):
print(f" [x] Received {body}")
print(body)



channel.basic_consume(queue='sendTxt', on_message_callback=callback, auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('Interrupted')
try:
sys.exit(0)
except SystemExit:
os._exit(0)
1 change: 1 addition & 0 deletions tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sendPDF

0 comments on commit 573b8c8

Please sign in to comment.