blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
a523fb24383778cfa759ebc418562c3a9384aab5 | Python | mjbouvet/Linear-Regression-Modeling-for-Oliver-Wyman | /Python Code/EDA_NY.py | UTF-8 | 13,612 | 2.9375 | 3 | [] | no_license | import pandas as pd
import numpy as np
import seaborn as sns #visualization
import matplotlib.pyplot as plt #visualization
sns.set(color_codes=True)
#Import Files
casesData = pd.read_csv("H:/Documents/Oliver Wyman Interview/COVID Cases.csv")
mobilityIndex = pd.read_csv("H:/Documents/Oliver Wyman Interview/Mobility Ind... | true |
427974cd5b1e0cf36cddb4536349f8bb8e9496cd | Python | guomulian/caregivers | /cleaning/utils.py | UTF-8 | 2,229 | 3.453125 | 3 | [] | no_license | import pandas as pd
from pathlib import Path
def get_project_root() -> Path:
return Path(__file__).parent.parent
def get_cols_with_na_values(df):
return df.columns[df.isna().any()]
def print_cols_with_na_values(df):
cols = get_cols_with_na_values(df)
print("Columns with NaN values:\n\n{}".format(... | true |
c355580824477bdfb1f09db8640d0fb23c7f16b2 | Python | aayc/code-contest-problems | /codeforces/678B/solution.py | UTF-8 | 974 | 4.09375 | 4 | [] | no_license | '''
B. The Same Calendar
The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be e... | true |
cc45171806546703a8557721c49cd38ce7f0b37a | Python | siddhantdeep/MachineLearning | /Polynomial Regression/polynomial_regression_me.py | UTF-8 | 1,646 | 3.625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 4 17:44:39 2019
@author: 764958
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#import dataset as DataFrames and split them into independent and dependent variables
dataset = pd.read_csv('Position_Salaries.csv')
level = datase... | true |
ebe2d1eec9a595b66dde8e04fcd077d19e1e4995 | Python | quanaimaxiansheng/1805-2.py | /03day/6-私有公有.py | UTF-8 | 177 | 2.59375 | 3 | [] | no_license | class wo():
def __init__(self,mimi):
self.__mimi = mimi
def getmimi(self):
return self.__mimi
mimi=input("请输入你的秘密")
yuxing=wo(mimi)
print(yuxing.getmimi())
| true |
34285608be053d54a240f38590098d6b4196e8b4 | Python | Carlos123b/X-Serv-Python-Multiplica | /mult.py | UTF-8 | 222 | 3.78125 | 4 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python3
# -*- coding: utf-8 -*-
for i in range(1,11):
print("Tabla del " + str(i) + ":")
print("---------------------------")
for j in range(1,11):
print(i,"por",j,"es",i*j)
print("\n")
| true |
ac0f777fa1bd9b17564c8341b538f5e9a05a9036 | Python | Redpike/advent-of-code | /2015/d11/d11.py | UTF-8 | 1,464 | 3.453125 | 3 | [] | no_license | def check(password_string):
if 'i' in password_string or 'o' in password_string or 'l' in password_string:
return 0
count = 0
flag = 0
char = ''
for i in range(len(password_string) - 1):
if password_string[i] == password_string[i + 1] and password_string[i] not in char:
c... | true |
e76f50ee968bbce8175547a7e4a0715bc5f79c9b | Python | joose1983/answer-for-python-crush-course-2ndE | /Chapter 9/making_pizzas.py | UTF-8 | 166 | 3.359375 | 3 | [] | no_license | from pizza import *
def make_pizza(size, *toppings):
print("hello")
make_pizza(16, 'pepperoni')
make_pizza(1, 'mushrooms', 'green peppers', 'extra cheese')
| true |
c93d11531c35b18761e0297712e7099153f6c9ee | Python | joel-roland/joel-test-commit | /Databricks Bootcamp/Data Engineering Workshop/Delta Lake Workshop - Delta Lake Primer.py | UTF-8 | 21,619 | 2.625 | 3 | [] | no_license | # Databricks notebook source
# MAGIC %md
# MAGIC
# MAGIC # Ensuring Consistency with ACID Transactions with Delta Lake (Loan Risk Data)
# MAGIC
# MAGIC <img src="https://pages.databricks.com/rs/094-YMS-629/images/delta-lake-logo-whitebackground.png" width=200/>
# MAGIC
# MAGIC This is a companion notebook to provide... | true |
0a130263d8e40df7bfaca48d84613f8c8a66b64e | Python | alyoshinaarina/vpl19 | /chistyakova.py | UTF-8 | 70 | 3.484375 | 3 | [] | no_license | n = input('What is your name? ')
print ('Nice to meet you, ',n, ':)')
| true |
19245158710b3bd7d512910287461abe3692094f | Python | Semeriuss/LiberNet | /hub/routes.py | UTF-8 | 5,806 | 2.734375 | 3 | [] | no_license | from flask import render_template, url_for, flash, redirect, request, session
from hub import app, db, bcrypt
from hub.forms import RegistrationForm, LoginForm, ReviewForm
from hub.functions import authorize, is_authorized, api_search
from flask_login import login_user, current_user, logout_user, login_required
# Rout... | true |
ba3823993a47dd73b6bc998e6529107a0d56e11a | Python | j2kun/rote | /rote/rote.py | UTF-8 | 2,600 | 2.828125 | 3 | [] | no_license | import sys
class Rote(object):
def __init__(self):
self.handlers = {
'setup': None,
'newdata': None,
'foreach': None,
'skipif': None,
'describe': None,
'teardown': None,
}
self.accumulator = []
self.new_data =... | true |
1ec663808c13b421ebbe0af6cbbfb37278e47b26 | Python | jsz14897502/eclass | /home/robot/robot_campus_news_info.py | UTF-8 | 1,372 | 2.75 | 3 | [] | no_license | """
Version: 0.1
Author: lvtoo
e-mail: o@oouul.com
Date: 2018/11/25
"""
import requests
from bs4 import BeautifulSoup
from home.models import New
from datetime import datetime
def del_start_blank(str1):
for i in range(100):
if str1.startswith(' '):
str1 = str1[7:]
else:
... | true |
45198c99be41613fbfca6d562f2bc3c2988c9879 | Python | zeibou/Tapiocas | /tapiocas/text_reco.py | UTF-8 | 1,960 | 2.625 | 3 | [] | no_license | from enum import Enum
import pytesseract
import logging
# OCR ENGINE MODE: https://tesseract.patagames.com/help/html/T_Patagames_Ocr_Enums_OcrEngineMode.htm
class OEM(Enum):
TESSERACT_ONLY = 0 # Run Tesseract only - fastest
CUBE_ONLY = 1 # Run Cube only - better accuracy, but slower
TESSERACT_CUBE_COMBI... | true |
453bf60182b49345cce2b7641aa881525b4ebce3 | Python | wolegeyun/python_data_analyst | /python统计分析/2假设检验1 3种t检验.py | UTF-8 | 2,892 | 3.40625 | 3 | [] | no_license | #coding:utf8
# #2.假设检验
# 是数理统计学中根据一定假设条件由样本推断总体的一种方法。具体作法是:根据问题的需要对所研究的总体作某种假设,记作H0
# 选取合适的统计量,这个统计量的选取要使得在假设H0成立时,其分布为已知;
# 由实测的样本,计算出统计量的值,并根据预先给定的显著性水平进行检验,作出拒绝或接受假设H0的判断。
# 常用的假设检验方法有u—检验法、t检验法、χ2检验法(卡方检验)、F—检验法,秩和检验等。
#1 t检验,看样本的平均值和总体的平均值差异 是否显著 https://wenku.baidu.com/view/7d36c04b2e3f5727a5e9620d.html
#https:... | true |
6ad3546ad7ba931824358a637a75089c0864de76 | Python | yudh1232/Codeup-Algorithm | /1126 정수 계산기.py | UTF-8 | 260 | 3.65625 | 4 | [] | no_license | a, b = map(int, input().split())
print("{0} + {1} = {2}".format(a, b, a + b))
print("{0} - {1} = {2}".format(a, b, a - b))
print("{0} * {1} = {2}".format(a, b, a * b))
print("{0} / {1} = {2}".format(a, b, a // b))
print("{0} % {1} = {2}".format(a, b, a % b))
| true |
b337a306a4162105d029a1d275c42ee3a219d0c9 | Python | Zidoing/learning | /老男孩/xxx.py | UTF-8 | 628 | 3.171875 | 3 | [] | no_license | import re
print re.findall('w\w{2}l', 'hello world')
print re.findall('[a-z]', 'adfdasf')
print re.findall('[^com]', 'com')
print re.findall('\w', 'com')
print re.search('\w', 'com').group()
print re.search('f(as)|ff', 'sdjkfasasff').group()
ret = re.search('(?P<id>\d{3})(?P<name>\w{3})', 'dsafsf33343fda')
print r... | true |
95ba3b99b1a055e3fa3a79ae5a91eadd0fde7193 | Python | nyush-se-spring2021-forum/OurTieba | /ourtieba/configs/functions.py | UTF-8 | 2,468 | 3.0625 | 3 | [
"MIT"
] | permissive | import datetime
import functools
from contextlib import contextmanager
from flask import session, redirect
# For now, we just assume that all the sessions are not tampered.
# Forgery may be possible, but it's csrf token's lob to find it out
# (which we haven't implemented yet).
def login_required(f):
"""
Dec... | true |
29ca184d7dcda029a8824ce4b775fa047aff72d8 | Python | shulhannur/Chat-App-Using-Parallel-and-Distributed-System | /client.py | UTF-8 | 1,734 | 2.65625 | 3 | [] | no_license | import socket
import threading
import tkinter
import tkinter.scrolledtext
from tkinter import simpledialog
HOST = '127.0.0.1'
PORT = 5005
class Client:
def __init__(self,host,port):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((host, port))
msg = tkinter.Tk()
msg.withdr... | true |
50151ec2201bc0cfddc017b57c73cb5096ee79c1 | Python | Suchi-M/object-storage-extension-samples | /vmware-ose-common-test-suites/framework/libs/clients/s3_api_client.py | UTF-8 | 2,150 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | import boto3
import botocore
class S3APIClient(object):
'''
auth_info{source, type, username, password, tenant, token, app_id, api_key}
type=basic: user, password, tenant
type=token: token
type=api_key: app_id, api_key
'''
def __init__(self,
endpoint,
auth... | true |
f9d695a0f80854f156421e719997a874006846f6 | Python | StBogdan/PythonWork | /Leetcode/1254.py | UTF-8 | 1,805 | 3.609375 | 4 | [] | no_license | from typing import List
class Solution:
def closedIsland(self, grid: List[List[int]]) -> int:
islands = 0
n = len(grid)
m = len(grid[0])
def global_warm(grid_mod, i, j):
stillIsland = True
if grid_mod[i][j] == 0:
if i == 0 or... | true |
d95a46d9c71f2b0dfc295f4ff048e6a329a1fbc2 | Python | owkin/FLamby | /flamby/datasets/fed_isic2019/dataset_creation_scripts/color_constancy.py | UTF-8 | 1,223 | 2.953125 | 3 | [
"CC-BY-NC-4.0",
"MIT"
] | permissive | from __future__ import division
import cv2
import numpy
def color_constancy(img, power=6, gamma=None):
"""
Preprocessing step to make sure that the images appear with similar brightness
and contrast.
See this [link}(https://en.wikipedia.org/wiki/Color_constancy) for an explanation.
Thank you to [... | true |
66ee9d5bf9f1d0b87893ef76ce16b31cf8c37465 | Python | ubercareerprep2019/Uber-Career-Prep-Homework-Ammon | /Assignment-2/part3.py | UTF-8 | 2,259 | 3.6875 | 4 | [] | no_license | # Graphs - Ex1
from collections import deque
class GraphNode:
def __init__(self, data):
self.data = data
class GraphWithAdjacencyList:
def __init__(self):
self.__adj_nodes = {}
self.__nodes = {}
def add_node(self, key: int):
g_key = GraphNode(key)
self.__nodes[key] = g_key
self.__adj_nodes[g_key] = ... | true |
7f6cea04f09b257972330d75b3d9baac9711c26d | Python | jonathangriffiths/Euler | /Page1/EvenFibonacciSum.py | UTF-8 | 345 | 3.421875 | 3 | [] | no_license | __author__ = 'Jono'
def getEvenFibSum(max_number):
a = 1
b = 1
sum=0
while a <= max_number and b <= max_number:
new_term = a + b
a = new_term
new_term = a + b
b = new_term
if a%2 == 0:
sum+=a
if b%2 == 0:
sum+=b
return sum
pri... | true |
6467ba560234b906c89be46448d8eb917688af98 | Python | PDXostc/rvi_big_data | /data_logger.py | UTF-8 | 8,757 | 2.84375 | 3 | [] | no_license | #!/usr/bin/python
#
# Copyright (C) 2014, Jaguar Land Rover
#
# This program is licensed under the terms and conditions of the
# Mozilla Public License, version 2.0. The full text of the
# Mozilla Public License is at https://www.mozilla.org/MPL/2.0/
#
#
# A generic logger / reporter
#
import sqlite3
import Queue
i... | true |
0d0770d77de5cad2ad8f2d256589a558404303ef | Python | AthaG/Kata-Tasks | /5kyu/BestTravel_5kyu.py | UTF-8 | 1,933 | 3.9375 | 4 | [] | no_license | '''John and Mary want to travel between a few towns A, B, C ... Mary has on a sheet of paper
a list of distances between these towns. ls = [50, 55, 57, 58, 60]. John is tired of driving
and he says to Mary that he doesn't want to drive more than t = 174 miles and he will visit only 3 towns.
Which distances, hence whic... | true |
d139c1d4d3672813da9f0a4b6a504fa0ee8aec79 | Python | zqy1/pythonCookbook | /thread/locals.py | UTF-8 | 465 | 3.34375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import threading
local = threading.local()
local.name = "main"
def func():
local.name = "local"
print local.name
t1 = threading.Thread(target=func)
t1.start()
t1.join()
print local.name
# 首先,启动线程会打印线程内部的变量, join阻塞线程后,则会打印全局的name变量
# local 小写字母类 保证了线程设置的属性不会被其他线程设置的属性替换
# 主线... | true |
148804342781f073c197e6b8e477d60006b14556 | Python | ginnyyang/MyPython | /learning_process/coroutine_test.py | UTF-8 | 1,112 | 3.4375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#协程看上去也是子程序,但执行过程中,在子程序内部可中断,然后转而执行别的子程序,在适当的时候再返回来接着执行
def consumer():
r=''
while True:
n=yield r
if not n:
return
print('[CONSUMER] Consuming %s...' %n)
r='200 OK'
def produce(c):
c.send(None)
n=0
while n<5:
n=n+1
print('[PRODUCER] Producing %s...... | true |
3e8a4f5b8b226f5349188528e87d6a5ae04b11c1 | Python | sonivaidehi/IoTPracticals | /motion_test.py | UTF-8 | 381 | 3.078125 | 3 | [] | no_license | import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(15, GPIO.IN)
GPIO.setup(24, GPIO.OUT)
while True:
input_state = GPIO.input(15)
if input_state == True:
print("Motion Detected")
GPIO.output(24,True)
time.sleep(1)
GPIO.output(24,False)
time.sleep(4)
... | true |
1628259188b938fd0a7e580dea26f49283c4cd84 | Python | IncubatorShokuhou/cpol_processing | /cpol_processing/filtering.py | UTF-8 | 6,682 | 2.734375 | 3 | [
"MIT"
] | permissive | """
Codes for creating and manipulating gate filters.
@title: filtering
@author: Valentin Louf <valentin.louf@monash.edu>
@institutions: Monash University and the Australian Bureau of Meteorology
@date: 20/11/2017
.. autosummary::
:toctree: generated/
texture
do_gatefilter_cpol
do_gatefilter
filt... | true |
f1b30ceb0b8ad29855b06e01dbad48cf6b22736f | Python | amanuel43/chemgymrl | /tests/demo_chemistrygym.py | UTF-8 | 7,179 | 3.078125 | 3 | [] | no_license | '''
ChemistryGym Demo
:title: demo_chemistrygym.py
:author: Chris Beeler and Mitchell Shahen
:history: 2020-07-03
'''
# pylint: disable=invalid-name
# pylint: disable=protected-access
# pylint: disable=unused-import
# pylint: disable=wrong-import-order
# pylint: disable=wrong-import-position
# impo... | true |
51f93becc7639b2805bcf946edfa206bca3afe49 | Python | MFrassek/MyKoAutomationSuite | /utils/weekendParticipationPopulator.py | UTF-8 | 1,039 | 2.96875 | 3 | [] | no_license | from tablePopulator import TablePopulator
from weekendParticipation import WeekendParticipation
import os
import csv
class WeekendParticipationPopulator(TablePopulator):
@classmethod
def populate_table(cls):
weekend_participation_data = cls.get_data_from_file()
for weekend_participation in wee... | true |
79c3e451b4d8c68f7e9d495eaec54febc99bc4f5 | Python | shunyooo/MAZE | /GridMDP.py | UTF-8 | 5,748 | 2.984375 | 3 | [] | no_license | from MDP import MDP
from utils import argmax, vector_add, print_table # noqa
from grid import orientations, turn_right, turn_left
from pprint import pprint
import numpy as np, pandas as pd
import random
class GridMDP(MDP):
# grid引数を受け取る点が差分。
# grid: 各状態での報酬が格納されている。Mapデータみたいなもの。
# GridMDP([[-0.04, -0.0... | true |
d6a2aa3b1fa34c97b94551707d8e25f8c05ba217 | Python | AlexandervVugt/DarkTimesMississippi | /gui/dice.py | UTF-8 | 1,496 | 3.3125 | 3 | [] | no_license | import main
def setup():
global dice1, dice2, cube, active
one = loadImage("one.png")
two = loadImage("two.png")
three = loadImage("three.png")
four = loadImage("four.png")
five = loadImage("five.png")
six = loadImage("six.png")
dice1 = six
dice2 = six
cube = [one, two, thr... | true |
5b3dab18f8bd2a7969bc678b88b5945acbc07ae5 | Python | sfull14/bshares | /flaskblog.py | UTF-8 | 2,206 | 2.9375 | 3 | [] | no_license | from flask import Flask, render_template, url_for, flash, redirect # import Flask class
from forms import RegistrationForm, LoginForm
app = Flask(__name__) # setting app = instance of Flask class
app.config['SECRET_KEY'] = 'b54e04d10d8a6dadfec52f3671b9e0c6'
#Key: the code blocks in the HTML code get evaluated but ar... | true |
aa4692b3eabd0dddf0cf2df1fd7ce4b0c7822767 | Python | Hironobu-Kawaguchi/atcoder | /atcoder/iroha2019_day3_e.py | UTF-8 | 439 | 3.015625 | 3 | [] | no_license | # E - 「く」
# https://atcoder.jp/contests/iroha2019-day3/tasks/iroha2019_day3_e
N = int(input())
C = [input() for _ in range(N)]
ans = 0
nums = []
tmpc = '/'
tmpn = 0
for c in C:
if c == tmpc:
tmpn += 1
else:
nums.append(tmpn)
tmpn = 1
tmpc = c
nums.append(tmpn)
... | true |
a2c3631679b5065af05ca23a9365f912df4246e6 | Python | wpli/dialog | /tbh_info_datetime/src/tbh_info_datetime.py | UTF-8 | 1,427 | 3.296875 | 3 | [] | no_license | ## Datetime Information
## * functions:
## o get_current_time: returns datetime.time object
## o get_current_date: returns datetime.date object
## o get_current_datetime: returns datetime.datetime object
import sys
import datetime
sys.path.append( "../../tbh_api/src" )
from tbh_api... | true |
0ceaf215b1ae7ced6c270c95c2900c15f6289f5a | Python | lzc978/digraph | /logger_manage.py | UTF-8 | 688 | 2.703125 | 3 | [
"MIT"
] | permissive | import logging
loggers = []
class LogProxy:
"""日志代理类, 方便更换工具库中使用的日志器"""
def __init__(self, logger):
_, __ = self, logger
_.logger, _.info, _.debug, _.warning, _.error = __, __.info, __.debug, __.warning, __.error
def _get_logger(logger_name):
"""根据名称获取日志器"""
__ = logging.getLogger(l... | true |
8609502b8f94b1fb256655af4f033a1520acbdfe | Python | andremgbr/Sudoku_Selenium | /main.py | UTF-8 | 982 | 2.875 | 3 | [] | no_license | import numpy as np
board = np.array( [[0,7,0,3,0,0,0,0,9],
[5,0,0,0,0,0,8,0,0],
[3,0,1,0,4,9,0,5,0],
[0,0,0,0,0,0,0,0,0],
[9,3,0,2,0,0,4,0,0],
[1,8,0,6,0,0,9,0,7],
[8,4,0,9,0,0,0,0,0],
[0,2,0,0,0,4,0,1,0],
[0,0,0,0,0,0,5,0,0] ])
def encontra_zero(board):
for i in range(9):
... | true |
34b66a7615421013977bcfab7078861dff8f4db9 | Python | Aasthaengg/IBMdataset | /Python_codes/p02927/s887960331.py | UTF-8 | 284 | 3.171875 | 3 | [] | no_license | M,D = map(int, input().split())
def seki(n):
s = str(n)
i1,i2 = int(s[0]), int(s[1])
if i1>=2 and i2>=2:
return i1*i2
else:
return -1
res = 0
for m in range(1,M+1):
for d in range(11,D+1):
if m==seki(d):
res += 1
print(res)
| true |
b3eea8030bb9916d710c16e7d77635b9a91e537a | Python | thoppe/DeepMDMA | /src/build_descriptions.py | UTF-8 | 911 | 3.0625 | 3 | [] | no_license | import glob, os
import pandas as pd
images_per_line = 4
F_JPG = glob.glob("../results/images/*.jpg")
data = []
for f in sorted(F_JPG):
name = os.path.basename(f)
item = {}
item['f'] = f
item['channel'] = name.split('_')[0]
item['n'] = int(name.split('_')[-1].split('.')[0])
data.append(item)
... | true |
2c664f55ba4eef2ddf190eb23dd34ed996677749 | Python | sanyam-dev/hello-world | /Expense.py | UTF-8 | 2,345 | 3.734375 | 4 | [] | no_license | global expense
expense = []
Months = ["January" ,"February", "March" ,"April", "May","June", "July", "August","September", "October", "Novemeber", "December"]
response = ["Y","Yes","YES","yes","y"]
n = int(input("No. of Months:"))
if n in range(13):
pass
else:
print("ERROR MESSAGE!")
def add_data(month,exp_da... | true |
86d5c80246a6d758ade689c0aecdc23769d71a0a | Python | ashishtrehan/market_data | /stock_data.py | UTF-8 | 831 | 3.0625 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup as bs
def get_historical_data(name, number_of_days):
def scrap(number:int):
if number == 0:
return divs[number].span.text
else:
return float(divs[number].span.text.replace(',',''))
keys = ['date','open','high','low','adj_clo... | true |
062bfa15a4f1148087f952e2ca818f575b3b618f | Python | KevinJeon/The-Tragedy-of-the-commons | /models/RuleBasedAgent.py | UTF-8 | 3,322 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | import random
import numpy as np
from tocenv.components.agent import Action
from models.Agent import Agent
from tocenv.components.observation import NumericObservation
def softmax(x):
y = np.exp(x - np.max(x))
f_x = y / np.sum(np.exp(x))
return f_x
class RuleBasedAgent(Agent):
def __init__(self, a... | true |
19bac33768f960bb16898b47b98095ec3241f4ba | Python | swkaen/Raspberry_pi_RC_using_bottle | /morse_code.py | UTF-8 | 2,173 | 2.84375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
import time
class Morse_Code:
morse_code_jp = {u"イ":"il",u"ロ":"ilil",u"ハ":"lii",u"ニ":"lili",u"ホ":"lii",u"ヘ":"i",u"ト":"iilii",
u"チ":"iili",u"リ":"lli",u"ヌ":"iiii",u"ル":"lilli",u"ヲ":"illl",
u"ワ":"lil",u"カ":"ilii",u"ヨ":"ll",u"タ":"li",u"レ":"lll",u"ソ":"llli",
... | true |
d39ff4ca4b119afaa55c84447ce95d879fd0ceb7 | Python | sayan82/python-programs | /Question_2.py | UTF-8 | 429 | 4.4375 | 4 | [] | no_license | #Q2.Write a program to accept ‘n’ numbers from user , store these numbers into an array. Find out maximum and minimum number from an Array.¶
list=[]
z=True
while(z):
n=int(input("Enter a number:\n"))
list.append(n)
a=input("do want to enter a number(y/n):\n")
if a!="y":
z=False
print(... | true |
dc4f9c8c83de916e14f2dfb699a6933afae60dbf | Python | zhuifengshen/xmind-utils | /testcase/main.py | UTF-8 | 3,306 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# _*_ coding:utf-8 _*_
import logging
import sys
from testcase.testlink import xmind_to_testlink_json_file, xmind_to_testlink_xml_file
from testcase.utils import get_absolute_path
from testcase.zentao import xmind_to_zentao_csv_file
"""
A tool to parse xmind file into testcase file, which will h... | true |
37170923a38cd2a28eef571a2ad585178a9b7239 | Python | MTamPham/dublin-bikes | /db-all-exploration.py | UTF-8 | 3,615 | 2.921875 | 3 | [] | no_license | '''
Author: Tam M Pham
Created date: 22/11/2018
Modified date: 03/01/2019
Description:
Plotting distribution of activity throughout the week
Finding the most 10th busy and least 10th busy stations
'''
import os
import numpy as np
import pandas as pd
import calendar
import time
from comm... | true |
5695e3a3b24c4063aeab9046688531a615a383b4 | Python | sksam-Encoder/pythonCourse | /35Later/SumOfN.py | UTF-8 | 108 | 3.515625 | 4 | [] | no_license | def sumOf(n):
if n == 1:
return 1
else:
return n + sumOf(n - 1)
print(sumOf(5))
| true |
766bcbabdb67d6ce59a04fa64c1ed75c55a98f2a | Python | nolfonzo/rebrained | /tree.py | UTF-8 | 497 | 3.265625 | 3 | [] | no_license | def traverse(node):
>>> node1=Node(1)
>>> node2=Node(2)
>>> node3=Node(3,node1,node2)
>>> node4=Node(4)
>>> node5=Node(5,node3,node4)
>>> traverse(node5)
5
3
1
2
4
if node==None: return
print node.value
traverse(node.left)
traverse(node.right)
class Node:
... | true |
8e88dbbfcd84f340c802c6c135623d8962adc50c | Python | amirnafisa/decon4lindt | /detection_unit/drawing_tools.py | UTF-8 | 681 | 3.109375 | 3 | [] | no_license | from PIL import ImageDraw
colour = {}
colour[0] = (255, 255, 255)
colour[1] = (255, 0, 0)
colour[2] = (0, 255, 0)
colour[3] = (0, 0, 255)
def drawrect(drawcontext, xy, outline=None, width=0):
[(x0,y0),(x1,y1)] = xy
points = (x0, y0), (x1, y0), (x1, y1), (x0, y1), (x0, y0)
drawcontext.line(points, fill=out... | true |
dbd206c7779b63c76bf266998be7da17ace40cb2 | Python | RahulRavishankar/Oblivious_Transfer | /ot.py | UTF-8 | 4,025 | 3.125 | 3 | [] | no_license | from hashlib import sha256
from cryptography.fernet import Fernet
import base64
import os
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
import random
class Alice:
def __init__(s... | true |
c73afcc553001c11021fee5dc3f50e4e79ee9dd3 | Python | okbengii/scrapydemo | /miao/spiders/textproxy.py | UTF-8 | 993 | 2.53125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
# import requests
# try:
# requests.get('http://wenshu.court.gov.cn/', proxies={"http":"http://222.85.50.168:808"})
# except:
# print "failed"
# else:
# print "success"
# import re
# con = '链接:<a href="http://git.ghostscript.com/?p=ghostpdl.git;h=8210a2864372723b49c526e2b102fdc00c9c4699" ta... | true |
aa1d94e3329ae35c60e1993448e6f770c495c9c4 | Python | RaymondLZhou/uplifting-news | /src/visualize.py | UTF-8 | 782 | 3.21875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import matplotlib.pyplot as plt
def display_dataset(train_dataset):
for example, label in train_dataset.take(1):
print("Texts: ", example.numpy()[:3])
print()
print("Labels: ", label.numpy()[:3])
def display_results(test_loss, test_acc, history):
def plot_graphs(metric):
plt.... | true |
1af5282a19fb1c7f5209fe8cd0d69e7573da0154 | Python | jackwong95/MMURandomStuff | /TDS3651 - Visual Information Processing/Assignment/Part 2/precisionCurve.py | UTF-8 | 2,393 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | import pickle
import numpy as np
import matplotlib.pyplot as plt
import os
from SIFT import computeDistances as sift
from RGB import computeDistances as rgb
# Food database information
dbSize = 1000
retrieves = [i for i in range(0, 1000, 10)]
nPerCat = 100
nC = 10
labels = ('AK','BL','CD','CL','DR','MG','NL','PG','RC'... | true |
772052abdee8092765dfa09a459aefa3a753813f | Python | baidw/languages | /python/exam/exam_0103_comment.py | UTF-8 | 310 | 3.21875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__='baidw'
#one comment
#two comment
def mymaxnum(a,b):
"this is a compare b ,if a>b return a,else return b "
if a>b:
return a
else:
return b
print "max number:",mymaxnum(10,20)
print "文档字符串注释[用于在线文档]:",mymaxnum.__doc__
| true |
d9b4bc752d7d8a9ab8af1620088996c45d9832ed | Python | kannera/ocr_repair | /fix_tools.py | UTF-8 | 6,835 | 2.875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import json
import re
import operator
import dbm
INPUT = 0
OUTPUT = 1
START = 0
MIDDLE = 1
END = 2
def parse_data_row(line):
line = re.split("\t", line)[1:]
l = int(len(line)/2)
return [line[i*2:i*2+2] for i in range(0, l)]
def parse_corrections_to_list(corrections):
... | true |
728eae480cbacb206eefec64b9b487e95589a4ed | Python | marcosdaniel0616/Curso-de-Python---Geek-university | /counter.py | UTF-8 | 1,868 | 4.15625 | 4 | [] | no_license | """
Módulo Collections - Counter (Contador)
https://docs.python.org/3/library/collections.html#collections.Counter
Collections -> High-Performance Container Datetypes
Counter -> Recebe um iterável como parâmetro e cria um objeto do tipo Collections Counter que é parecido
com um dicionário, contendo como chave o elem... | true |
46657cd5071c8885586ba669ce572ecec33cc217 | Python | Pastilhas/IART-FEUP-2 | /q_learning/zhed_bot.py | UTF-8 | 6,662 | 2.9375 | 3 | [] | no_license | import sys
import q_learning
from levels import get_level
class Game:
def __init__(self):
self.run = True
self.win = False
self.level = 6
self.board = []
self.lastState = None
self.currState = []
self.generate_board()
self.actions = self.getActions()... | true |
3a014882742ae31f75108bef8cc83be2e0d678b5 | Python | awwad/depresolve | /depresolve/resolver/rbtpip_recheck_satisfied.py | UTF-8 | 2,224 | 2.53125 | 3 | [
"MIT"
] | permissive | """
Convenience script, one-time.
"""
import depresolve
import depresolve.depdata as depdata
import depresolve.resolver.resolvability as ry
def recheck_all_unsatisfied():
depdata.ensure_data_loaded(CONFLICT_MODELS=[3], include_edeps=True)
solutions = depdata.load_json_db('data/resolved_via_rbtpip.json')
insta... | true |
c78f6c134330b3c2ff214371e10c8cf5ce3adea3 | Python | farrellsc/zAutoPilot | /auto_pilot/data/world_map.py | UTF-8 | 629 | 2.8125 | 3 | [
"MIT"
] | permissive | from auto_pilot.data.coordinates import Coordinates
import numpy as np
class WorldMap:
"""
This class describes a grid cell world map.
"""
def __init__(self, mat: np.matrix):
self.map = mat
self.heuristic = None
self.shape = self.map.shape
def from_file(self, path_to_map: ... | true |
e52a669dbe2b0257a4bac624df31ab12efef6176 | Python | shubhammishra277/Utilities | /Fileutility.py | UTF-8 | 1,857 | 3.046875 | 3 | [] | no_license | import glob
import subprocess
import os
class datamovement(object):
def __init__(self):
self.datapath=input("Enter the folder path for which you want to seggregate:")
def extensiongetter(self):
distinctextenstions=[i.split(".")[-1] for i in glob.glob("%s/*"%self.... | true |
a0c3c1c0abd33059dd71cb78ddcb496e99c1ad23 | Python | rafaelparente/pa-nests | /nestParser.py | UTF-8 | 9,690 | 2.859375 | 3 | [] | no_license | #!python3
#-*- coding: utf-8 -*-
import os
import sys
import json
import webbrowser
import operator
from math import ceil
from geopy.distance import vincenty
def dump_poke_groups(poke_groups, pokeGroups):
data = []
for groupNum in range(pokeGroups):
groupId = '@'+str(groupNum)
groupNode = poke... | true |
7afcb16d117f96f15ad717373a0943417841d36a | Python | surajsoni2/python-basic | /prime_number.py | UTF-8 | 271 | 4.1875 | 4 | [] | no_license | # Python program to check whether a number is Prime or not
num = int(input(("enter a number to check")))
for x in range(2,num):
if num%x == 0:
print(num,"is not prime")
break
elif x==num-1:
print(num,"is prime")
break | true |
2331251b0491a45ee90098c1caa0554dc86d3fcd | Python | AdracarysW/Kombat-Simulator | /player.py | UTF-8 | 2,925 | 3.1875 | 3 | [] | no_license |
from textTools import *
from description import *
class Player():
def __init__(self, playerClass, name):
self.ourClass = playerClass
self.name = name
self.mana = 3
self.hp = 0
self.maxHp = 0
self.atk = 0
self.spd = 0
self.defn = 0
self.mana ... | true |
fc4763cf963de9cbbdfb6db2230965bd2fcbc82d | Python | JoshuaRabiu/String-Marionette | /app.py | UTF-8 | 1,979 | 3.71875 | 4 | [] | no_license | from tkinter import *
root = Tk()
#Creates Title
title = Label(root, text="String Marionette", bg="#336E7B", fg="white")
title.pack(side=TOP)
#Creates Input Field & Sets Cursor Focus inside the field
usr_input = Entry(root)
usr_input.pack()
usr_input.focus_set()
#Creates Output Frame
outputFrame = Frame(root)
outputFr... | true |
d70cce19a18a1b8e5626d5f73aecea18a5a4fa13 | Python | ohhhhmy/OhGongCo | /0314/베스트앨범.py | UTF-8 | 1,214 | 3.375 | 3 | [] | no_license | def solution(g, p):
playlist = {}
genre_length = len(g)
list_length = len(p)
only_number = {}
play = []
for i in range(list_length):
if p[i] not in only_number:
only_number[p[i]] = []
only_number[p[i]].append(i)
print(only_number)
for i in range(genre... | true |
5d4895a276a0208914d68dc43950c69719c312d2 | Python | davjs/ai-programmer | /tests/generatortests2.py | UTF-8 | 2,520 | 3.109375 | 3 | [] | no_license | import main.expressions
from main.function import Function
from main.programgenerator2 import ProgramIntention, Parameter
from main.expressions import get_computed_boolean_expressions_using_all_variables
__author__ = 'David'
import unittest
from main import programgenerator2
class GeneratorTests(unittest.TestCase):... | true |
7c4fef5fb91d1842806e04ccd51177309456bdc2 | Python | victorarodri/probprog | /scripts/model.py | UTF-8 | 1,991 | 2.84375 | 3 | [] | no_license | # Imports
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
from edward.models import (
Dirichlet, Categorical, ParamMixture)
def mc_lda_model(D, S, V, K, w_obs):
"""Defines multi-channel LDA model in Edward.
Args:
... | true |
ecf31f842d63b2a6acc474e1133e99daffc1cca2 | Python | developyoun/AlgorithmSolve | /solved/15059.py | UTF-8 | 184 | 3.265625 | 3 | [] | no_license | a1, b1, c1 = map(int, input().split())
a2, b2, c2 = map(int, input().split())
res = 0
if a1 < a2:
res += a2-a1
if b1 < b2:
res += b2-b1
if c1 < c2:
res += c2-c1
print(res) | true |
c8a0a78a693b8c9e692b12d000e263f349633a8e | Python | ksavietta/PythonExercises | /6.00.1x Files/probset2-1.py | UTF-8 | 853 | 3.015625 | 3 | [] | no_license | balance = 4842
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
monthlyInterestRate = 0
minimumMonthlyPayment = 0
monthlyUnpaidPayment = 0
updatedBalanceEachMonth = balance
total = 0
for month in range(1,13):
balance = updatedBalanceEachMonth
monthlyInterestRate = annualInterestRate/12.0
minimumMonthlyP... | true |
8f943c05476abceaf8e874360daf646cd3ffb700 | Python | Antonio24ch/Bedu-sesion141120 | /e02_imc.py | UTF-8 | 748 | 3.640625 | 4 | [] | no_license | nombre = input('cual es tu nombre?\n')
peso = input(f'{nombre}, cual es tu peso?')
peso = float(peso)
altura = input(f'{nombre}, cual es tu altura?')
altura = float(altura)
imc = peso / (altura*altura)
if imc >= 40:
grado_obesidad = 'obesidad muy severa.'
elif imc >= 35:
grado_obesidad = 'obesidad severa.'... | true |
0f3cba64cd8116dc85cd747b0c874528604499fb | Python | ABenxj/leetcode | /31 nextPermutation.py | UTF-8 | 936 | 3.25 | 3 | [] | no_license | #!/usr/bin/env pyhton
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021 , Inc. All Rights Reserved
#
"""
Authors: jufei
Date: 2021/4/7 5:34 PM
"""
from typing import List
class Solution:
def nextPermutation(self, nums: List[int]) -> None:
"""
第一步,依次从后向前,找出第一个变小的数的位置和值; 第二步,找出比该值大的最后一个数,对换位置,排序
... | true |
d0ba017f3dd46ca4606197aa2fcc230409786079 | Python | JKrysztofiak/single-layer-neural-network | /Perceptron.py | UTF-8 | 2,915 | 2.921875 | 3 | [] | no_license | from random import randint
import math
def vector_length(v: list) -> float:
value = 0
for x in v:
value+=pow(x,2)
return math.sqrt(value)
def multiply_vector(v: list, m: float) -> list:
res = []
for value in v:
res.append(float(value)*m)
return res
def add_vectors(v1: list,v2:... | true |
882fee7f1fb0d22af6ea3fb9bd8838b9b0fd2a25 | Python | apalala/exercism | /python/robot-name/robot_name.py | UTF-8 | 700 | 3.109375 | 3 | [] | no_license | import string
from datetime import datetime
class Robot():
def __init__(self):
self.name = None
self.reset()
def reset(self):
now = datetime.now()
day_of_year = now.timetuple().tm_yday
day_half = now.hour // 12
self.name = (
i2text(day_of_year * da... | true |
057e318db4a9bbd1e9007ca03f46418c01dce7ae | Python | upsidedownio/coding-club-hr | /season001/20180829-week2/gted/basic_bst.py | UTF-8 | 2,093 | 4.0625 | 4 | [] | no_license | #!/bin/python3
class Node(object):
def __init__(self, data):
self.left = None
self.right = None
self.data = data
self.level = 0
def __str__(self):
return str(self.data)
def _get_next(sub_root, data):
if data < sub_root.data:
return sub_root, sub_root.left... | true |
90eaf15eb0922042f91d484104711b72565e22c6 | Python | Alexfordrop/Basics | /анотация_типов.py | UTF-8 | 254 | 3.515625 | 4 | [] | no_license | from typing import List, Dict
numbers: Dict[str, int] = {'one': 1, 'two': 2}
values: List[int] = numbers.values()
def _sum(a: int, b: int) -> int:
return a + b
_sum(*values)
_sum('Rock ', 'Hard')
print(_sum(*values))
print(_sum('Rock ', 'Hard')) | true |
e90a12aa8649f83366d8ae0b0f9638eb21538fed | Python | fbserkov/praxis | /robert_martin/payroll_system/change_classification_transaction.py | UTF-8 | 2,148 | 2.765625 | 3 | [] | no_license | from change_employee_transaction import ChangeEmployeeTransaction
from employee import EmpId, Employee
from payment_classification import (
CommissionedClassification, HourlyClassification,
PaymentClassification, SalariedClassification)
from payment_schedule import (
BiweeklySchedule, MonthlySchedule, Payme... | true |
c9859d933b31cd3038f60ed4999278e2b02d656d | Python | ZeroNetto/Dictionaries | /Modules/ordered_array.py | UTF-8 | 3,161 | 3.5 | 4 | [] | no_license | #!/usr/bin/env python3
import sys
import utils
class Ordered_array:
def __init__(self, elements_type):
self.ord_array = []
(ok, msg) = utils.check_type(elements_type)
if not ok:
raise ValueError(msg)
self.elements_type = msg
def append(self, element):
eleme... | true |
10da4ca624ae902f917fd4071e0a76edce4a5ea8 | Python | evbolokhov/PythonPY100 | /Занятие1/Лабораторные задания/task3/main.py | UTF-8 | 139 | 3.421875 | 3 | [] | no_license | if __name__ == "__main__":
# Write your solution here
a = float(input("a :"))
n = int(input("n: "))
print("a^n: ", a ** n)
| true |
e4127ca88fd4629bf59bc80f6e806e2aa8e9bbbe | Python | xenron/sandbox-da-python | /book/packt/Python.Data.Visualization.Cookbook/3367OS_06_Code/ch06/ch06_rec01_02_pil_thumbnails.py | UTF-8 | 2,234 | 3.328125 | 3 | [] | no_license | import os
import sys
from math import floor
from PIL import Image
class Thumbnailer(object):
def __init__(self, src_folder=None):
self.src_folder = src_folder
self.ratio = .3
self.thumbnail_folder = "thumbnails"
def _create_thumbnails_folder(self):
thumb_path = os.path.join(se... | true |
26353da2fa7f18d20e01babe4404a96a44d0c6a3 | Python | Hackerfarm/python-workshops | /LivePygame/game02.py | UTF-8 | 5,629 | 2.96875 | 3 | [
"Unlicense"
] | permissive | import pygame, types, threading, traceback
class Game:
def __init__(self):
self.size = (500,500)
self.running = True
self.scene = list()
self.event_handlers = dict()
self.event_handlers[(('type',pygame.QUIT),)] = self.on_quit
self.event_handlers[(('type',pygame.KEYD... | true |
4c6d685cccc6536c531fcf12f6a518d822e2cac4 | Python | amiraliakbari/sharif-mabani-python | /by-subject/mathematics/integration.py | UTF-8 | 502 | 3.84375 | 4 | [
"MIT"
] | permissive | def drange(start, stop, step):
'''
produces numbers with given step in the given range
'''
r = start
while r < stop:
yield r
r += step
def simpleIntegration(lower,upper,a,b,c, delta):
'''
integration of second degree polynomial:
a * x**2 + b*x + c
using simple rectan... | true |
d8dbc2e47e3a6c39eeedc207d2763c5d17f353a4 | Python | parsd/fastapi-login | /test/mocks.py | UTF-8 | 830 | 3.015625 | 3 | [
"MIT"
] | permissive | """Mock objects for testing."""
from typing import Optional
from pydantic import BaseModel
class User(BaseModel): # noqa: D101
name: str
class SessionStore: # noqa: D101
def __init__(self): # noqa: D107
self._ids = {}
def __contains__(self, item): # noqa: D105
return item in self.... | true |
3396a0d9626b6bd09bff30ffdd9611a1ad42fca8 | Python | orenlivne/euler | /rosalind/fib/rosalind_fib.py | UTF-8 | 2,322 | 3.75 | 4 | [] | no_license | '''
============================================================
http://rosalind.info/problems/fib/
Problem
A sequence is an ordered collection of objects (usually
numbers), which are allowed to repeat. Sequences can be finite or
infinite. Two examples are the finite sequence (PI,-SQRT(2),0,PI)
and the infinite seque... | true |
9bbe9d24a557a31965d4646d738e75c5e01b15e4 | Python | pedroceciliocn/intro-a-prog-py-livro | /Cap_6_Listas_dicionários_tuplas_e_conjuntos/prog_6_9_pesquisa_sequencial.py | UTF-8 | 302 | 4.03125 | 4 | [] | no_license | # Programa 6.9 - Pesquisa sequencial
L = [15, 7, 27, 39]
p = int(input("Digite o valor a procurar: "))
x = 0
achou = False
while achou == False and x < len(L):
if L[x] == p:
achou = True
x += 1
if achou:
print(f"{p} achado na posição {x}")
else:
print(f"{p} não encontrado")
| true |
10e06d1684c7cec84027455660e1d36f4080ac49 | Python | MathPlus/Information-Theory | /info_gain_ratio_contour_plots.py | UTF-8 | 2,139 | 2.65625 | 3 | [] | no_license | import numpy as np
from info_theory_functions import prescribed_igr_fn101
import matplotlib.pyplot as plt
dirname_fig = 'info_gain_ratio_contour_plots'
plt.rcParams['font.weight'] = 'bold'
plt.rcParams['figure.titleweight'] = 'bold'
plt.rcParams['axes.titleweight'] = 'bold'
plt.rcParams['axes.labelw... | true |
cdde86e164130b9c7240da96da4fea14508245e8 | Python | lew18/practicepython.org-mysolutions | /ex32-hangman.py | UTF-8 | 3,438 | 4.5625 | 5 | [
"MIT"
] | permissive | """
https://www.practicepython.org
Exercise 32: Hangman
2 chilis
This exercise is Part 3 of 3 of the Hangman exercise series. The other exercises are: Part 1 and Part 2.
You can start your Python journey anywhere, but to finish this exercise you will have to have finished
Parts 1 and 2 or use the solutions (Part 1 ... | true |
5812bba02fd2fbadd736898256932a3b46ba4df9 | Python | Heinhtet612/Sandbox_SP52 | /assignment1.py | UTF-8 | 5,316 | 3.890625 | 4 | [] | no_license | """
Replace the contents of this module docstring with your own details
Name: Hein Htet Ko
Student ID: 13807190
Date started: 06/August/2021
GitHub URL: https://github.com/Heinhtet612/SP52_Assignment01
"""
name = "places.csv"
def main():
print("Travel Tracker 1.0 - by <Hein Htet Ko>")
print(readfile(), "Place... | true |
1c855dc02d20a1596d6f231c742a60a66b716cc1 | Python | potsbo/nlp100 | /030.py | UTF-8 | 1,374 | 3.734375 | 4 | [] | no_license | # 30. 形態素解析結果の読み込み
# 形態素解析結果(neko.txt.mecab)を読み込むプログラムを実装せよ.ただし,各形態素は表層形(surface),基本形(base),品詞(pos),品詞細分類1(pos1)をキーとするマッピング型に格納し,1文を形態素(マッピング型)のリストとして表現せよ.第4章の残りの問題では,ここで作ったプログラムを活用せよ.
import re
def divide_into_sentences(lines):
sentences = []
sentence = []
for line in lines:
if line == 'EOS':
... | true |
03fc58778bfaf5cdf1f5e2abccc2b838b7410007 | Python | Srishti14/ex_06_03_coursera_py4e | /ex_06_03.py | UTF-8 | 198 | 3.28125 | 3 | [] | no_license | def counter(string,the_letter):
count = 0
for letter in string:
if letter == the_letter:
count = count + 1
print(count)
counter("srishti","s")
counter("grapes","j")
| true |
4ed2adce02c2341d013d6f4d6729648232198fa5 | Python | limteng-rpi/ir_final | /src/ner/util.py | UTF-8 | 3,270 | 2.65625 | 3 | [] | no_license | import torch
from src.ner.model import LstmCnnOutElmo
def load_lstm_cnn_elmo_model(model_file, elmo_option, elmo_weight,
gpu=False, device=0):
"""Load the LSTM-CNN+ELMo model from file.
:param model_file: Path to the model file.
:param elmo_option: ELMo option file.
:para... | true |
a1a8f3c0511b7152814afb69579434be4aef8f5f | Python | msaqibdani/LeetCode-Practice | /LC523_ContinuousSubArraySum.py | UTF-8 | 566 | 2.859375 | 3 | [] | no_license | class Solution:
def checkSubarraySum(self, nums: List[int], k: int) -> bool:
total = 0
seen = {}
seen[total] = -1
for i, num in enumerate(nums):
total += num
if k != 0:
total %= k
... | true |
ed4ff7e25e638ff0a27cd13c1658505b576bc6e6 | Python | hoteldelluna/AlgoStudy | /TaeJuneJoung/COD/lv3.TapeEquilibrium.py | UTF-8 | 236 | 2.65625 | 3 | [] | no_license | def solution(A):
minV = 9876543210
left, right = 0, sum(A)
for i in range(len(A)-1):
left += A[i]
right -= A[i]
value = abs(left - right)
minV = value if value < minV else minV
return minV | true |
937172f717d4e5da0785beeacaa0b2e5012800f1 | Python | orestis/pyobjc | /pyobjc/pyobjc-framework-DictionaryServices/PyObjCTest/test_dictionaryservices.py | UTF-8 | 746 | 2.828125 | 3 | [
"MIT"
] | permissive | '''
Some simple tests to check that the framework is properly wrapped.
'''
import objc
from PyObjCTools.TestSupport import *
from DictionaryServices import *
class TestDictionaryServices (TestCase):
def testClasses(self):
self.failUnless( issubclass(DCSDictionaryRef, objc.lookUpClass('NSCFType')) )
... | true |
2cf71c7a1fbc2be3d90c346c9e0e62e13c8c35ef | Python | phg98/SnakeGame | /test_apple.py | UTF-8 | 1,199 | 3.125 | 3 | [] | no_license | from unittest import TestCase
from apple import Apple
import pygame
from pygame.locals import *
class TestApple(TestCase):
def test_apple(self):
# create test apple
SCREEN_WIDTH = 480
SCREEN_HEIGHT = 320
screen_size = (SCREEN_WIDTH, SCREEN_HEIGHT)
TILE_SIZE_X = 10
... | true |
4627727fc7f604582ab21d861e4d2637e0895988 | Python | kobiturgeman/ReconDetect | /ClientSide/PacketCounting.py | UTF-8 | 6,280 | 2.609375 | 3 | [] | no_license | from collections import deque
class PacketCounting:
def __init__(self):
self.TenSeconds = 0
self.table = deque()
def addPacket(self, packet,conn):
if not (packet['dstPort'] == 1433 or packet['srcPort'] == 1433):
packets = {
'TimePeriod': 0,
... | true |
ac03367eb16823c818ee81a398bd55c9fd137f0f | Python | PiotrDabkowski/ask.fm | /HideFox.py | UTF-8 | 2,376 | 2.890625 | 3 | [] | no_license | import subprocess
try:
import win32gui
HideFox = False
except:
class dummy:
def __init__(self, *args):
pass
def __getattr__(self, a):
def f(*a):
return []
return f
HideFox = dummy
if not HideFox:
class HideFox:
... | true |
d84b8a797900273bfc0cde0b552945658e543fd0 | Python | hyeokjinson/algorithm | /ps프로젝트/BF/알파벳.py | UTF-8 | 626 | 2.671875 | 3 | [] | no_license | import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
def dfs(x,y,cnt):
global res
for i in range(4):
nx=x+dx[i]
ny=y+dy[i]
if 0<=nx<r and 0<=ny<c:
if ch[ord(arr[nx][ny])-65]==0:
ch[ord(arr[nx][ny])-65]=1
dfs(nx,ny,cnt+1)
... | true |
eccfeb5db1b7e0fa2dce40490ea3cc483efb77bb | Python | preetmishra/competitive-programming | /codechef/long/jan19/HP18.py | UTF-8 | 470 | 2.984375 | 3 | [] | no_license | t = int(input())
for _ in range(t) :
x = input().split()
x = [int(i) for i in x]
x, y, z = x
l = input().split()
l = [int(i) for i in l]
both = bob = alice = 0
for i in l :
if i % y == 0 and i % z == 0 :
both += 1
elif i % y == 0 :
bob += 1
eli... | true |