소스 검색

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)

Loading…
취소
저장