eyad222 commited on
Commit
ee8bdec
·
verified ·
1 Parent(s): a012719

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -2,7 +2,6 @@ import numpy as np
2
  import streamlit as st
3
  import matplotlib.pyplot as plt
4
  from mpl_toolkits.mplot3d import Axes3D
5
- import inflect
6
 
7
  def prediction_pop_model(year, population, pred_year):
8
  n = len(year)
@@ -18,8 +17,17 @@ def prediction_pop_model(year, population, pred_year):
18
  return pred_population
19
 
20
  def number_to_words(number):
21
- p = inflect.engine()
22
- return p.number_to_words(number)
 
 
 
 
 
 
 
 
 
23
 
24
  # Data
25
  year = np.array([1952, 1957, 1962, 1967, 1972, 1977, 1982, 1987, 1992, 1997, 2002, 2007, 2009, 2011, 2013, 2015, 2017, 2019, 2021, 2023, 2024], dtype=np.float64)
@@ -34,7 +42,7 @@ input_year = st.number_input("Enter the year you want to predict the population
34
  # Predict button
35
  if st.button("Predict"):
36
  predicted_population = prediction_pop_model(year, population, input_year)
37
- population_words = number_to_words(predicted_population)
38
  st.write(f"Predicted Population for {input_year}: {population_words}")
39
 
40
  # Plotting
 
2
  import streamlit as st
3
  import matplotlib.pyplot as plt
4
  from mpl_toolkits.mplot3d import Axes3D
 
5
 
6
  def prediction_pop_model(year, population, pred_year):
7
  n = len(year)
 
17
  return pred_population
18
 
19
  def number_to_words(number):
20
+ # Simple conversion function for demonstration
21
+ ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
22
+ tens = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
23
+ teens = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
24
+
25
+ if number < 10:
26
+ return ones[number]
27
+ elif number < 20:
28
+ return teens[number - 10]
29
+ else:
30
+ return tens[number // 10] + ' ' + ones[number % 10]
31
 
32
  # Data
33
  year = np.array([1952, 1957, 1962, 1967, 1972, 1977, 1982, 1987, 1992, 1997, 2002, 2007, 2009, 2011, 2013, 2015, 2017, 2019, 2021, 2023, 2024], dtype=np.float64)
 
42
  # Predict button
43
  if st.button("Predict"):
44
  predicted_population = prediction_pop_model(year, population, input_year)
45
+ population_words = number_to_words(int(predicted_population))
46
  st.write(f"Predicted Population for {input_year}: {population_words}")
47
 
48
  # Plotting