m3hrdadfi commited on
Commit
14b4bdd
1 Parent(s): d0e818e
Files changed (9) hide show
  1. .gitignore +886 -0
  2. README.md +8 -24
  3. app.py +160 -0
  4. assets/style.css +22 -0
  5. examples.json +202 -0
  6. meta.py +9 -0
  7. normalizer.py +4 -0
  8. requirements.txt +4 -0
  9. utils.py +35 -0
.gitignore ADDED
@@ -0,0 +1,886 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### VirtualEnv template
2
+ # Virtualenv
3
+ # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
4
+ .Python
5
+ [Bb]in
6
+ [Ii]nclude
7
+ [Ll]ib
8
+ [Ll]ib64
9
+ [Ll]ocal
10
+ [Ss]cripts
11
+ pyvenv.cfg
12
+ .venv
13
+ pip-selfcheck.json
14
+
15
+ ### VisualStudio template
16
+ ## Ignore Visual Studio temporary files, build results, and
17
+ ## files generated by popular Visual Studio add-ons.
18
+ ##
19
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
20
+
21
+ # User-specific files
22
+ *.rsuser
23
+ *.suo
24
+ *.user
25
+ *.userosscache
26
+ *.sln.docstates
27
+
28
+ # User-specific files (MonoDevelop/Xamarin Studio)
29
+ *.userprefs
30
+
31
+ # Mono auto generated files
32
+ mono_crash.*
33
+
34
+ # Build results
35
+ [Dd]ebug/
36
+ [Dd]ebugPublic/
37
+ [Rr]elease/
38
+ [Rr]eleases/
39
+ x64/
40
+ x86/
41
+ [Ww][Ii][Nn]32/
42
+ [Aa][Rr][Mm]/
43
+ [Aa][Rr][Mm]64/
44
+ bld/
45
+ [Bb]in/
46
+ [Oo]bj/
47
+ [Ll]og/
48
+ [Ll]ogs/
49
+
50
+ # Visual Studio 2015/2017 cache/options directory
51
+ .vs/
52
+ # Uncomment if you have tasks that create the project's static files in wwwroot
53
+ #wwwroot/
54
+
55
+ # Visual Studio 2017 auto generated files
56
+ Generated\ Files/
57
+
58
+ # MSTest test Results
59
+ [Tt]est[Rr]esult*/
60
+ [Bb]uild[Ll]og.*
61
+
62
+ # NUnit
63
+ *.VisualState.xml
64
+ TestResult.xml
65
+ nunit-*.xml
66
+
67
+ # Build Results of an ATL Project
68
+ [Dd]ebugPS/
69
+ [Rr]eleasePS/
70
+ dlldata.c
71
+
72
+ # Benchmark Results
73
+ BenchmarkDotNet.Artifacts/
74
+
75
+ # .NET Core
76
+ project.lock.json
77
+ project.fragment.lock.json
78
+ artifacts/
79
+
80
+ # ASP.NET Scaffolding
81
+ ScaffoldingReadMe.txt
82
+
83
+ # StyleCop
84
+ StyleCopReport.xml
85
+
86
+ # Files built by Visual Studio
87
+ *_i.c
88
+ *_p.c
89
+ *_h.h
90
+ *.ilk
91
+ *.meta
92
+ *.obj
93
+ *.iobj
94
+ *.pch
95
+ *.pdb
96
+ *.ipdb
97
+ *.pgc
98
+ *.pgd
99
+ *.rsp
100
+ *.sbr
101
+ *.tlb
102
+ *.tli
103
+ *.tlh
104
+ *.tmp
105
+ *.tmp_proj
106
+ *_wpftmp.csproj
107
+ *.log
108
+ *.vspscc
109
+ *.vssscc
110
+ .builds
111
+ *.pidb
112
+ *.svclog
113
+ *.scc
114
+
115
+ # Chutzpah Test files
116
+ _Chutzpah*
117
+
118
+ # Visual C++ cache files
119
+ ipch/
120
+ *.aps
121
+ *.ncb
122
+ *.opendb
123
+ *.opensdf
124
+ *.sdf
125
+ *.cachefile
126
+ *.VC.db
127
+ *.VC.VC.opendb
128
+
129
+ # Visual Studio profiler
130
+ *.psess
131
+ *.vsp
132
+ *.vspx
133
+ *.sap
134
+
135
+ # Visual Studio Trace Files
136
+ *.e2e
137
+
138
+ # TFS 2012 Local Workspace
139
+ $tf/
140
+
141
+ # Guidance Automation Toolkit
142
+ *.gpState
143
+
144
+ # ReSharper is a .NET coding add-in
145
+ _ReSharper*/
146
+ *.[Rr]e[Ss]harper
147
+ *.DotSettings.user
148
+
149
+ # TeamCity is a build add-in
150
+ _TeamCity*
151
+
152
+ # DotCover is a Code Coverage Tool
153
+ *.dotCover
154
+
155
+ # AxoCover is a Code Coverage Tool
156
+ .axoCover/*
157
+ !.axoCover/settings.json
158
+
159
+ # Coverlet is a free, cross platform Code Coverage Tool
160
+ coverage*.json
161
+ coverage*.xml
162
+ coverage*.info
163
+
164
+ # Visual Studio code coverage results
165
+ *.coverage
166
+ *.coveragexml
167
+
168
+ # NCrunch
169
+ _NCrunch_*
170
+ .*crunch*.local.xml
171
+ nCrunchTemp_*
172
+
173
+ # MightyMoose
174
+ *.mm.*
175
+ AutoTest.Net/
176
+
177
+ # Web workbench (sass)
178
+ .sass-cache/
179
+
180
+ # Installshield output folder
181
+ [Ee]xpress/
182
+
183
+ # DocProject is a documentation generator add-in
184
+ DocProject/buildhelp/
185
+ DocProject/Help/*.HxT
186
+ DocProject/Help/*.HxC
187
+ DocProject/Help/*.hhc
188
+ DocProject/Help/*.hhk
189
+ DocProject/Help/*.hhp
190
+ DocProject/Help/Html2
191
+ DocProject/Help/html
192
+
193
+ # Click-Once directory
194
+ publish/
195
+
196
+ # Publish Web Output
197
+ *.[Pp]ublish.xml
198
+ *.azurePubxml
199
+ # Note: Comment the next line if you want to checkin your web deploy settings,
200
+ # but database connection strings (with potential passwords) will be unencrypted
201
+ *.pubxml
202
+ *.publishproj
203
+
204
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
205
+ # checkin your Azure Web App publish settings, but sensitive information contained
206
+ # in these scripts will be unencrypted
207
+ PublishScripts/
208
+
209
+ # NuGet Packages
210
+ *.nupkg
211
+ # NuGet Symbol Packages
212
+ *.snupkg
213
+ # The packages folder can be ignored because of Package Restore
214
+ **/[Pp]ackages/*
215
+ # except build/, which is used as an MSBuild target.
216
+ !**/[Pp]ackages/build/
217
+ # Uncomment if necessary however generally it will be regenerated when needed
218
+ #!**/[Pp]ackages/repositories.config
219
+ # NuGet v3's project.json files produces more ignorable files
220
+ *.nuget.props
221
+ *.nuget.targets
222
+
223
+ # Microsoft Azure Build Output
224
+ csx/
225
+ *.build.csdef
226
+
227
+ # Microsoft Azure Emulator
228
+ ecf/
229
+ rcf/
230
+
231
+ # Windows Store app package directories and files
232
+ AppPackages/
233
+ BundleArtifacts/
234
+ Package.StoreAssociation.xml
235
+ _pkginfo.txt
236
+ *.appx
237
+ *.appxbundle
238
+ *.appxupload
239
+
240
+ # Visual Studio cache files
241
+ # files ending in .cache can be ignored
242
+ *.[Cc]ache
243
+ # but keep track of directories ending in .cache
244
+ !?*.[Cc]ache/
245
+
246
+ # Others
247
+ ClientBin/
248
+ ~$*
249
+ *~
250
+ *.dbmdl
251
+ *.dbproj.schemaview
252
+ *.jfm
253
+ *.pfx
254
+ *.publishsettings
255
+ orleans.codegen.cs
256
+
257
+ # Including strong name files can present a security risk
258
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
259
+ #*.snk
260
+
261
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
262
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
263
+ #bower_components/
264
+
265
+ # RIA/Silverlight projects
266
+ Generated_Code/
267
+
268
+ # Backup & report files from converting an old project file
269
+ # to a newer Visual Studio version. Backup files are not needed,
270
+ # because we have git ;-)
271
+ _UpgradeReport_Files/
272
+ Backup*/
273
+ UpgradeLog*.XML
274
+ UpgradeLog*.htm
275
+ ServiceFabricBackup/
276
+ *.rptproj.bak
277
+
278
+ # SQL Server files
279
+ *.mdf
280
+ *.ldf
281
+ *.ndf
282
+
283
+ # Business Intelligence projects
284
+ *.rdl.data
285
+ *.bim.layout
286
+ *.bim_*.settings
287
+ *.rptproj.rsuser
288
+ *- [Bb]ackup.rdl
289
+ *- [Bb]ackup ([0-9]).rdl
290
+ *- [Bb]ackup ([0-9][0-9]).rdl
291
+
292
+ # Microsoft Fakes
293
+ FakesAssemblies/
294
+
295
+ # GhostDoc plugin setting file
296
+ *.GhostDoc.xml
297
+
298
+ # Node.js Tools for Visual Studio
299
+ .ntvs_analysis.dat
300
+ node_modules/
301
+
302
+ # Visual Studio 6 build log
303
+ *.plg
304
+
305
+ # Visual Studio 6 workspace options file
306
+ *.opt
307
+
308
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
309
+ *.vbw
310
+
311
+ # Visual Studio LightSwitch build output
312
+ **/*.HTMLClient/GeneratedArtifacts
313
+ **/*.DesktopClient/GeneratedArtifacts
314
+ **/*.DesktopClient/ModelManifest.xml
315
+ **/*.Server/GeneratedArtifacts
316
+ **/*.Server/ModelManifest.xml
317
+ _Pvt_Extensions
318
+
319
+ # Paket dependency manager
320
+ .paket/paket.exe
321
+ paket-files/
322
+
323
+ # FAKE - F# Make
324
+ .fake/
325
+
326
+ # CodeRush personal settings
327
+ .cr/personal
328
+
329
+ # Python Tools for Visual Studio (PTVS)
330
+ __pycache__/
331
+ *.pyc
332
+
333
+ # Cake - Uncomment if you are using it
334
+ # tools/**
335
+ # !tools/packages.config
336
+
337
+ # Tabs Studio
338
+ *.tss
339
+
340
+ # Telerik's JustMock configuration file
341
+ *.jmconfig
342
+
343
+ # BizTalk build output
344
+ *.btp.cs
345
+ *.btm.cs
346
+ *.odx.cs
347
+ *.xsd.cs
348
+
349
+ # OpenCover UI analysis results
350
+ OpenCover/
351
+
352
+ # Azure Stream Analytics local run output
353
+ ASALocalRun/
354
+
355
+ # MSBuild Binary and Structured Log
356
+ *.binlog
357
+
358
+ # NVidia Nsight GPU debugger configuration file
359
+ *.nvuser
360
+
361
+ # MFractors (Xamarin productivity tool) working folder
362
+ .mfractor/
363
+
364
+ # Local History for Visual Studio
365
+ .localhistory/
366
+
367
+ # BeatPulse healthcheck temp database
368
+ healthchecksdb
369
+
370
+ # Backup folder for Package Reference Convert tool in Visual Studio 2017
371
+ MigrationBackup/
372
+
373
+ # Ionide (cross platform F# VS Code tools) working folder
374
+ .ionide/
375
+
376
+ # Fody - auto-generated XML schema
377
+ FodyWeavers.xsd
378
+
379
+ ### TeX template
380
+ ## Core latex/pdflatex auxiliary files:
381
+ *.aux
382
+ *.lof
383
+ *.log
384
+ *.lot
385
+ *.fls
386
+ *.out
387
+ *.toc
388
+ *.fmt
389
+ *.fot
390
+ *.cb
391
+ *.cb2
392
+ .*.lb
393
+
394
+ ## Intermediate documents:
395
+ *.dvi
396
+ *.xdv
397
+ *-converted-to.*
398
+ # these rules might exclude image files for figures etc.
399
+ # *.ps
400
+ # *.eps
401
+ # *.pdf
402
+
403
+ ## Generated if empty string is given at "Please type another file name for output:"
404
+ .pdf
405
+
406
+ ## Bibliography auxiliary files (bibtex/biblatex/biber):
407
+ *.bbl
408
+ *.bcf
409
+ *.blg
410
+ *-blx.aux
411
+ *-blx.bib
412
+ *.run.xml
413
+
414
+ ## Build tool auxiliary files:
415
+ *.fdb_latexmk
416
+ *.synctex
417
+ *.synctex(busy)
418
+ *.synctex.gz
419
+ *.synctex.gz(busy)
420
+ *.pdfsync
421
+
422
+ ## Build tool directories for auxiliary files
423
+ # latexrun
424
+ latex.out/
425
+
426
+ ## Auxiliary and intermediate files from other packages:
427
+ # algorithms
428
+ *.alg
429
+ *.loa
430
+
431
+ # achemso
432
+ acs-*.bib
433
+
434
+ # amsthm
435
+ *.thm
436
+
437
+ # beamer
438
+ *.nav
439
+ *.pre
440
+ *.snm
441
+ *.vrb
442
+
443
+ # changes
444
+ *.soc
445
+
446
+ # comment
447
+ *.cut
448
+
449
+ # cprotect
450
+ *.cpt
451
+
452
+ # elsarticle (documentclass of Elsevier journals)
453
+ *.spl
454
+
455
+ # endnotes
456
+ *.ent
457
+
458
+ # fixme
459
+ *.lox
460
+
461
+ # feynmf/feynmp
462
+ *.mf
463
+ *.mp
464
+ *.t[1-9]
465
+ *.t[1-9][0-9]
466
+ *.tfm
467
+
468
+ #(r)(e)ledmac/(r)(e)ledpar
469
+ *.end
470
+ *.?end
471
+ *.[1-9]
472
+ *.[1-9][0-9]
473
+ *.[1-9][0-9][0-9]
474
+ *.[1-9]R
475
+ *.[1-9][0-9]R
476
+ *.[1-9][0-9][0-9]R
477
+ *.eledsec[1-9]
478
+ *.eledsec[1-9]R
479
+ *.eledsec[1-9][0-9]
480
+ *.eledsec[1-9][0-9]R
481
+ *.eledsec[1-9][0-9][0-9]
482
+ *.eledsec[1-9][0-9][0-9]R
483
+
484
+ # glossaries
485
+ *.acn
486
+ *.acr
487
+ *.glg
488
+ *.glo
489
+ *.gls
490
+ *.glsdefs
491
+ *.lzo
492
+ *.lzs
493
+
494
+ # uncomment this for glossaries-extra (will ignore makeindex's style files!)
495
+ # *.ist
496
+
497
+ # gnuplottex
498
+ *-gnuplottex-*
499
+
500
+ # gregoriotex
501
+ *.gaux
502
+ *.gtex
503
+
504
+ # htlatex
505
+ *.4ct
506
+ *.4tc
507
+ *.idv
508
+ *.lg
509
+ *.trc
510
+ *.xref
511
+
512
+ # hyperref
513
+ *.brf
514
+
515
+ # knitr
516
+ *-concordance.tex
517
+ # TODO Uncomment the next line if you use knitr and want to ignore its generated tikz files
518
+ # *.tikz
519
+ *-tikzDictionary
520
+
521
+ # listings
522
+ *.lol
523
+
524
+ # luatexja-ruby
525
+ *.ltjruby
526
+
527
+ # makeidx
528
+ *.idx
529
+ *.ilg
530
+ *.ind
531
+
532
+ # minitoc
533
+ *.maf
534
+ *.mlf
535
+ *.mlt
536
+ *.mtc[0-9]*
537
+ *.slf[0-9]*
538
+ *.slt[0-9]*
539
+ *.stc[0-9]*
540
+
541
+ # minted
542
+ _minted*
543
+ *.pyg
544
+
545
+ # morewrites
546
+ *.mw
547
+
548
+ # nomencl
549
+ *.nlg
550
+ *.nlo
551
+ *.nls
552
+
553
+ # pax
554
+ *.pax
555
+
556
+ # pdfpcnotes
557
+ *.pdfpc
558
+
559
+ # sagetex
560
+ *.sagetex.sage
561
+ *.sagetex.py
562
+ *.sagetex.scmd
563
+
564
+ # scrwfile
565
+ *.wrt
566
+
567
+ # sympy
568
+ *.sout
569
+ *.sympy
570
+ sympy-plots-for-*.tex/
571
+
572
+ # pdfcomment
573
+ *.upa
574
+ *.upb
575
+
576
+ # pythontex
577
+ *.pytxcode
578
+ pythontex-files-*/
579
+
580
+ # tcolorbox
581
+ *.listing
582
+
583
+ # thmtools
584
+ *.loe
585
+
586
+ # TikZ & PGF
587
+ *.dpth
588
+ *.md5
589
+ *.auxlock
590
+
591
+ # todonotes
592
+ *.tdo
593
+
594
+ # vhistory
595
+ *.hst
596
+ *.ver
597
+
598
+ # easy-todo
599
+ *.lod
600
+
601
+ # xcolor
602
+ *.xcp
603
+
604
+ # xmpincl
605
+ *.xmpi
606
+
607
+ # xindy
608
+ *.xdy
609
+
610
+ # xypic precompiled matrices and outlines
611
+ *.xyc
612
+ *.xyd
613
+
614
+ # endfloat
615
+ *.ttt
616
+ *.fff
617
+
618
+ # Latexian
619
+ TSWLatexianTemp*
620
+
621
+ ## Editors:
622
+ # WinEdt
623
+ *.bak
624
+ *.sav
625
+
626
+ # Texpad
627
+ .texpadtmp
628
+
629
+ # LyX
630
+ *.lyx~
631
+
632
+ # Kile
633
+ *.backup
634
+
635
+ # gummi
636
+ .*.swp
637
+
638
+ # KBibTeX
639
+ *~[0-9]*
640
+
641
+ # TeXnicCenter
642
+ *.tps
643
+
644
+ # auto folder when using emacs and auctex
645
+ ./auto/*
646
+ *.el
647
+
648
+ # expex forward references with \gathertags
649
+ *-tags.tex
650
+
651
+ # standalone packages
652
+ *.sta
653
+
654
+ # Makeindex log files
655
+ *.lpz
656
+
657
+ # xwatermark package
658
+ *.xwm
659
+
660
+ # REVTeX puts footnotes in the bibliography by default, unless the nofootinbib
661
+ # option is specified. Footnotes are the stored in a file with suffix Notes.bib.
662
+ # Uncomment the next line to have this generated file ignored.
663
+ #*Notes.bib
664
+
665
+ ### Eclipse template
666
+ .metadata
667
+ bin/
668
+ tmp/
669
+ *.tmp
670
+ *.bak
671
+ *.swp
672
+ *~.nib
673
+ local.properties
674
+ .settings/
675
+ .loadpath
676
+ .recommenders
677
+
678
+ # External tool builders
679
+ .externalToolBuilders/
680
+
681
+ # Locally stored "Eclipse launch configurations"
682
+ *.launch
683
+
684
+ # PyDev specific (Python IDE for Eclipse)
685
+ *.pydevproject
686
+
687
+ # CDT-specific (C/C++ Development Tooling)
688
+ .cproject
689
+
690
+ # CDT- autotools
691
+ .autotools
692
+
693
+ # Java annotation processor (APT)
694
+ .factorypath
695
+
696
+ # PDT-specific (PHP Development Tools)
697
+ .buildpath
698
+
699
+ # sbteclipse plugin
700
+ .target
701
+
702
+ # Tern plugin
703
+ .tern-project
704
+
705
+ # TeXlipse plugin
706
+ .texlipse
707
+
708
+ # STS (Spring Tool Suite)
709
+ .springBeans
710
+
711
+ # Code Recommenders
712
+ .recommenders/
713
+
714
+ # Annotation Processing
715
+ .apt_generated/
716
+ .apt_generated_test/
717
+
718
+ # Scala IDE specific (Scala & Java development for Eclipse)
719
+ .cache-main
720
+ .scala_dependencies
721
+ .worksheet
722
+
723
+ # Uncomment this line if you wish to ignore the project description file.
724
+ # Typically, this file would be tracked if it contains build/dependency configurations:
725
+ #.project
726
+
727
+ ### JupyterNotebooks template
728
+ # gitignore template for Jupyter Notebooks
729
+ # website: http://jupyter.org/
730
+
731
+ .ipynb_checkpoints
732
+ */.ipynb_checkpoints/*
733
+
734
+ # IPython
735
+ profile_default/
736
+ ipython_config.py
737
+
738
+ # Remove previous ipynb_checkpoints
739
+ # git rm -r .ipynb_checkpoints/
740
+
741
+ ### Python template
742
+ # Byte-compiled / optimized / DLL files
743
+ __pycache__/
744
+ *.py[cod]
745
+ *$py.class
746
+
747
+ # C extensions
748
+ *.so
749
+
750
+ # Distribution / packaging
751
+ .Python
752
+ build/
753
+ develop-eggs/
754
+ dist/
755
+ downloads/
756
+ eggs/
757
+ .eggs/
758
+ lib/
759
+ lib64/
760
+ parts/
761
+ sdist/
762
+ var/
763
+ wheels/
764
+ share/python-wheels/
765
+ *.egg-info/
766
+ .installed.cfg
767
+ *.egg
768
+ MANIFEST
769
+
770
+ # PyInstaller
771
+ # Usually these files are written by a python script from a template
772
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
773
+ *.manifest
774
+ *.spec
775
+
776
+ # Installer logs
777
+ pip-log.txt
778
+ pip-delete-this-directory.txt
779
+
780
+ # Unit test / coverage reports
781
+ htmlcov/
782
+ .tox/
783
+ .nox/
784
+ .coverage
785
+ .coverage.*
786
+ .cache
787
+ nosetests.xml
788
+ coverage.xml
789
+ *.cover
790
+ *.py,cover
791
+ .hypothesis/
792
+ .pytest_cache/
793
+ cover/
794
+
795
+ # Translations
796
+ *.mo
797
+ *.pot
798
+
799
+ # Django stuff:
800
+ *.log
801
+ local_settings.py
802
+ db.sqlite3
803
+ db.sqlite3-journal
804
+
805
+ # Flask stuff:
806
+ instance/
807
+ .webassets-cache
808
+
809
+ # Scrapy stuff:
810
+ .scrapy
811
+
812
+ # Sphinx documentation
813
+ docs/_build/
814
+
815
+ # PyBuilder
816
+ .pybuilder/
817
+ target/
818
+
819
+ # Jupyter Notebook
820
+ .ipynb_checkpoints
821
+
822
+ # IPython
823
+ profile_default/
824
+ ipython_config.py
825
+
826
+ # pyenv
827
+ # For a library or package, you might want to ignore these files since the code is
828
+ # intended to run in multiple environments; otherwise, check them in:
829
+ # .python-version
830
+
831
+ # pipenv
832
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
833
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
834
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
835
+ # install all needed dependencies.
836
+ #Pipfile.lock
837
+
838
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
839
+ __pypackages__/
840
+
841
+ # Celery stuff
842
+ celerybeat-schedule
843
+ celerybeat.pid
844
+
845
+ # SageMath parsed files
846
+ *.sage.py
847
+
848
+ # Environments
849
+ .env
850
+ .venv
851
+ env/
852
+ venv/
853
+ ENV/
854
+ env.bak/
855
+ venv.bak/
856
+
857
+ # Spyder project settings
858
+ .spyderproject
859
+ .spyproject
860
+
861
+ # Rope project settings
862
+ .ropeproject
863
+
864
+ # mkdocs documentation
865
+ /site
866
+
867
+ # mypy
868
+ .mypy_cache/
869
+ .dmypy.json
870
+ dmypy.json
871
+
872
+ # Pyre type checker
873
+ .pyre/
874
+
875
+ # pytype static type analyzer
876
+ .pytype/
877
+
878
+ # Cython debug symbols
879
+ cython_debug/
880
+
881
+ # CUSTOM
882
+ .idea
883
+ tmp
884
+ *.tmp.py
885
+ .DS_store
886
+ .DS_Store
README.md CHANGED
@@ -1,33 +1,17 @@
1
  ---
2
- title: Gpt2 QA
3
- emoji: 👀
4
  colorFrom: blue
5
- colorTo: pink
6
  sdk: streamlit
7
  app_file: app.py
8
  pinned: false
9
  ---
10
 
11
- # Configuration
12
 
13
- `title`: _string_
14
- Display title for the Space
15
 
16
- `emoji`: _string_
17
- Space emoji (emoji-only character allowed)
18
-
19
- `colorFrom`: _string_
20
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
21
-
22
- `colorTo`: _string_
23
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
24
-
25
- `sdk`: _string_
26
- Can be either `gradio` or `streamlit`
27
-
28
- `app_file`: _string_
29
- Path to your main application file (which contains either `gradio` or `streamlit` Python code).
30
- Path is relative to the root of the repository.
31
-
32
- `pinned`: _boolean_
33
- Whether the Space stays on top of your list.
1
  ---
2
+ title: GPT2 QA
3
+ emoji: ⁉️
4
  colorFrom: blue
5
+ colorTo: yellow
6
  sdk: streamlit
7
  app_file: app.py
8
  pinned: false
9
  ---
10
 
11
+ # Streamlit demo for GPT2 QA
12
 
13
+ ### Launch demo:
 
14
 
15
+ ```
16
+ streamlit run app.py
17
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoTokenizer
3
+ from transformers import GPT2LMHeadModel
4
+ from transformers import set_seed
5
+
6
+ import meta
7
+ from normalizer import normalize
8
+ from utils import load_json
9
+ from utils import local_css
10
+
11
+ EXAMPLES = load_json("examples.json")
12
+ CK = ""
13
+ QK = "Q:"
14
+ AK = "A:"
15
+
16
+
17
+ class TextGeneration:
18
+ def __init__(self):
19
+ self.debug = True
20
+ self.dummy_output = "Destiny's Child"
21
+ self.tokenizer = None
22
+ self.model = None
23
+ self.model_name_or_path = "m3hrdadfi/gpt2-QA"
24
+ self.length_margin = 100
25
+ set_seed(42)
26
+
27
+ def load(self):
28
+ if not self.debug:
29
+ self.tokenizer = AutoTokenizer.from_pretrained(self.model_name_or_path)
30
+ self.model = GPT2LMHeadModel.from_pretrained(self.model_name_or_path)
31
+
32
+ def generate(self, prompt, generation_kwargs):
33
+
34
+ if not self.debug:
35
+ input_ids = self.tokenizer([prompt], return_tensors="pt")["input_ids"]
36
+ max_length = len(input_ids[0]) + self.length_margin
37
+ max_length = min(max_length, 1024)
38
+ generation_kwargs["max_length"] = max_length
39
+
40
+ generated = self.model.generate(
41
+ input_ids,
42
+ **generation_kwargs,
43
+ )[0]
44
+
45
+ answer = self.tokenizer.decode(generated, skip_special_tokens=True)
46
+ found = answer.find(f"{AK}")
47
+ if not found:
48
+ return ""
49
+
50
+ answer = [a.strip() for a in answer[found:].split(f"{AK}") if a.strip()]
51
+ answer = answer[0] if len(answer) > 0 else ""
52
+ return answer
53
+
54
+ return self.dummy_output
55
+
56
+
57
+ @st.cache(allow_output_mutation=True)
58
+ def load_text_generator():
59
+ generator = TextGeneration()
60
+ generator.load()
61
+ return generator
62
+
63
+
64
+ def main():
65
+ st.set_page_config(
66
+ page_title="GPT2 QA",
67
+ page_icon="⁉️",
68
+ layout="wide",
69
+ initial_sidebar_state="expanded"
70
+ )
71
+ local_css("assets/style.css")
72
+ generator = load_text_generator()
73
+
74
+ st.sidebar.markdown(meta.SIDEBAR_INFO)
75
+ num_beams = st.sidebar.slider(
76
+ label='Number of Beam',
77
+ help="Number of beams for beam search",
78
+ min_value=4,
79
+ max_value=15,
80
+ value=5,
81
+ step=1
82
+ )
83
+ repetition_penalty = st.sidebar.slider(
84
+ label='Repetition Penalty',
85
+ help="The parameter for repetition penalty",
86
+ min_value=1.0,
87
+ max_value=10.0,
88
+ value=1.0,
89
+ step=0.1
90
+ )
91
+ length_penalty = st.sidebar.slider(
92
+ label='Length Penalty',
93
+ help="Exponential penalty to the length",
94
+ min_value=1.0,
95
+ max_value=10.0,
96
+ value=1.0,
97
+ step=0.1
98
+ )
99
+ early_stopping = st.sidebar.selectbox(
100
+ label='Early Stopping ?',
101
+ options=(True, False),
102
+ help="Whether to stop the beam search when at least num_beams sentences are finished per batch or not",
103
+ )
104
+ generation_kwargs = {
105
+ "num_beams": num_beams,
106
+ "early_stopping": early_stopping,
107
+ "repetition_penalty": repetition_penalty,
108
+ "length_penalty": length_penalty,
109
+ }
110
+
111
+ st.markdown(meta.HEADER_INFO)
112
+ prompts = [e["title"] for e in EXAMPLES] + ["Custom"]
113
+ prompt = st.selectbox('Examples', prompts, index=len(prompts) - 1)
114
+
115
+ if prompt == "Custom":
116
+ prompt_box = {
117
+ "context": meta.C_PROMPT_BOX,
118
+ "question": meta.Q_PROMPT_BOX,
119
+ "answers": meta.A_PROMPT_BOX,
120
+ }
121
+ else:
122
+ prompt_box = next(e for e in EXAMPLES if e["title"] == prompt)
123
+
124
+ context = st.text_area("Enter context", prompt_box["context"], height=200)
125
+ question = st.text_area("Enter question", prompt_box["question"], height=100)
126
+ answer = "Ground Truth Answers: " + \
127
+ "".join([f"<span class='ground-truth'>{answer}</span>" for answer in prompt_box["answers"]])
128
+ st.markdown(
129
+ f'<p>'
130
+ f'{answer}'
131
+ f'<p>',
132
+ unsafe_allow_html=True
133
+ )
134
+ generation_kwargs_ph = st.empty()
135
+
136
+ if st.button("Find the answer 🔎 "):
137
+ with st.spinner(text="Searching ..."):
138
+ generation_kwargs_ph.markdown(", ".join([f"`{k}`: {v}" for k, v in generation_kwargs.items()]))
139
+ context = normalize(context)
140
+ question = normalize(question)
141
+
142
+ if context and question:
143
+ text = f"{context} {QK} {question} {AK}"
144
+ generated_answer = generator.generate(text, generation_kwargs)
145
+ generated_answer = f"{AK} {generated_answer}".strip()
146
+ context = f"{CK} {context}".strip()
147
+ question = f"{QK} {question}".strip()
148
+
149
+ st.markdown(
150
+ f'<p>'
151
+ f'<span class="result-text">{context}<span><br/><br/>'
152
+ f'<span class="result-text">{question}<span><br/><br/>'
153
+ f'<span class="result-text generated-text">{generated_answer} </span>'
154
+ f'</p>',
155
+ unsafe_allow_html=True
156
+ )
157
+
158
+
159
+ if __name__ == '__main__':
160
+ main()
assets/style.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .rtl,{
2
+ text-align: right;
3
+ direction: rtl !important;
4
+ }
5
+ .ltr {
6
+ text-align: left;
7
+ direction: ltr !important;
8
+ }
9
+
10
+ span.result-text {
11
+ padding: 3px 3px;
12
+ line-height: 32px;
13
+ }
14
+ span.generated-text {
15
+ background-color: rgb(118 200 147 / 13%);
16
+ }
17
+ span.ground-truth {
18
+ border-bottom: 4px solid #003fff78;
19
+ padding: 2px 4px;
20
+ display: inline-block;
21
+ margin-right: 10px;
22
+ }
examples.json ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "title": "1: Franco-Prussian_War",
4
+ "context": "During the war, the Paris National Guard, particularly in the working-class neighbourhoods of Paris, had become highly politicised and units elected officers; many refused to wear uniforms or obey commands from the national government. National guard units tried to seize power in Paris on 31 October 1870 and 22 January 1871. On 18 March 1871, when the regular army tried to remove cannons from an artillery park on Montmartre, National Guard units resisted and killed two army generals. The national government and regular army forces retreated to Versailles and a revolutionary government was proclaimed in Paris. A Commune was elected, which was dominated by socialists, anarchists and revolutionaries. The red flag replaced the French tricolour and a civil war began between the Commune and the regular army, which attacked and recaptured Paris from 21–28 May in La Semaine Sanglante (Bloody week).",
5
+ "question": "On which dates did La Semaine Sanglante occur in Paris?",
6
+ "answers": [
7
+ "21–28 May"
8
+ ]
9
+ },
10
+ {
11
+ "title": "2: Franco-Prussian_War",
12
+ "context": "During the war, the Paris National Guard, particularly in the working-class neighbourhoods of Paris, had become highly politicised and units elected officers; many refused to wear uniforms or obey commands from the national government. National guard units tried to seize power in Paris on 31 October 1870 and 22 January 1871. On 18 March 1871, when the regular army tried to remove cannons from an artillery park on Montmartre, National Guard units resisted and killed two army generals. The national government and regular army forces retreated to Versailles and a revolutionary government was proclaimed in Paris. A Commune was elected, which was dominated by socialists, anarchists and revolutionaries. The red flag replaced the French tricolour and a civil war began between the Commune and the regular army, which attacked and recaptured Paris from 21–28 May in La Semaine Sanglante (Bloody week).",
13
+ "question": "What became highly politicised during the war?",
14
+ "answers": [
15
+ "Paris National Guard"
16
+ ]
17
+ },
18
+ {
19
+ "title": "3: Franco-Prussian_War",
20
+ "context": "The Prussian Army, under the terms of the armistice, held a brief victory parade in Paris on 17 February; the city was silent and draped with black and the Germans quickly withdrew. Bismarck honoured the armistice, by allowing train loads of food into Paris and withdrawing Prussian forces to the east of the city, prior to a full withdrawal once France agreed to pay a five billion franc war indemnity. At the same time, Prussian forces were concentrated in the provinces of Alsace and Lorraine. An exodus occurred from Paris as some 200,000 people, predominantly middle-class, went to the countryside.",
21
+ "question": "France had to consent to pay how much in war indemnity?",
22
+ "answers": [
23
+ "five billion franc"
24
+ ]
25
+ },
26
+ {
27
+ "title": "4: Franco-Prussian_War",
28
+ "context": "On 1 September 1870, the battle opened with the Army of Châlons, with 202 infantry battalions, 80 cavalry squadrons and 564 guns, attacking the surrounding Prussian Third and Meuse Armies totaling 222 infantry battalions, 186 cavalry squadrons and 774 guns. General De Wimpffen, the commander of the French V Corps in reserve, hoped to launch a combined infantry and cavalry attack against the Prussian XI Corps. But by 11:00, Prussian artillery took a toll on the French while more Prussian troops arrived on the battlefield. The French cavalry, commanded by General Marguerite, launched three desperate attacks on the nearby village of Floing where the Prussian XI Corps was concentrated. Marguerite was killed leading the very first charge and the two additional charges led to nothing but heavy losses. By the end of the day, with no hope of breaking out, Napoleon III called off the attacks. The French lost over 17,000 men, killed or wounded, with 21,000 captured. The Prussians reported their losses at 2,320 killed, 5,980 wounded and 700 captured or missing. By the next day, on 2 September, Napoleon III surrendered and was taken prisoner with 104,000 of his soldiers. It was an overwhelming victory for the Prussians, for they not only captured an entire French army, but the leader of France as well. The defeat of the French at Sedan had decided the war in Prussia's favour. One French army was now immobilised and besieged in the city of Metz, and no other forces stood on French ground to prevent a German invasion. Nevertheless, the war would continue.",
29
+ "question": "On which date did the battle begin with the Army of Chalons attacking various Prussian divisions?",
30
+ "answers": [
31
+ "1 September 1870"
32
+ ]
33
+ },
34
+ {
35
+ "title": "5: Franco-Prussian_War",
36
+ "context": "To relieve pressure from the expected German attack into Alsace-Lorraine, Napoleon III and the French high command planned a seaborne invasion of northern Germany as soon as war began. The French expected the invasion to divert German troops and to encourage Denmark to join in the war, with its 50,000-strong army and the Royal Danish Navy. It was discovered that Prussia had recently built defences around the big North German ports, including coastal artillery batteries with Krupp heavy artillery, which with a range of 4,000 yards (3,700 m), had double the range of French naval guns. The French Navy lacked the heavy guns to engage the coastal defences and the topography of the Prussian coast made a seaborne invasion of northern Germany impossible.",
37
+ "question": "What did the French navy lack in engaging coastal defenses?",
38
+ "answers": [
39
+ "heavy guns"
40
+ ]
41
+ },
42
+ {
43
+ "title": "6: Elevator",
44
+ "context": "Some types of residential elevators do not use a traditional elevator shaft, machine room, and elevator hoistway. This allows an elevator to be installed where a traditional elevator may not fit, and simplifies installation. The ASME board first approved machine-room-less systems in a revision of the ASME A17.1 in 2007. Machine-room-less elevators have been available commercially since the mid 1990s, however cost and overall size prevented their adoption to the residential elevator market until around 2010.",
45
+ "question": "What types of elevators occassionaly do not use a traditional elevator shaft, machine room or hoistway?",
46
+ "answers": [
47
+ "residential"
48
+ ]
49
+ },
50
+ {
51
+ "title": "7: Elevator",
52
+ "context": "Past problems with hydraulic elevators include underground electrolytic destruction of the cylinder and bulkhead, pipe failures, and control failures. Single bulkhead cylinders, typically built prior to a 1972 ASME A17.1 Elevator Safety Code change requiring a second dished bulkhead, were subject to possible catastrophic failure. The code previously permitted only single-bottom hydraulic cylinders. In the event of a cylinder breach, the fluid loss results in uncontrolled down movement of the elevator. This creates two significant hazards: being subject to an impact at the bottom when the elevator stops suddenly and being in the entrance for a potential shear if the rider is partly in the elevator. Because it is impossible to verify the system at all times, the code requires periodic testing of the pressure capability. Another solution to protect against a cylinder blowout is to install a plunger gripping device. One commercially available is known by the marketing name \"LifeJacket\". This is a device which, in the event of an uncontrolled downward acceleration, nondestructively grips the plunger and stops the car. A device known as an overspeed or rupture valve is attached to the hydraulic inlet\/outlet of the cylinder and is adjusted for a maximum flow rate. If a pipe or hose were to break (rupture), the flow rate of the rupture valve will surpass a set limit and mechanically stop the outlet flow of hydraulic fluid, thus stopping the plunger and the car in the down direction.",
53
+ "question": "Before the code change was enacted what was the only permitted hydraulic cylinder type?",
54
+ "answers": [
55
+ "single-bottom"
56
+ ]
57
+ },
58
+ {
59
+ "title": "8: Elevator",
60
+ "context": "The first electric elevator was built by Werner von Siemens in 1880 in Germany. The inventor Anton Freissler developed the ideas of von Siemens and built up a successful enterprise in Austria-Hungary. The safety and speed of electric elevators were significantly enhanced by Frank Sprague who added floor control, automatic elevators, acceleration control of cars, and safeties. His elevator ran faster and with larger loads than hydraulic or steam elevators, and 584 electric elevators were installed before Sprague sold his company to the Otis Elevator Company in 1895. Sprague also developed the idea and technology for multiple elevators in a single shaft.",
61
+ "question": "Who built the first electric elevator?",
62
+ "answers": [
63
+ "Werner von Siemens"
64
+ ]
65
+ },
66
+ {
67
+ "title": "9: Elevator",
68
+ "context": "Once the elevator arrives at the floor, it will park with its doors open and the car buttons will be disabled to prevent a passenger from taking control of the elevator. Medical personnel must then activate the code-blue key switch inside the car, select their floor and close the doors with the door close button. The elevator will then travel non-stop to the selected floor, and will remain in code-blue service until switched off in the car. Some hospital elevators will feature a 'hold' position on the code-blue key switch (similar to fire service) which allows the elevator to remain at a floor locked out of service until code blue is deactivated.",
69
+ "question": "Once it arrives what does the elevator do",
70
+ "answers": [
71
+ "will remain in code-blue service until switched off in the car"
72
+ ]
73
+ },
74
+ {
75
+ "title": "10: Elevator",
76
+ "context": "Some skyscraper buildings and other types of installation feature a destination operating panel where a passenger registers their floor calls before entering the car. The system lets them know which car to wait for, instead of everyone boarding the next car. In this way, travel time is reduced as the elevator makes fewer stops for individual passengers, and the computer distributes adjacent stops to different cars in the bank. Although travel time is reduced, passenger waiting times may be longer as they will not necessarily be allocated the next car to depart. During the down peak period the benefit of destination control will be limited as passengers have a common destination.",
77
+ "question": "What is the downside to a :destination operating panel\"?",
78
+ "answers": [
79
+ "passenger waiting times may be longer as they will not necessarily be allocated the next car to depart"
80
+ ]
81
+ },
82
+ {
83
+ "title": "11: FA_Cup",
84
+ "context": "The final has never been contested by two teams from outside the top division and there have only been eight winners who weren't in the top flight: Notts County (1894); Tottenham Hotspur (1901); Wolverhampton Wanderers (1908); Barnsley (1912); West Bromwich Albion (1931); Sunderland (1973), Southampton (1976) and West Ham United (1980). With the exception of Tottenham, these clubs were all playing in the second tier (the old Second Division) - Tottenham were playing in the Southern League and were only elected to the Football League in 1908, meaning they are the only non-league winners of the FA Cup. Other than Tottenham's victory, only 24 finalists have come from outside English football's top tier, with a record of 7 wins and 17 runners-up: and none at all from the third tier or lower, Southampton (1902) being the last finalist from outside the top two tiers.",
85
+ "question": "What year did that take place? ",
86
+ "answers": [
87
+ "1894"
88
+ ]
89
+ },
90
+ {
91
+ "title": "12: FA_Cup",
92
+ "context": "The competition is open to any club down to Level 10 of the English football league system which meets the eligibility criteria. All clubs in the top four levels (the Premier League and the three divisions of the Football League) are automatically eligible. Clubs in the next six levels (non-league football) are also eligible provided they have played in either the FA Cup, FA Trophy or FA Vase competitions in the previous season. Newly formed clubs, such as F.C. United of Manchester in 2005–06 and also 2006–07, may not therefore play in the FA Cup in their first season. All clubs entering the competition must also have a suitable stadium.",
93
+ "question": "Do I need a stadium to compete? ",
94
+ "answers": [
95
+ "All clubs entering the competition must also have a suitable stadium."
96
+ ]
97
+ },
98
+ {
99
+ "title": "13: FA_Cup",
100
+ "context": "Many[who?] expected BSkyB to make a bid to show some of the remaining FA Cup games for the remainder of the 2009–10 season which would include a semi-final and shared rights to the final. ESPN took over the package Setanta held for the FA Cup from the 2010–11 season. The 2011 final was also shown live on Sky 3D in addition to ESPN (who provided the 3D coverage for Sky 3D) and ITV. Following the sale of ESPN's UK and Ireland channels to BT, ESPN's rights package transferred to BT Sport from the 2013–14 season.",
101
+ "question": "What year did this take place? ",
102
+ "answers": [
103
+ "the 2013–14 season"
104
+ ]
105
+ },
106
+ {
107
+ "title": "14: FA_Cup",
108
+ "context": "The final has never been contested by two teams from outside the top division and there have only been eight winners who weren't in the top flight: Notts County (1894); Tottenham Hotspur (1901); Wolverhampton Wanderers (1908); Barnsley (1912); West Bromwich Albion (1931); Sunderland (1973), Southampton (1976) and West Ham United (1980). With the exception of Tottenham, these clubs were all playing in the second tier (the old Second Division) - Tottenham were playing in the Southern League and were only elected to the Football League in 1908, meaning they are the only non-league winners of the FA Cup. Other than Tottenham's victory, only 24 finalists have come from outside English football's top tier, with a record of 7 wins and 17 runners-up: and none at all from the third tier or lower, Southampton (1902) being the last finalist from outside the top two tiers.",
109
+ "question": "Has the final been played by a two clubs outside of the top divisions? ",
110
+ "answers": [
111
+ "The final has never been contested by two teams from outside the top division"
112
+ ]
113
+ },
114
+ {
115
+ "title": "15: FA_Cup",
116
+ "context": "Chasetown, whilst playing at Level 8 of English football during the 2007–08 competition, are the lowest-ranked team to play in the Third Round Proper (final 64, of 731 teams entered that season). Chasetown was then a member of the Southern League Division One Midlands (a lower level within the Southern Football League), when they lost to Football League Championship (Level 2) team Cardiff City, the eventual FA Cup runners-up that year. Their success earned the lowly organisation over £60,000 in prize money.",
117
+ "question": "What FA cup season did this take place in? ",
118
+ "answers": [
119
+ "2007–08 competition"
120
+ ]
121
+ },
122
+ {
123
+ "title": "16: Antenna_(radio)",
124
+ "context": "Antenna tuning generally refers to cancellation of any reactance seen at the antenna terminals, leaving only a resistive impedance which might or might not be exactly the desired impedance (that of the transmission line). Although an antenna may be designed to have a purely resistive feedpoint impedance (such as a dipole 97% of a half wavelength long) this might not be exactly true at the frequency that it is eventually used at. In some cases the physical length of the antenna can be \"trimmed\" to obtain a pure resistance. On the other hand, the addition of a series inductance or parallel capacitance can be used to cancel a residual capacitative or inductive reactance, respectively.",
125
+ "question": "What can be used to cancel a inductibe reactance or residual capacitative?",
126
+ "answers": [
127
+ "parallel capacitance"
128
+ ]
129
+ },
130
+ {
131
+ "title": "17: Antenna_(radio)",
132
+ "context": "It is possible to use the impedance matching concepts to construct vertical antennas substantially shorter than the 1⁄4 wavelength at which the antenna is resonant. By adding an inductance in series with the antenna, a so-called loading coil, the capacitive reactance of this antenna can be cancelled leaving a pure resistance which can then be matched to the transmission line. Sometimes the resulting resonant frequency of such a system (antenna plus matching network) is described using the construct of electrical length and the use of a shorter antenna at a lower frequency than its resonant frequency is termed electrical lengthening.",
133
+ "question": "For use with more than one channel changes are made to increase what property?",
134
+ "answers": [
135
+ "impedance matching"
136
+ ]
137
+ },
138
+ {
139
+ "title": "18: Antenna_(radio)",
140
+ "context": "On the other hand, classical (analog) television transmissions are usually horizontally polarized, because in urban areas buildings can reflect the electromagnetic waves and create ghost images due to multipath propagation. Using horizontal polarization, ghosting is reduced because the amount of reflection of electromagnetic waves in the p polarization (horizontal polarization off the side of a building) is generally less than s (vertical, in this case) polarization. Vertically polarized analog television has nevertheless been used in some rural areas. In digital terrestrial television such reflections are less problematic, due to robustness of binary transmissions and error correction.",
141
+ "question": "Buildings can create ghost images because of what?",
142
+ "answers": [
143
+ "multipath propagation"
144
+ ]
145
+ },
146
+ {
147
+ "title": "19: Antenna_(radio)",
148
+ "context": "The origin of the word antenna relative to wireless apparatus is attributed to Italian radio pioneer Guglielmo Marconi. In the summer of 1895, Marconi began testing his wireless system outdoors on his father's estate near Bologna and soon began to experiment with long wire \"aerials\". Marconi discovered that by raising the \"aerial\" wire above the ground and connecting the other side of his transmitter to ground, the transmission range was increased. Soon he was able to transmit signals over a hill, a distance of approximately 2.4 kilometres (1.5 mi). In Italian a tent pole is known as l'antenna centrale, and the pole with the wire was simply called l'antenna. Until then wireless radiating transmitting and receiving elements were known simply as aerials or terminals.",
149
+ "question": "Who is most associated with the emergence of the word antenna?",
150
+ "answers": [
151
+ "Guglielmo Marconi"
152
+ ]
153
+ },
154
+ {
155
+ "title": "20: Antenna_(radio)",
156
+ "context": "The radiation pattern of an antenna is a plot of the relative field strength of the radio waves emitted by the antenna at different angles. It is typically represented by a three-dimensional graph, or polar plots of the horizontal and vertical cross sections. The pattern of an ideal isotropic antenna, which radiates equally in all directions, would look like a sphere. Many nondirectional antennas, such as monopoles and dipoles, emit equal power in all horizontal directions, with the power dropping off at higher and lower angles; this is called an omnidirectional pattern and when plotted looks like a torus or donut.",
157
+ "question": "Dipoles are considered to be what antenna type?",
158
+ "answers": [
159
+ "nondirectional"
160
+ ]
161
+ },
162
+ {
163
+ "title": "21: Saint_Helena",
164
+ "context": "The island was uninhabited when discovered by the Portuguese in 1502. One of the most remote islands in the world, it was for centuries an important stopover for ships sailing to Europe from Asia and South Africa. Napoleon was imprisoned there in exile by the British, as were Dinuzulu kaCetshwayo (for leading a Zulu army against British rule) and more than 5,000 Boers taken prisoner during the Second Boer War.",
165
+ "question": "Why was Dinuzulu kaCetshwayo imprisoned on the island?",
166
+ "answers": [
167
+ "leading a Zulu army against British rule"
168
+ ]
169
+ },
170
+ {
171
+ "title": "22: Saint_Helena",
172
+ "context": "ADSL-broadband service is provided with maximum speeds of up to 1536 KBit\/s downstream and 512 KBit\/s upstream offered on contract levels from lite £16 per month to gold+ at £190 per month. There are a few public WiFi hotspots in Jamestown, which are also being operated by SURE (formerly Cable & Wireless).",
173
+ "question": "What is the gold price of the broadband service?",
174
+ "answers": [
175
+ "£190 per month"
176
+ ]
177
+ },
178
+ {
179
+ "title": "23: Saint_Helena",
180
+ "context": "In 1657, Oliver Cromwell granted the English East India Company a charter to govern Saint Helena and the following year the company decided to fortify the island and colonise it with planters. The first governor, Captain John Dutton, arrived in 1659, making Saint Helena one of Britain's oldest colonies outside North America and the Caribbean. A fort and houses were built. After the Restoration of the English monarchy in 1660, the East India Company received a royal charter giving it the sole right to fortify and colonise the island. The fort was renamed James Fort and the town Jamestown, in honour of the Duke of York, later James II of England.",
181
+ "question": "What year did the first governor arrive to Saint Helena?",
182
+ "answers": [
183
+ "1659"
184
+ ]
185
+ },
186
+ {
187
+ "title": "24: Saint_Helena",
188
+ "context": "One commentator has observed that, notwithstanding the high unemployment resulting from the loss of full passports during 1981–2002, the level of loyalty to the British monarchy by the St Helena population is probably not exceeded in any other part of the world. King George VI is the only reigning monarch to have visited the island. This was in 1947 when the King, accompanied by Queen Elizabeth (later the Queen Mother), Princess Elizabeth (later Queen Elizabeth II) and Princess Margaret were travelling to South Africa. Prince Philip arrived at St Helena in 1957 and then his son Prince Andrew visited as a member of the armed forces in 1984 and his sister the Princess Royal arrived in 2002.",
189
+ "question": "Prince Andrews, son of Prince Phillip visited in what year?",
190
+ "answers": [
191
+ "1984"
192
+ ]
193
+ },
194
+ {
195
+ "title": "25: Saint_Helena",
196
+ "context": "Saint FM provided a local radio service for the island which was also available on internet radio and relayed in Ascension Island. The station was not government funded. It was launched in January 2005 and closed on 21 December 2012. It broadcast news, features and music in collaboration with its sister newspaper, the St Helena Independent (which continues).",
197
+ "question": "What date was Saint FM radio launched?",
198
+ "answers": [
199
+ "January 2005"
200
+ ]
201
+ }
202
+ ]
meta.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ HEADER_INFO = """
2
+ # GPT2 QA
3
+ """.strip()
4
+ SIDEBAR_INFO = """
5
+ # Configuration
6
+ """.strip()
7
+ C_PROMPT_BOX = "Enter your text ..."
8
+ Q_PROMPT_BOX = "Ask your question ..."
9
+ A_PROMPT_BOX = "Not entered."
normalizer.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ def normalize(text):
2
+ # TODO...
3
+
4
+ return text
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ streamlit
2
+ Pillow
3
+ torch
4
+ transformers
utils.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import json
3
+ from PIL import Image
4
+
5
+
6
+ def load_image(image_path, image_resize=None):
7
+ image = Image.open(image_path)
8
+ if isinstance(image_resize, tuple):
9
+ image.resize(image_resize)
10
+ return image
11
+
12
+
13
+ def load_text(text_path):
14
+ text = ''
15
+ with open(text_path) as f:
16
+ text = f.read()
17
+
18
+ return text
19
+
20
+
21
+ def load_json(json_path):
22
+ jdata = ''
23
+ with open(json_path) as f:
24
+ jdata = json.load(f)
25
+
26
+ return jdata
27
+
28
+
29
+ def local_css(css_path):
30
+ with open(css_path) as f:
31
+ st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
32
+
33
+
34
+ def remote_css(css_url):
35
+ st.markdown(f'<link href="{css_url}" rel="stylesheet">', unsafe_allow_html=True)