colonelwatch commited on
Commit
c4788e3
·
1 Parent(s): 7bb8a83

Automatically determine the quantity

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -5,6 +5,7 @@ from dataclasses import dataclass
5
  from itertools import batched, chain
6
  import json
7
  import os
 
8
  from pathlib import Path
9
  from sys import stderr
10
  from typing import TypedDict, Self, Any, Callable
@@ -279,9 +280,22 @@ def main():
279
  return (result_strings, )
280
 
281
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  gr.Markdown("# abstracts-index")
283
  gr.Markdown(
284
- "Explore 95 million academic publications selected from the "
285
  "[OpenAlex](https://openalex.org) dataset. This project is an index of the "
286
  "embeddings generated from their titles and abstracts. The embeddings were "
287
  f"generated using the {model_name} model provided by the "
 
5
  from itertools import batched, chain
6
  import json
7
  import os
8
+ from math import log10
9
  from pathlib import Path
10
  from sys import stderr
11
  from typing import TypedDict, Self, Any, Callable
 
280
  return (result_strings, )
281
 
282
  with gr.Blocks() as demo:
283
+ # figure out the words to describe the quantity
284
+ n_entries = len(index)
285
+ n_digits = int(log10(n_entries))
286
+ divisor, postfix = {
287
+ 0: (1, ""),
288
+ 1: (1000, " thousand"),
289
+ 2: (1000000, " million"),
290
+ 3: (1000000000, " billion"),
291
+ }[n_digits // 3]
292
+ significand = n_entries / divisor
293
+ significand = round(significand, 1 if (n_digits % 3 == 1) else None)
294
+ quantity = str(significand) + postfix
295
+
296
  gr.Markdown("# abstracts-index")
297
  gr.Markdown(
298
+ f"Explore {quantity} academic publications selected from the "
299
  "[OpenAlex](https://openalex.org) dataset. This project is an index of the "
300
  "embeddings generated from their titles and abstracts. The embeddings were "
301
  f"generated using the {model_name} model provided by the "