From d884867dc62e9826375b26d062b56bd3d1a895c8 Mon Sep 17 00:00:00 2001 From: Javokhir Date: Tue, 8 Sep 2020 16:36:45 +0500 Subject: [PATCH 01/12] Added the project for the issue #198 --- projects/Number guessing game/README.md | 14 ++++++ projects/Number guessing game/image.png | Bin 0 -> 9547 bytes projects/Number guessing game/main.py | 56 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 projects/Number guessing game/README.md create mode 100644 projects/Number guessing game/image.png create mode 100644 projects/Number guessing game/main.py diff --git a/projects/Number guessing game/README.md b/projects/Number guessing game/README.md new file mode 100644 index 000000000..0df28ed70 --- /dev/null +++ b/projects/Number guessing game/README.md @@ -0,0 +1,14 @@ +# Number Guessing Game + +This game allows you to check your luck and intuition :) +You should find the number computer guessed + +### Usage +Just run "python main.py" in cmd command line after setting the project directory + +### Here you can see sample +[](/image.png) + +## *Author Name* + +[Javokhir](https://github.com/leader2one/) diff --git a/projects/Number guessing game/image.png b/projects/Number guessing game/image.png new file mode 100644 index 0000000000000000000000000000000000000000..ca01dc3cc1849c68d7227da05872eb8934cd2238 GIT binary patch literal 9547 zcmcJUcUV)++U^6WAW{VBARr3T5$S>ise%;gy+{XXf^ zAP{OuJHh?E`|NYh{;t#iNM_B<%3LeCGV{Cd`-yn1u0%@AKnwr?NR?m8YXJaw^|dUF%kzwP$Y&;tM<>%M;B^}Ci> z0|1YHDa*gm@i9Bd1gi3kCvB69ExYBQ+l3uJB#ljcick$BjnRN8fzX2dp`Kzi*ZY4sHM&)pfC@jV&!@E0`%!XzVn8 z%ko*rc;OQLB0#odxz#`b!?lfK{NBz*~#-vm|P7$0KmyFC{%x2jhmFS zMg)F*EGzaHy0bJ$>J^Cx2x1o`9xZg4E8JVnx{!D@W<3CdTowr;uxH<%CP$<~&IHE~ zFR{Dy5VNE7g(rFIZ-J^N+O}d4h5&Foixb6G6mW?$fs9(9^eAh_}u&bL}(*=YL6TM*kT8f9=wxrK?~p2Np;(U_ja7W zL@hZ^G%plD3g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4fi9 z*uD3D8-ZUR6~Jp$pt#a|H1jx4tbN=eadu7S7S4OYsloOVk5h4CCin2CpVtjoJ%jMM ztqy?;XxToGHa@Hdv{N#2%&n)rcs{LEd zbFFt*9SE;uR+#Ax-zg0t2mU;eS}VlMK?hD1TrBgwX)kB2ZH4%!{oUihexVlc_A($=FlO*N@Z? zYt^5LAz};~Dhaj1l)qvdGYLfUEpB=n@QqgKHp99WDewG>a($dTI0dEqW!nC5Qupih zsmE+JpNjIcjn}b<^$V9n!QwnFds=hR+?jV~wJD!=Obt}*YB=ybr7=QBiT!3u6N%Vm~kLB*JKpBYi zi1owcr1({BYi*Tfr`S1N^5C&8dL0)O{C4j_q~X@6B?M5#r*=oM@V7?a$^=>H zA(g!+H~NWJ&;5;wa@`2c%kwI|>0kdAqjo&&Zr-G>TM{5^$A+a)Nbq@rJ8<5pMQJLO z8*FFNub~u`9rCLu`+?Wcv`y@?nE~s7yaBGfo_ryR#kB6GuaE0@_{MFPvlp|_@{7Ud zx5hnKjoF|TWh15RuDc@%7!oN!NzE=501*5co!)`|P5$E7FOSp#dd*@LxzRTz8JnlZ zkBXe*Msa2bAVZ_)f2zC8uYxG+w44jajRZ*RJ(IJ#L_c(Jxs&o*BmL|3;d@f!{>KpU zrU9{taURh>q1-Ec;(t>Hwk%PGR@15BZzye&T|-wkB8pPlg8&O~n07*9W)S y#;_|mpt$27nO=9-pW4>n9t-eiZ5o+VEZ(|d-|>F`_gUN`0A&Sr`6^k9kN*W|=d=F+ literal 0 HcmV?d00001 diff --git a/projects/Number guessing game/main.py b/projects/Number guessing game/main.py new file mode 100644 index 000000000..7fe59f6be --- /dev/null +++ b/projects/Number guessing game/main.py @@ -0,0 +1,56 @@ +import random + +print("Number guessing game") + +# randint function to generate the +# random number b/w 1 to 9 +number = random.randint(1, 9) + +# number of chances to be given +# to the user to guess the number +# or it is the inputs given by user +# into input box here number of +# chances are 5 +chances = 0 + +print("Guess a number (between 1 and 9):") + +# While loop to count the number +# of chances +while chances < 5: + + # Enter a number between 1 to 9 + guess = int(input()) + + # Compare the user entered number + # with the number to be guessed + if guess == number: + + # if number entered by user + # is same as the generated + # number by randint function then + # break from loop using loop + # control statement "break" + print("Congratulation YOU WON!!!") + break + + # Check if the user entered + # number is smaller than + # the generated number + elif guess < number: + print("Your guess was too low: Guess a number higher than", guess) + + # The user entered number is + # greater than the generated + # number + else: + print("Your guess was too high: Guess a number lower than", guess) + + # Increase the value of chance by 1 + chances += 1 + + +# Check whether the user +# guessed the correct number +if not chances < 5: + print("YOU LOSE!!! The number is", number) \ No newline at end of file From 8ff47197a29271f995dd6e738a4cb35a2d05e52f Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Tue, 8 Sep 2020 17:40:35 +0530 Subject: [PATCH 02/12] Update README.md --- projects/Number guessing game/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/Number guessing game/README.md b/projects/Number guessing game/README.md index 0df28ed70..50f8b1365 100644 --- a/projects/Number guessing game/README.md +++ b/projects/Number guessing game/README.md @@ -7,7 +7,7 @@ You should find the number computer guessed Just run "python main.py" in cmd command line after setting the project directory ### Here you can see sample -[](/image.png) +![Image](./image.png) ## *Author Name* From 375db50904911681b9663ee37e234e40efaf5d8c Mon Sep 17 00:00:00 2001 From: Javokhirbek Date: Tue, 8 Sep 2020 18:22:10 +0500 Subject: [PATCH 03/12] update main.py some changes --- projects/Number guessing game/main.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/projects/Number guessing game/main.py b/projects/Number guessing game/main.py index 7fe59f6be..88ab090dd 100644 --- a/projects/Number guessing game/main.py +++ b/projects/Number guessing game/main.py @@ -17,7 +17,7 @@ # While loop to count the number # of chances -while chances < 5: +while True: # Enter a number between 1 to 9 guess = int(input()) @@ -31,7 +31,8 @@ # number by randint function then # break from loop using loop # control statement "break" - print("Congratulation YOU WON!!!") + print(f'CONGRATULATIONS! YOU HAVE GUESSED THE NUMBER {number} IN {chances} ATTEMPTS!') + #Printing final statement using the f-strings method; break # Check if the user entered @@ -49,8 +50,3 @@ # Increase the value of chance by 1 chances += 1 - -# Check whether the user -# guessed the correct number -if not chances < 5: - print("YOU LOSE!!! The number is", number) \ No newline at end of file From c302407d8b71d1555639cdbee21527bafa3bf474 Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Tue, 8 Sep 2020 20:45:54 +0530 Subject: [PATCH 04/12] Create python-app.yml --- .github/workflows/python-app.yml | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 000000000..ce3cf01d6 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,34 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python application + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + From e18e8759bb44c1311b12f9f56581ee930c58830f Mon Sep 17 00:00:00 2001 From: Javokhirbek Date: Tue, 8 Sep 2020 20:32:50 +0500 Subject: [PATCH 05/12] validated with flake8 --- projects/Number guessing game/main.py | 97 ++++++++++++++------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/projects/Number guessing game/main.py b/projects/Number guessing game/main.py index 88ab090dd..ebae670bf 100644 --- a/projects/Number guessing game/main.py +++ b/projects/Number guessing game/main.py @@ -1,52 +1,53 @@ -import random - -print("Number guessing game") - -# randint function to generate the -# random number b/w 1 to 9 -number = random.randint(1, 9) - -# number of chances to be given -# to the user to guess the number -# or it is the inputs given by user -# into input box here number of -# chances are 5 +import random + +print("Number guessing game") + +# randint function to generate the +# random number b/w 1 to 9 +number = random.randint(1, 9) + +# number of chances to be given +# to the user to guess the number +# or it is the inputs given by user +# into input box here number of +# chances are 5 chances = 0 - -print("Guess a number (between 1 and 9):") - -# While loop to count the number -# of chances + +print("Guess a number (between 1 and 9):") + +# While loop to count the number +# of chances while True: - - # Enter a number between 1 to 9 - guess = int(input()) - - # Compare the user entered number - # with the number to be guessed - if guess == number: - - # if number entered by user - # is same as the generated - # number by randint function then - # break from loop using loop - # control statement "break" - print(f'CONGRATULATIONS! YOU HAVE GUESSED THE NUMBER {number} IN {chances} ATTEMPTS!') - #Printing final statement using the f-strings method; + + # Enter a number between 1 to 9 + guess = int(input()) + + # Compare the user entered number + # with the number to be guessed + if guess == number: + + # if number entered by user + # is same as the generated + # number by randint function then + # break from loop using loop + # control statement "break" + print( + f'CONGRATULATIONS! YOU HAVE GUESSED THE \ + NUMBER {number} IN {chances} ATTEMPTS!') + # Printing final statement using the f-strings method; break - - # Check if the user entered - # number is smaller than - # the generated number - elif guess < number: - print("Your guess was too low: Guess a number higher than", guess) - - # The user entered number is - # greater than the generated - # number - else: - print("Your guess was too high: Guess a number lower than", guess) - - # Increase the value of chance by 1 + + # Check if the user entered + # number is smaller than + # the generated number + elif guess < number: + print("Your guess was too low: Guess a number higher than", guess) + + # The user entered number is + # greater than the generated + # number + else: + print("Your guess was too high: Guess a number lower than", guess) + + # Increase the value of chance by 1 chances += 1 - From bfa6ff60a02012e87a8bcb851cb8ceb119b1cbed Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Tue, 8 Sep 2020 21:07:47 +0530 Subject: [PATCH 06/12] Update main.py --- projects/Number guessing game/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/Number guessing game/main.py b/projects/Number guessing game/main.py index ebae670bf..56ce997f2 100644 --- a/projects/Number guessing game/main.py +++ b/projects/Number guessing game/main.py @@ -51,3 +51,4 @@ # Increase the value of chance by 1 chances += 1 + From ab67ca9d64909162a5e7e928d24d4971e2a1f22a Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Tue, 8 Sep 2020 21:15:21 +0530 Subject: [PATCH 07/12] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 578ceba9f..0719b21b8 100644 --- a/README.md +++ b/README.md @@ -169,3 +169,4 @@ SR No | Project | Author 82 | [Time To Load Website](https://github.com/chavarera/python-mini-projects/tree/master/projects/Time%20to%20load%20Website)| [Aditya Jetely](https://github.com/AdityaJ7) 83 | [Customer Loan Repayment Prediction](https://github.com/chavarera/python-mini-projects/tree/master/Notebooks/Customer_loan_repayment_problem)| [ART](https://github.com/Tomyzon1728) 84 | [Generate Wordcloud from Wikipedia Article](https://github.com/chavarera/python-mini-projects/tree/master/projects/Wikipedia%20Search%20Wordcloud)| [Naman Shah](https://github.com/namanshah01) +85 | [Number Guessing Game](https://github.com/chavarera/python-mini-projects/tree/master/projects/Number%20guessing%20game)| [Javokhirbek](https://github.com/leader2one) From 16837acc47a5ea7a9ae2cac72f3bc802f353f6a5 Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Tue, 8 Sep 2020 21:15:45 +0530 Subject: [PATCH 08/12] Update README.md --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index e9e0d48a2..949132bbd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -89,3 +89,4 @@ SR No | Project | Author 82 | [Time To Load Website](https://github.com/chavarera/python-mini-projects/tree/master/projects/Time%20to%20load%20Website)| [Aditya Jetely](https://github.com/AdityaJ7) 83 | [Customer Loan Repayment Prediction](https://github.com/chavarera/python-mini-projects/tree/master/Notebooks/Customer_loan_repayment_problem)| [ART](https://github.com/Tomyzon1728) 84 | [Generate Wordcloud from Wikipedia Article](https://github.com/chavarera/python-mini-projects/tree/master/projects/Wikipedia%20Search%20Wordcloud)| [Naman Shah](https://github.com/namanshah01) +85 | [Number Guessing Game](https://github.com/chavarera/python-mini-projects/tree/master/projects/Number%20guessing%20game)| [Javokhirbek](https://github.com/leader2one) From 7a54bd21dad7619c4c2f273a1f02684a3ab20d7a Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Wed, 9 Sep 2020 09:15:55 +0530 Subject: [PATCH 09/12] Update app.py --- projects/web page summation/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/web page summation/app.py b/projects/web page summation/app.py index 940236963..8f0236eda 100644 --- a/projects/web page summation/app.py +++ b/projects/web page summation/app.py @@ -68,7 +68,7 @@ def writeCsv(data, LANGUAGE, SENTENCES_COUNT): length = len(data) position = data[0].index('website') for i in range(1, length): - if i is 1: + if i == 1: _data = data[0] _data.append("summary") newFileWriter.writerow(_data) @@ -143,4 +143,4 @@ def main(argv=sys.argv): if __name__ == '__main__': - main() \ No newline at end of file + main() From 10a0d2647ff5c8077d943b5758656077e5ec6cc0 Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Wed, 9 Sep 2020 10:04:26 +0530 Subject: [PATCH 10/12] Improvement for PEP8 --- projects/web page summation/utils/model.py | 2 +- projects/web page summation/utils/prepare.py | 30 +----------- .../web page summation/utils/summarize.py | 37 ++++++-------- projects/web page summation/utils/test.py | 15 +++--- projects/web page summation/utils/train.py | 48 ++++++------------- projects/web page summation/utils/utils.py | 20 ++++---- 6 files changed, 48 insertions(+), 104 deletions(-) diff --git a/projects/web page summation/utils/model.py b/projects/web page summation/utils/model.py index b3b7d5083..cfcfc9384 100644 --- a/projects/web page summation/utils/model.py +++ b/projects/web page summation/utils/model.py @@ -1,6 +1,6 @@ import tensorflow as tf from tensorflow.contrib import rnn -#from utils import get_init_embedding +from utils import get_init_embedding class Model(object): diff --git a/projects/web page summation/utils/prepare.py b/projects/web page summation/utils/prepare.py index 128545039..6596c4247 100644 --- a/projects/web page summation/utils/prepare.py +++ b/projects/web page summation/utils/prepare.py @@ -1,19 +1,6 @@ - -import wget -import os -import tarfile import gzip -import zipfile -import argparse - -#parser = argparse.ArgumentParser() -#parser.add_argument("--glove", action="store_true") -#args = parser.parse_args() - -# Extract data file -#with tarfile.open(default_path + "sumdata/train/summary.tar.gz", "r:gz") as tar: -# tar.extractall() +default_path = '.' with gzip.open(default_path + "sumdata/train/train.article.txt.gz", "rb") as gz: with open(default_path + "sumdata/train/train.article.txt", "wb") as out: @@ -22,18 +9,3 @@ with gzip.open(default_path + "sumdata/train/train.title.txt.gz", "rb") as gz: with open(default_path + "sumdata/train/train.title.txt", "wb") as out: out.write(gz.read()) - - -#if args.glove: -# glove_dir = "glove" -# glove_url = "https://nlp.stanford.edu/data/wordvecs/glove.42B.300d.zip" -# -# if not os.path.exists(glove_dir): -# os.mkdir(glove_dir) -# -# # Download glove vector -# wget.download(glove_url, out=glove_dir) -# -# # Extract glove file -# with zipfile.ZipFile(os.path.join("glove", "glove.42B.300d.zip"), "r") as z: -# z.extractall(glove_dir) \ No newline at end of file diff --git a/projects/web page summation/utils/summarize.py b/projects/web page summation/utils/summarize.py index 74243944a..b92206ccf 100644 --- a/projects/web page summation/utils/summarize.py +++ b/projects/web page summation/utils/summarize.py @@ -1,10 +1,6 @@ -# -*- coding: utf-8 -*- -# load Dependancies - from __future__ import absolute_import from __future__ import division, print_function, unicode_literals from sumy.parsers.html import HtmlParser -from sumy.parsers.plaintext import PlaintextParser from sumy.nlp.tokenizers import Tokenizer from sumy.summarizers.lex_rank import LexRankSummarizer as Summarizer from sumy.nlp.stemmers import Stemmer @@ -13,25 +9,22 @@ def summarize(url=None, LANGUAGE='English', SENTENCES_COUNT=2): - parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE)) - # or for plain text files - # parser = PlaintextParser.from_file("document.txt", Tokenizer(LANGUAGE)) - stemmer = Stemmer(LANGUAGE) - - summarizer = Summarizer(stemmer) - summarizer.stop_words = get_stop_words(LANGUAGE) - result = '' - for sentence in summarizer(parser.document, SENTENCES_COUNT): + parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE)) + stemmer = Stemmer(LANGUAGE) + summarizer = Summarizer(stemmer) + summarizer.stop_words = get_stop_words(LANGUAGE) + result = '' + for sentence in summarizer(parser.document, SENTENCES_COUNT): + result = result + ' ' + str(sentence) + try: result = result + ' ' + str(sentence) - try: - result = result + ' ' + str(sentence) - except: - print( + except: + print( '\n\n Invalid Entry!, please Ensure you enter a valid web link \n\n') - sys.stdout.flush() - return ( + sys.stdout.flush() + return ( '\n\n Invalid Entry!, please Ensure you enter a valid web link \n\n') - print('\n\n'+str(url)+'\n\n'+str(result)) - sys.stdout.flush() - return result + print('\n\n'+str(url)+'\n\n'+str(result)) + sys.stdout.flush() + return result diff --git a/projects/web page summation/utils/test.py b/projects/web page summation/utils/test.py index bfcdca620..77d928270 100644 --- a/projects/web page summation/utils/test.py +++ b/projects/web page summation/utils/test.py @@ -1,13 +1,10 @@ import tensorflow as tf -import pickle -#from model import Model -#from utils import build_dict, build_dataset, batch_iter - - -# with open("args.pickle", "rb") as f: -# args = pickle.load(f) - +from model import Model +from utils import build_dict, build_dataset, batch_iter, get_text_list +valid_article_path = '.' +valid_title_path = '.' tf.reset_default_graph() +default_path = '.' class args: @@ -74,6 +71,6 @@ class args: if word not in summary: summary.append(word) summary_array.append(" ".join(summary)) - #print(" ".join(summary), file=f) + # print(" ".join(summary), file=f) print('Summaries have been generated') diff --git a/projects/web page summation/utils/train.py b/projects/web page summation/utils/train.py index d1a8d32fc..d072ac2a5 100644 --- a/projects/web page summation/utils/train.py +++ b/projects/web page summation/utils/train.py @@ -1,31 +1,10 @@ import os -import pickle -import argparse import tensorflow as tf import time +from model import Model +from utils import build_dict, build_dataset, batch_iter start = time.perf_counter() -#from model import Model -#from utils import build_dict, build_dataset, batch_iter - -# Uncomment next 2 lines to suppress error and Tensorflow info verbosity. Or change logging levels -# tf.logging.set_verbosity(tf.logging.FATAL) -# os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' - -# def add_arguments(parser): -# parser.add_argument("--num_hidden", type=int, default=150, help="Network size.") -# parser.add_argument("--num_layers", type=int, default=2, help="Network depth.") -# parser.add_argument("--beam_width", type=int, default=10, help="Beam width for beam search decoder.") -# parser.add_argument("--glove", action="store_true", help="Use glove as initial word embedding.") -# parser.add_argument("--embedding_size", type=int, default=300, help="Word embedding size.") -# -# parser.add_argument("--learning_rate", type=float, default=1e-3, help="Learning rate.") -# parser.add_argument("--batch_size", type=int, default=64, help="Batch size.") -# parser.add_argument("--num_epochs", type=int, default=10, help="Number of epochs.") -# parser.add_argument("--keep_prob", type=float, default=0.8, help="Dropout keep prob.") -# -# parser.add_argument("--toy", action="store_true", help="Use only 50K samples of data") -# -# parser.add_argument("--with_model", action="store_true", help="Continue from previously saved model") +default_path = '.' class args: @@ -48,12 +27,6 @@ class args: args.with_model = "store_true" -#parser = argparse.ArgumentParser() -# add_arguments(parser) -#args = parser.parse_args() -# with open("args.pickle", "wb") as f: -# pickle.dump(args, f) - if not os.path.exists(default_path + "saved_model"): os.mkdir(default_path + "saved_model") else: @@ -61,7 +34,9 @@ class args: old_model_checkpoint_path = open( default_path + 'saved_model/checkpoint', 'r') old_model_checkpoint_path = "".join( - [default_path + "saved_model/", old_model_checkpoint_path.read().splitlines()[0].split('"')[1]]) + [ + default_path + "saved_model/", + old_model_checkpoint_path.read().splitlines()[0].split('"')[1]]) print("Building dictionary...") @@ -98,9 +73,13 @@ class args: map(lambda x: list(x) + [word_dict[""]], batch_y)) batch_decoder_input = list( - map(lambda d: d + (summary_max_len - len(d)) * [word_dict[""]], batch_decoder_input)) + map( + lambda d: d + (summary_max_len - len(d)) * [word_dict[""]], + batch_decoder_input)) batch_decoder_output = list( - map(lambda d: d + (summary_max_len - len(d)) * [word_dict[""]], batch_decoder_output)) + map( + lambda d: d + (summary_max_len - len(d)) * [word_dict[""]], + batch_decoder_output)) train_feed_dict = { model.batch_size: len(batch_x), @@ -112,7 +91,8 @@ class args: } _, step, loss = sess.run( - [model.update, model.global_step, model.loss], feed_dict=train_feed_dict) + [model.update, + model.global_step, model.loss], feed_dict=train_feed_dict) if step % 1000 == 0: print("step {0}: loss = {1}".format(step, loss)) diff --git a/projects/web page summation/utils/utils.py b/projects/web page summation/utils/utils.py index 86c492ab2..49abb555f 100644 --- a/projects/web page summation/utils/utils.py +++ b/projects/web page summation/utils/utils.py @@ -2,11 +2,12 @@ import collections import pickle import numpy as np -from newspaper import Article from nltk.tokenize import word_tokenize -from gensim.models.keyedvectors import KeyedVectors -from gensim.test.utils import get_tmpfile -from gensim.scripts.glove2word2vec import glove2word2vec +default_path = '.' +train_article_path = '.' +train_title_path = '.' +valid_article_path = '.' + def clean_str(sentence): sentence = re.sub("[#.]+", "#", sentence) @@ -55,7 +56,8 @@ def build_dict(step, toy=False): return word_dict, reversed_dict, article_max_len, summary_max_len -def build_dataset(step, word_dict, article_max_len, summary_max_len, toy=False): +def build_dataset( + step, word_dict, article_max_len, summary_max_len, toy=False): if step == "train": article_list = get_text_list(train_article_path, toy) title_list = get_text_list(train_title_path, toy) @@ -91,11 +93,11 @@ def batch_iter(inputs, outputs, batch_size, num_epochs): def get_init_embedding(reversed_dict, embedding_size): - #glove_file = default_path + "glove/glove.6B.300d.txt" - #word2vec_file = get_tmpfile(default_path + "word2vec_format.vec") - #glove2word2vec(glove_file, word2vec_file) + # glove_file = default_path + "glove/glove.6B.300d.txt" + # word2vec_file = get_tmpfile(default_path + "word2vec_format.vec") + # glove2word2vec(glove_file, word2vec_file) print("Loading Glove vectors...") - #word_vectors = KeyedVectors.load_word2vec_format(word2vec_file) + # word_vectors = KeyedVectors.load_word2vec_format(word2vec_file) with open(default_path + "glove/model_glove_300.pkl", 'rb') as handle: word_vectors = pickle.load(handle) From fbf372e54b90e4eaaf4efd649a6fbaafea56c5d7 Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Wed, 9 Sep 2020 10:10:00 +0530 Subject: [PATCH 11/12] more PEP-8 --- .../background_windows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py b/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py index abb79a322..fef6851c6 100644 --- a/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py +++ b/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py @@ -5,7 +5,7 @@ import sys url = "https://source.unsplash.com/random" -filename = "random.jpg" +file_name = "random.jpg" def is_64bit(): return sys.maxsize > 2 ** 32 From fb77b1d315ecdfbf5538b99c0ffa40995fde03d2 Mon Sep 17 00:00:00 2001 From: Aditya Jetely Date: Wed, 9 Sep 2020 10:12:04 +0530 Subject: [PATCH 12/12] PEP-8 --- .../background_windows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py b/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py index fef6851c6..9e694b4f3 100644 --- a/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py +++ b/projects/write a script to download a random image from unsplash and set it as wallpaper/background_windows.py @@ -32,7 +32,7 @@ def setup(pathtofile,version): if __name__ == "__main__": try: - download(url, filename) + download(url, file_name) setup(file_name) except Exception as e: print(f"Error {e}")