ソースを参照

counting how many words are in abstracts

solr_update
Simon Bowie 2年前
コミット
b88a14ec45
2個のファイルの変更18行の追加2行の削除
  1. +2
    -1
      web/app/templates/abstracts.html
  2. +16
    -1
      word_count.py

+ 2
- 1
web/app/templates/abstracts.html ファイルの表示

@@ -10,7 +10,8 @@
<div class="row">
<div class="col m-5">
<p class="h1 text-center">Reading Fragments</p>
<p class="mt-2 text-center">a <span id="time"></span> minute read out of 662781 minutes reading time</p>
<!-- The following total reading time is based on the calculation of approx. 43,647,513 words in all the documents divided by 200 as the average reading speed of 200 wpm -->
<p class="mt-2 text-center">a <span id="time"></span> minute read out of 218238 minutes reading time</p>
<a href="{{ url_for('main.index') }}" class="h1 text-left"> ⇽ </a>
</div>
</div>

+ 16
- 1
word_count.py ファイルの表示

@@ -16,7 +16,22 @@ for root, dirs, files in os.walk(directory):
content = file.read()
#text = rtf_to_text(content)
words = content.split()
substring = '\\'
# remove elements from list that contain given string
words = [item for item in words if substring not in item]
substring = '}'
# remove elements from list that contain given string
words = [item for item in words if substring not in item]
substring = '{'
# remove elements from list that contain given string
words = [item for item in words if substring not in item]
substring = '/'
# remove elements from list that contain given string
words = [item for item in words if substring not in item]
substring = '('
# remove elements from list that contain given string
words = [item for item in words if substring not in item]
total += len(words)
#print(text)
#print(words)

print(total)

読み込み中…
キャンセル
保存