boapps commited on
Commit
225784b
·
verified ·
1 Parent(s): b412b1d

Upload 2 files

Browse files
Files changed (2) hide show
  1. kvizek.jsonl +0 -0
  2. kvizparse.ipynb +8 -17
kvizek.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
kvizparse.ipynb CHANGED
@@ -20,7 +20,7 @@
20
  "outputs": [],
21
  "source": [
22
  "def parse_question(match, pagetitle, url):\n",
23
- " question = match.group('question').replace('<br> ', '')\n",
24
  " params = [p for p in match.group('info').strip('{}').split('|') if p != '']\n",
25
  " if params[0] not in ['Kvízkérdés', 'kvízkérdés']:\n",
26
  " print(params[0])\n",
@@ -34,7 +34,7 @@
34
  " filepart = filepart.strip('[]')\n",
35
  " type = {'egy': 'single', 'több': 'multi'}[params_dict['típus']]\n",
36
  " answer = params_dict['válasz']\n",
37
- " if '-' in answer:\n",
38
  " return None\n",
39
  " score = None\n",
40
  " if 'pont' in params_dict:\n",
@@ -42,6 +42,7 @@
42
  " if 'pontozás' in params_dict:\n",
43
  " score = params_dict['pontozás']\n",
44
  " answers = [a.strip('# ') for a in match.group('answers').split('\\n') if a.strip('# ') != '']\n",
 
45
  " return {\n",
46
  " 'title': title,\n",
47
  " 'question': question, \n",
@@ -62,7 +63,7 @@
62
  "metadata": {},
63
  "outputs": [],
64
  "source": [
65
- "regex = r\"==(?P<title>.+)==$\\n*(?P<question>(?:.*\\n)+?)\\n*{{(?P<info>Kvízkérdés|.+)}}\\n*(?P<answers>(?:#.+\\n?)+)\\n*(?P<footnote>.+\\n)*?(?=\\n*==)\""
66
  ]
67
  },
68
  {
@@ -96,17 +97,7 @@
96
  {
97
  "data": {
98
  "text/plain": [
99
- "{'title': 'A canalis femoralis',\n",
100
- " 'question': '{{Kvízkérdés|típus=egy|válasz=1}}\\n# kijárata nem vezet a combizmok alá\\n# a lágyékszalag alatt található\\n\\n== A rectus abdominis (egyenes hasizom) kötőszövetes hüvelyének ... ==\\n',\n",
101
- " 'answers': ['elülső falát alkothatja a külső ferde hasizom aponeurosisa',\n",
102
- " 'hátsó falát alkothatja a haránt (transversus) hasizom inas lemeze',\n",
103
- " 'mindkettő együtt'],\n",
104
- " 'correct_answers': [3],\n",
105
- " 'type': 'single',\n",
106
- " 'score': None,\n",
107
- " 'quiz_title': 'Törzsizmok,_medence',\n",
108
- " 'url': 'https://wiki.kszk.io/Funkcion%C3%A1lis_anat%C3%B3mia/T%C3%B6rzsizmok,_medence/',\n",
109
- " 'file': None}"
110
  ]
111
  },
112
  "execution_count": 5,
@@ -115,7 +106,7 @@
115
  }
116
  ],
117
  "source": [
118
- "data[0]"
119
  ]
120
  },
121
  {
@@ -129,7 +120,7 @@
129
  {
130
  "data": {
131
  "text/plain": [
132
- "71"
133
  ]
134
  },
135
  "execution_count": 6,
@@ -150,7 +141,7 @@
150
  {
151
  "data": {
152
  "text/plain": [
153
- "4289"
154
  ]
155
  },
156
  "execution_count": 7,
 
20
  "outputs": [],
21
  "source": [
22
  "def parse_question(match, pagetitle, url):\n",
23
+ " question = match.group('question').replace('<br> ', '').strip()\n",
24
  " params = [p for p in match.group('info').strip('{}').split('|') if p != '']\n",
25
  " if params[0] not in ['Kvízkérdés', 'kvízkérdés']:\n",
26
  " print(params[0])\n",
 
34
  " filepart = filepart.strip('[]')\n",
35
  " type = {'egy': 'single', 'több': 'multi'}[params_dict['típus']]\n",
36
  " answer = params_dict['válasz']\n",
37
+ " if '-' in answer or '/' in answer:\n",
38
  " return None\n",
39
  " score = None\n",
40
  " if 'pont' in params_dict:\n",
 
42
  " if 'pontozás' in params_dict:\n",
43
  " score = params_dict['pontozás']\n",
44
  " answers = [a.strip('# ') for a in match.group('answers').split('\\n') if a.strip('# ') != '']\n",
45
+ " #print(answer)\n",
46
  " return {\n",
47
  " 'title': title,\n",
48
  " 'question': question, \n",
 
63
  "metadata": {},
64
  "outputs": [],
65
  "source": [
66
+ "regex = r\"==(?P<title>.+)==$\\n*(?P<question>(?:[^\\=]*\\n)*?)\\n*{{(?P<info>Kvízkérdés|.+)}}\\n*(?P<answers>(?:#.+\\n?)+)\\n*(?P<footnote>.+\\n)*?(?=\\n*==)\""
67
  ]
68
  },
69
  {
 
97
  {
98
  "data": {
99
  "text/plain": [
100
+ "132"
 
 
 
 
 
 
 
 
 
 
101
  ]
102
  },
103
  "execution_count": 5,
 
106
  }
107
  ],
108
  "source": [
109
+ "len([d for d in data if d['question']])"
110
  ]
111
  },
112
  {
 
120
  {
121
  "data": {
122
  "text/plain": [
123
+ "46"
124
  ]
125
  },
126
  "execution_count": 6,
 
141
  {
142
  "data": {
143
  "text/plain": [
144
+ "8225"
145
  ]
146
  },
147
  "execution_count": 7,