jitesh commited on
Commit
62a9f8b
1 Parent(s): e701941

replaces nltk with re to find num of tokens

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. story_gen.py +5 -4
app.py CHANGED
@@ -17,9 +17,9 @@ story_till_now = container_param.text_input(
17
  label='First Sentence', value='Hello, I\'m a language model,')
18
 
19
  num_generation = container_param.slider(
20
- label='Number of generation', min_value=1, max_value=100, value=10, step=1)
21
  length = container_param.slider(label='Length of the generated sentence',
22
- min_value=1, max_value=100, value=20, step=1)
23
  if mode == 'Create Statistics':
24
  container_mode.write('You selected statistics.')
25
  num_tests = container_param.slider(
 
17
  label='First Sentence', value='Hello, I\'m a language model,')
18
 
19
  num_generation = container_param.slider(
20
+ label='Number of generation', min_value=1, max_value=100, value=3, step=1)
21
  length = container_param.slider(label='Length of the generated sentence',
22
+ min_value=1, max_value=100, value=10, step=1)
23
  if mode == 'Create Statistics':
24
  container_mode.write('You selected statistics.')
25
  num_tests = container_param.slider(
story_gen.py CHANGED
@@ -6,15 +6,15 @@ import printj
6
  from transformers import pipeline # , set_seed
7
  import numpy as np
8
  import pandas as pd
9
- import nltk
10
-
11
 
12
  class StoryGenerator:
13
  def __init__(self):
14
  self.initialise_models()
15
  self.stats_df = pd.DataFrame(data=[], columns=[])
16
  self.stories = []
17
- nltk.download()
18
 
19
 
20
  def initialise_models(self):
@@ -39,7 +39,8 @@ class StoryGenerator:
39
 
40
  @staticmethod
41
  def get_num_token(text):
42
- return len(nltk.word_tokenize(text))
 
43
 
44
  @staticmethod
45
  def check_show_emotion(confidence_score, frequency, w):
 
6
  from transformers import pipeline # , set_seed
7
  import numpy as np
8
  import pandas as pd
9
+ # import nltk
10
+ import re
11
 
12
  class StoryGenerator:
13
  def __init__(self):
14
  self.initialise_models()
15
  self.stats_df = pd.DataFrame(data=[], columns=[])
16
  self.stories = []
17
+ # nltk.download()
18
 
19
 
20
  def initialise_models(self):
 
39
 
40
  @staticmethod
41
  def get_num_token(text):
42
+ # return len(nltk.word_tokenize(text))
43
+ return len(re.findall(r'\w+', text))
44
 
45
  @staticmethod
46
  def check_show_emotion(confidence_score, frequency, w):