Sean MacAvaney commited on
Commit
7e8e133
1 Parent(s): 4692c69
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -5,6 +5,7 @@ pt.init()
5
  from pyterrier_gradio import Demo, MarkdownFile, interface, df2code, code2md, EX_Q
6
 
7
  retr = pt.TerrierRetrieve.from_dataset('vaswani', 'terrier_stemmed')
 
8
 
9
  COLAB_NAME = 'pyterrier_retrieve.ipynb'
10
  COLAB_INSTALL = '''
@@ -33,15 +34,29 @@ retr({df2code(input)})'''
33
  res['score'] = res['score'].map(lambda x: round(x, 2))
34
  return (res, code2md(code, COLAB_INSTALL, COLAB_NAME))
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  interface(
37
  MarkdownFile('README.md'),
38
  Demo(
39
  predict,
40
- pd.DataFrame([
41
- ['1', 'measurement of dielectric constant of liquids by the use of microwave techniques'],
42
- ['2', 'mathematical analysis and design details of waveguide fed microwave radiations'],
43
- ['3', 'use of digital computers in the design of band pass filters having given phase and attenuation characteristics'],
44
- ], columns=['qid', 'query']),
45
  [
46
  gr.Dropdown(
47
  choices=['vaswani stemmed'],
@@ -64,5 +79,12 @@ interface(
64
  )],
65
  scale=2/3
66
  ),
 
 
 
 
 
 
 
67
  MarkdownFile('wrapup.md'),
68
  ).launch(share=False)
 
5
  from pyterrier_gradio import Demo, MarkdownFile, interface, df2code, code2md, EX_Q
6
 
7
  retr = pt.TerrierRetrieve.from_dataset('vaswani', 'terrier_stemmed')
8
+ sdm = pt.rewrite.SDM()
9
 
10
  COLAB_NAME = 'pyterrier_retrieve.ipynb'
11
  COLAB_INSTALL = '''
 
34
  res['score'] = res['score'].map(lambda x: round(x, 2))
35
  return (res, code2md(code, COLAB_INSTALL, COLAB_NAME))
36
 
37
+ def predict_sdm(input):
38
+ code = f'''import pandas as pd
39
+ import pyterrier as pt ; pt.init()
40
+
41
+ sdm = pt.rewrite.SDM()
42
+
43
+ sdm({df2code(input)})
44
+ '''
45
+ res = sdm(input)
46
+ return (res, code2md(code, COLAB_INSTALL, COLAB_NAME))
47
+
48
+ Q = pd.DataFrame([
49
+ ['1', 'measurement of dielectric constant of liquids by the use of microwave techniques'],
50
+ ['2', 'mathematical analysis and design details of waveguide fed microwave radiations'],
51
+ ['3', 'use of digital computers in the design of band pass filters having given phase and attenuation characteristics'],
52
+ ], columns=['qid', 'query'])
53
+
54
+
55
  interface(
56
  MarkdownFile('README.md'),
57
  Demo(
58
  predict,
59
+ Q,
 
 
 
 
60
  [
61
  gr.Dropdown(
62
  choices=['vaswani stemmed'],
 
79
  )],
80
  scale=2/3
81
  ),
82
+ MarkdownFile('sdm.md'),
83
+ Demo(
84
+ predict_sdm,
85
+ Q,
86
+ [],
87
+ scale=2/3
88
+ ),
89
  MarkdownFile('wrapup.md'),
90
  ).launch(share=False)