lhaausing commited on
Commit
5b45bec
·
verified ·
1 Parent(s): ebdb4ae

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. 2453.jsonl +0 -0
  2. 246.jsonl +0 -0
  3. 2461.jsonl +0 -0
  4. 2465.jsonl +0 -0
  5. 2466.jsonl +0 -0
  6. 2467.jsonl +0 -0
  7. 2469.jsonl +0 -0
  8. 2471.jsonl +0 -0
  9. 2475.jsonl +0 -0
  10. 2481.jsonl +8 -0
  11. 2483.jsonl +0 -0
  12. 2489.jsonl +0 -0
  13. 2492.jsonl +0 -0
  14. 2495.jsonl +0 -0
  15. 2496.jsonl +0 -0
  16. 2497.jsonl +0 -0
  17. 2498.jsonl +0 -0
  18. 250.jsonl +0 -0
  19. 2501.jsonl +0 -0
  20. 2506.jsonl +0 -0
2453.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
246.jsonl ADDED
File without changes
2461.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2465.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2466.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2467.jsonl ADDED
File without changes
2469.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2471.jsonl ADDED
File without changes
2475.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2481.jsonl ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {"seq_id":"249732487","text":"def main():\n size=int(input())\n nums=[]\n for i in range(0,size):\n num=int(input())\n nums.append(num)\n print(second_max(nums))\n\ndef second_max(nums):\n first=-1000000\n second=-1000000\n nums=sorting(nums)\n for i in range(0,len(nums)):\n if first<nums[i]:\n second=first\n first=nums[i]\n return second\n\ndef sorting(nums):\n for i in range(0,len(nums)-1):\n for i in range(0,len(nums)-1):\n if nums[i]>nums[i+1]:\n vari=nums[i]\n nums[i]=nums[i+1]\n nums[i+1]=vari\n return nums\nmain()\n","sub_path":"PythonLab7/hakerrank/pr9.py","file_name":"pr9.py","file_ext":"py","file_size_in_byte":610,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
2
+ {"seq_id":"513448211","text":"from typing_extensions import Concatenate\nimport pandas as pd\nimport string\nimport re\nimport pymongo\nimport sklearn as sklearn\nfrom mongoengine import connect\nfrom sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.model_selection import train_test_split\nimport pickle\n\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.svm import SVC\n\n\n\ndef ExtractDataFromDb():\n try:\n # --- Connection to Mongodb --- #\n mongo = pymongo.MongoClient(\n host=\"localhost\",\n port=27017,\n serverSelectionTimeoutMS=1000,\n )\n db = mongo.News\n\n # --- Connection to our database --- #\n connect('News', host='mongodb://localhost', alias='default')\n #fetch data\n cursor=db['app_news'].find()\n ids=[]\n classes=[]\n concat=[]\n #loop documents\n for doc in cursor:\n ids.append(doc['_id'])\n classes.append(doc['classe'])\n concat.append(doc['title']+''+doc['content'])\n \n content_toJson={}\n for i,cid in enumerate(ids):\n content_toJson[cid]=concat[i]\n \n return {'content':content_toJson,'classe':classes}\n\n except Exception as ex:\n print(ex)\n\n# --- Put the list of content and title from a list of text into a string format --- #\ndef ConverttoString(listOfText):\n string_text = ''.join(listOfText)\n return string_text\n\n# --- put the collected data into a pandas DataFrame --- #\ndef putDataInDataFrame(string_text):\n data_df = pd.DataFrame.from_dict(string_text).transpose()\n data_df.columns = ['content']\n data_df = data_df.sort_index()\n return data_df\n\n# --- Function to clean the data --- #\ndef cleanData(text):\n text = re.sub('\\[.*?\\]', '', text) \n text = re.sub('\\(.*?\\)', '', text) \n text = re.sub('\\w*\\d\\w*', '', text) \n text = re.sub('\\n', '', text) \n text = re.sub(r\"[A-Za-z\\.]*[0-9]+[A-Za-z%°\\.]*\", \"\", text)\n text = re.sub(r\"(\\s\\-\\s|-$)\", \"\", text)\n text = re.sub(r\"[,\\!\\?\\%\\(\\)\\/\\\"]\", \"\", text)\n text = re.sub(r\"\\&\\S*\\s\", \"\", text)\n text = re.sub(r\"\\&\", \"\", text)\n text = re.sub(r\"\\+\", \"\", text)\n text = re.sub(r\"\\#\", \"\", text)\n text = re.sub(r\"\\$\", \"\", text)\n text = re.sub(r\"\\£\", \"\", text)\n text = re.sub(r\"\\%\", \"\", text)\n text = re.sub(r\"\\:\", \"\", text)\n text = re.sub(r\"\\@\", \"\", text)\n text = re.sub(r\"\\-\", \"\", text)\n return text\n\ndef organizeData(data_df,classes,cleaned_data):\n # --- Adding class column to dataframe --- #\n data_df['classe'] = classes\n return data_df","sub_path":"preprocessing.py","file_name":"preprocessing.py","file_ext":"py","file_size_in_byte":2631,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
3
+ {"seq_id":"597102633","text":"#!/usr/bin/env python\n\nimport unittest\nimport sys\nimport os.path\nimport itertools\nfrom copy import copy\nimport types\n\nsys.path.append(os.path.dirname(__file__) + \"/../../..\")\n\nfrom sts.replay_event import *\nfrom sts.event_dag import *\n\nclass MockEvent(InputEvent):\n def proceed(self, simulation):\n pass\n\nclass MockInternalEvent(InternalEvent):\n def __init__(self, fingerprint, label=None):\n InternalEvent.__init__(self, label)\n self.fingerprint = fingerprint\n\n def proceed(self, simulation):\n pass\n\nclass MockInputEvent(InputEvent):\n def proceed(self, simulation):\n pass\n\nclass event_dag_test(unittest.TestCase):\n def test_split_basic(self):\n events = [MockEvent(), MockEvent(), MockEvent(), MockEvent()]\n dag = EventDag(events)\n splits = split_list(dag.input_events, 2)\n self.assertEqual(2, len(splits))\n self.assertEqual(2, len(splits[0]))\n self.assertEqual(2, len(splits[1]))\n splits = split_list(dag.input_events, 4)\n self.assertEqual(4, len(splits))\n self.assertEqual(1, len(splits[0]))\n self.assertEqual(1, len(splits[1]))\n self.assertEqual(1, len(splits[2]))\n self.assertEqual(1, len(splits[3]))\n splits = split_list(dag.input_events, 3)\n self.assertEqual(3, len(splits))\n self.assertEqual(4, len(splits[0]) + len(splits[1]) + len(splits[2]))\n\n def test_split_single(self):\n events = [MockEvent()]\n dag = EventDag(events)\n splits = split_list(dag.input_events, 1)\n self.assertEqual(1, len(splits))\n self.assertEqual(1, len(splits[0]))\n\n def test_split_zero(self):\n events = []\n dag = EventDag(events)\n splits = split_list(dag.input_events, 1)\n self.assertEqual(1, len(splits))\n self.assertEqual(0, len(splits[0]))\n\n def test_split_odd(self):\n events = [MockEvent(), MockEvent(), MockEvent()]\n dag = EventDag(events)\n splits = split_list(dag.input_events, 2)\n self.assertEqual(2, len(splits))\n self.assertEqual(3, len(splits[0]) + len(splits[1]))\n splits = split_list(dag.input_events, 3)\n self.assertEqual(3, len(splits))\n self.assertEqual(3, len(splits[0]) + len(splits[1]) + len(splits[2]))\n\n def test_event_dag(self):\n event_dag = EventDag( [ MockInternalEvent(\"a\"), MockInputEvent() ])\n self.assertEqual(2, len(event_dag))\n self.assertEqual(2, len(event_dag.filter_unsupported_input_types()))\n event_dag.mark_invalid_input_sequences()\n self.assertEqual(2, len(event_dag))\n\n def test_event_dag_subset(self):\n mockInputEvent = MockInputEvent()\n mockInputEvent2 = MockInputEvent()\n events = [ MockInternalEvent('a'), mockInputEvent, mockInputEvent2 ]\n event_dag = EventDag(events)\n # subset of (full set) is a noop\n self.assertEqual( event_dag.events, event_dag.input_subset(events).events)\n # subset of () empty retains the internal event\n self.assertEqual( event_dag.events[0:1], event_dag.input_subset([]).events)\n\n sub_graph = event_dag.input_subset([mockInputEvent])\n self.assertEqual( event_dag.events[0:2], sub_graph.events)\n\n def test_event_dag_complement(self):\n mockInputEvent = MockInputEvent()\n mockInputEvent2 = MockInputEvent()\n events = [ MockInternalEvent('a'), mockInputEvent, mockInputEvent2 ]\n event_dag = EventDag(events)\n # complement of (nothing) is full set\n self.assertEqual( event_dag.events, event_dag.input_complement([]).events)\n # complement of (all elements) retains only the internal event\n self.assertEqual( event_dag.events[0:1], event_dag.input_complement(events).events)\n\n sub_graph = event_dag.input_complement([mockInputEvent])\n self.assertEqual( [ e for (i, e) in enumerate(event_dag.events) if i==0 or i==2 ], sub_graph.events)\n\n def test_migration_simple(self):\n events = [ MockInternalEvent('a'), HostMigration(1,1,2,2),\n MockInternalEvent('b'), HostMigration(2,2,3,3),\n MockInputEvent() ]\n # Don't prune anything\n event_dag = EventDag(events)\n new_dag = event_dag.input_subset(events)\n self.assertEqual(events, new_dag.events)\n\n def test_migration_prune_1(self):\n events = [ MockInternalEvent('a'), HostMigration(1,1,2,2),\n MockInternalEvent('b'), HostMigration(2,2,3,3),\n MockInputEvent() ]\n # Prune the first migration\n subset = [events[1]]\n event_dag = EventDag(events)\n new_dag = event_dag.input_complement(subset)\n fingerprint = ('HostMigration',1,1,3,3)\n self.assertEqual(fingerprint, new_dag.events[2].fingerprint)\n\n def test_migration_prune_2(self):\n events = [ MockInternalEvent('a'), HostMigration(1,1,2,2),\n MockInternalEvent('b'), HostMigration(2,2,3,3),\n MockInputEvent(), HostMigration(3,3,4,4),\n HostMigration(4,4,5,5) ]\n # Prune the seconds and third migration\n subset = [events[3], events[4], events[5]]\n event_dag = EventDag(events)\n new_dag = event_dag.input_complement(subset)\n fingerprint = ('HostMigration',2,2,5,5)\n self.assertEqual(fingerprint, new_dag.events[3].fingerprint)\n\n def test_migration_prune_last(self):\n events = [ MockInternalEvent('a'), HostMigration(1,1,2,2),\n MockInternalEvent('b'), HostMigration(2,2,3,3),\n MockInputEvent() ]\n # Prune the last migration\n subset = [events[3]]\n event_dag = EventDag(events)\n new_dag = event_dag.input_complement(subset)\n fingerprint = ('HostMigration',1,1,2,2)\n self.assertEqual(fingerprint, new_dag.events[1].fingerprint)\n\n\nif __name__ == '__main__':\n unittest.main()\n","sub_path":"tests/unit/sts/event_dag_test.py","file_name":"event_dag_test.py","file_ext":"py","file_size_in_byte":5502,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
4
+ {"seq_id":"247097191","text":"#!/usr/bin/env python\n# encoding: utf-8\n# @author: liusir\n# @file: demo_05.py\n# @time: 2020/9/20 11:16 上午\n\n\nimport json\nimport requests\n\n# requests 模拟发送post请求\nurl_param_dict = {\n \"access_token\":'37_Ek4AQ3pIzrUYfXzoUD3bpPBm5mXo4eyncOcgDvk2KJ3gnia4hr_iwUDhpbPFb09Jjuzh5J4XgCXfgzy_nWxyT3wBoENIinh-X6l26hmnvur-s7BXqhi5Jsu5oclaGzi9XQpnZZz340ODbGbRAUMgAIAMGY'\n}\npost_param_data = { \"tag\" : { \"name\" : \"hunanP3P4\" } }\n\nresponse = requests.post(url='https://api.weixin.qq.com/cgi-bin/tags/create',\n params=url_param_dict,\n # json=post_param_data\n data = json.dumps( post_param_data )\n )\nprint( response.content.decode('utf-8') )","sub_path":"courest_pritices/20200920/demo_05.py","file_name":"demo_05.py","file_ext":"py","file_size_in_byte":737,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
5
+ {"seq_id":"403361662","text":"import random\n\ndef guess_attemps(word_len):\n return word_len % 2 + int(word_len / 2)\n\nwith open('dict_of_words.txt', mode='r') as f:\n list_probls = [(word, guess_attemps(len(word))) for word in f.read().split('\\n')]\n\nscore = tries = 0\n# random choose a word then scrample the word then \nword, guess_limit = random.choice(list_probls)\nrandom_hint_index = random.choice(range(len(word)))\nhidden_letters = ['_'] * len(word)\n# For every word (CTRL+C to exit)\nwhile True:\n try:\n \n \n hidden_letters[random_hint_index] = word[random_hint_index]\n # print \"_\" according to word's length and the first hinted letter \n \n print(f\"{' '.join(hidden_letters)} tries = {tries} chances = {guess_limit} score = {score}\")\n # Ask user to guess \n guess = input(\"(What is your guess?): \")\n\n # if correct then print and go to the next word\n if guess == word:\n print(f'[+] Congrats, secret word is {word}')\n score += 1\n tries = 0\n word, guess_limit = random.choice(list_probls)\n hidden_letters = ['_'] * len(word)\n else:\n if tries < guess_limit:\n # if still not out then +1 to tries \n tries += 1\n random_hint_index = random.choice(list(filter(lambda x: x != random_hint_index, \\\n range(len(word)))))\n else:\n # out of tries then \"failed\" and go to the next word \n print(f\"[+] Failed, secret word is {word}\")\n word, guess_limit = random.choice(list_probls)\n tries = 0\n hidden_letters = ['_'] * len(word)\n except KeyboardInterrupt:\n print(\"EXITED\")\n break\n","sub_path":"anagram.py","file_name":"anagram.py","file_ext":"py","file_size_in_byte":1632,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
6
+ {"seq_id":"419964229","text":"\ndef flat(lists):\n return [item for sublist in lists for item in sublist]\n\n\nlist_treta = [\n [{'a': [1, 2, 3, 4, 5], 'b': {'c': 'just a string'}}],\n [{'a': [5, 6, 7, 5], 'b': {'c': 'a string'}}],\n [{'a': [11, 12, 13, 15], 'b': {'c': 'just '}}],\n]\n\njust_the_as = list(map(lambda x: x['a'], flat(list_treta)))\n\nall_nums = flat(just_the_as)\nsuma = 0\nfor num in all_nums:\n suma += num\naverage = suma/len(all_nums)\n\nprint(list_treta)\nprint(average)\n","sub_path":"src/playground/playground.py","file_name":"playground.py","file_ext":"py","file_size_in_byte":458,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
7
+ {"seq_id":"641538140","text":"import pygame\nimport sys\n\npygame.init()\nwindow = pygame.display.set_mode( ( 640, 480 ) ) \n\nimgBunny = pygame.image.load( \"bunny.png\" )\nimgZombie = pygame.image.load( \"zombie.png\" )\n\nx = 320\ny = 240\nbunnySpeed = 5\n\nzombieX = [ 0, 64, 360 ]\nzombieY = [ 0, 64, 360 ]\nzombieSpeed = 1\n\nfpsClock = pygame.time.Clock()\n\nwhile True:\n\tfor event in pygame.event.get():\n\t\tif event.type == pygame.QUIT:\n\t\t\tpygame.quit()\n\t\t\tsys.exit()\n\t# for loop\n\t\n\tkeys = pygame.key.get_pressed()\n\t\n\t# If statements - handling key presses\n\tif ( keys[ pygame.K_LEFT ] ):\n\t\tx -= bunnySpeed\n\telif ( keys[ pygame.K_RIGHT ] ):\n\t\tx += bunnySpeed\n\tif ( keys[ pygame.K_UP ] ):\n\t\ty -= bunnySpeed\n\telif ( keys[ pygame.K_DOWN ] ):\n\t\ty += bunnySpeed\n\t\t\n\t# If statements - keeping the player from going off the screen\n\tif ( x < 0 ):\n\t\tx = 0\n\telif ( x > 640 - 48 ):\n\t\tx = 640 - 48\n\t\n\tif ( y < 0 ):\n\t\ty = 0\n\telif ( y > 480 - 48 ):\n\t\ty = 480 - 48\n\t\t\n\t# For loop - Update each zombie\n\tfor i in range( 0, 3 ):\n\t\tif ( zombieX[i] < x ):\n\t\t\tzombieX[i] += zombieSpeed\n\t\telif ( zombieX[i] > x ):\n\t\t\tzombieX[i] -= zombieSpeed\n\t\t\t\n\t\tif ( zombieY[i] < y ):\n\t\t\tzombieY[i] += zombieSpeed\n\t\telif ( zombieY[i] > y ):\n\t\t\tzombieY[i] -= zombieSpeed\n\t\n\twindow.fill( pygame.Color( 255, 255, 255 ) )\n\twindow.blit( imgBunny, ( x, y ) )\n\t\n\tfor i in range( 0, 3 ):\n\t\twindow.blit( imgZombie, ( zombieX[i], zombieY[i] ) )\n\t\n\tpygame.display.update()\n\tfpsClock.tick( 60 )\n# end loop\n","sub_path":"Programming-I-Python-and-Pygame-Prototype/4 Lists and For Loops/main.py","file_name":"main.py","file_ext":"py","file_size_in_byte":1412,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
8
+ {"seq_id":"597947908","text":"# pylint: disable=unused-argument,invalid-name,line-too-long\n\nfrom typing import List\n\nfrom parse import parse\nfrom sqlalchemy import text as sql_text\n\nfrom alembic_utils.exceptions import SQLParseFailure\nfrom alembic_utils.replaceable_entity import ReplaceableEntity\n\n\nclass PGView(ReplaceableEntity):\n \"\"\"A PostgreSQL View compatible with `alembic revision --autogenerate`\n\n **Parameters:**\n\n * **schema** - *str*: A SQL schema name\n * **signature** - *str*: A SQL view's call signature\n * **definition** - *str*: The SQL select statement body of the view\n \"\"\"\n\n @classmethod\n def from_sql(cls, sql: str) -> \"PGView\":\n \"\"\"Create an instance from a SQL string\"\"\"\n template = \"create{}view{:s}{schema}.{signature}{:s}as{:s}{definition}\"\n result = parse(template, sql, case_sensitive=False)\n if result is not None:\n # If the signature includes column e.g. my_view (col1, col2, col3) remove them\n signature = result[\"signature\"].split(\"(\")[0]\n return cls(\n schema=result[\"schema\"],\n # strip quote characters\n signature=signature.replace('\"', \"\"),\n definition=result[\"definition\"],\n )\n\n raise SQLParseFailure(f'Failed to parse SQL into PGView \"\"\"{sql}\"\"\"')\n\n def to_sql_statement_create(self) -> str:\n \"\"\"Generates a SQL \"create view\" statement\"\"\"\n return sql_text(\n f'CREATE VIEW {self.literal_schema}.\"{self.signature}\" AS {self.definition}'\n )\n\n def to_sql_statement_drop(self) -> str:\n \"\"\"Generates a SQL \"drop view\" statement\"\"\"\n return sql_text(f'DROP VIEW {self.literal_schema}.\"{self.signature}\"')\n\n def to_sql_statement_create_or_replace(self) -> str:\n \"\"\"Generates a SQL \"create or replace view\" statement\"\"\"\n return sql_text(\n f'CREATE OR REPLACE VIEW {self.literal_schema}.\"{self.signature}\" AS {self.definition}'\n )\n\n @classmethod\n def from_database(cls, connection, schema) -> List[\"PGView\"]:\n \"\"\"Get a list of all functions defined in the db\"\"\"\n sql = sql_text(\n f\"\"\"\n select\n schemaname schema_name,\n viewname view_name,\n definition\n from\n pg_views\n where\n schemaname not in ('pg_catalog', 'information_schema')\n and schemaname::text = '{schema}';\n \"\"\"\n )\n rows = connection.execute(sql).fetchall()\n db_views = [PGView(x[0], x[1], x[2]) for x in rows]\n\n for view in db_views:\n assert view is not None\n\n return db_views\n\n def get_compare_identity_query(self) -> str:\n \"\"\"Return SQL string that returns 1 row for existing DB object\"\"\"\n return f\"\"\"\n select\n -- Schema is appended in python\n viewname view_name\n from\n pg_views\n where\n schemaname::text = '{self.schema}';\n \"\"\"\n\n def get_compare_definition_query(self) -> str:\n \"\"\"Return SQL string that returns 1 row for existing DB object\"\"\"\n return f\"\"\"\n select\n -- Schema is appended in python\n viewname view_name,\n definition\n from\n\t pg_views\n\twhere\n schemaname::text = '{self.schema}';\n \"\"\"\n","sub_path":"src/alembic_utils/pg_view.py","file_name":"pg_view.py","file_ext":"py","file_size_in_byte":3349,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"90"}
2483.jsonl ADDED
File without changes
2489.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2492.jsonl ADDED
File without changes
2495.jsonl ADDED
File without changes
2496.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2497.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
2498.jsonl ADDED
File without changes
250.jsonl ADDED
File without changes
2501.jsonl ADDED
File without changes
2506.jsonl ADDED
The diff for this file is too large to render. See raw diff