Skip to content

Commit 0fe22f1

Browse files
committed
addded copyright and formatted
1 parent 003253e commit 0fe22f1

File tree

6 files changed

+69
-19
lines changed

6 files changed

+69
-19
lines changed

counter.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
#
2-
# counter.py v2.0.0
2+
# counter.py
33
#
44
# Copyright (c) 2015,
55
# Mooniak <[email protected]>
66
# Ayantha Randika <[email protected]>
7-
# Improvements: https://github.com/mooniak/Frequency-Counter
7+
# Improvements: https://github.com/mooniak/textual-tools
88
# Released under the GNU General Public License version 3 or later.
99
# See accompanying LICENSE file for details.
1010

11-
1211
class Counter:
1312
punctuation = [' ', ',', '"', '\'', '.', '?', '!', '/', ':', '-', '%', '<', '>', '(', ')', '`']
1413

1514
def __init__(self, unicodeRange=0):
1615
self.charCount = 0
1716
self.charCountNoWhiteSpace = 0
18-
self.wordCount=0
17+
self.wordCount = 0
1918
self.ledgerSingle = {}
2019
self.ledgerDouble = {}
2120
self.ledgerTriple = {}
2221
self.unicodeRange = unicodeRange
2322
self.name = ""
24-
self.source= ""
23+
self.source = ""
2524

2625
def _count_characters(self, openfile):
2726
now = None
@@ -54,8 +53,8 @@ def _count_characters(self, openfile):
5453
self.charCount += 1
5554
if not char.isspace():
5655
self.charCountNoWhiteSpace += 1
57-
if char==" ":
58-
self.wordCount+=1
56+
if char == " ":
57+
self.wordCount += 1
5958

6059
def count(self, name):
6160
try:

fileOps.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#
2+
# fileOps.py
3+
#
4+
# Copyright (c) 2015,
5+
# Mooniak <[email protected]>
6+
# Ayantha Randika <[email protected]>
7+
# Improvements: https://github.com/mooniak/textual-tools
8+
# Released under the GNU General Public License version 3 or later.
9+
# See accompanying LICENSE file for details.
10+
111
import os
212

313

hparser.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#
2+
# hparser.py
3+
#
4+
# Copyright (c) 2015,
5+
# Mooniak <[email protected]>
6+
# Ayantha Randika <[email protected]>
7+
# Improvements: https://github.com/mooniak/textual-tools
8+
# Released under the GNU General Public License version 3 or later.
9+
# See accompanying LICENSE file for details.
10+
111
from html.parser import HTMLParser
212

313

jsonFormulate.py

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#
2+
# jsonFormulate.py
3+
#
4+
# Copyright (c) 2015,
5+
# Mooniak <[email protected]>
6+
# Ayantha Randika <[email protected]>
7+
# Improvements: https://github.com/mooniak/textual-tools
8+
# Released under the GNU General Public License version 3 or later.
9+
# See accompanying LICENSE file for details.
10+
111
import json
212

313

@@ -18,19 +28,19 @@ def json_formulate(counter):
1828
for key, val in counter.ledgerTriple.items():
1929
ledgerTriple.append(CharObj(key, val).__dict__)
2030

21-
ledgerSingle=sorted(ledgerSingle, key=lambda x: x['count'], reverse=True)
22-
ledgerDouble=sorted(ledgerDouble, key=lambda x: x['count'], reverse=True)
23-
ledgerTriple=sorted(ledgerTriple, key=lambda x: x['count'], reverse=True)
31+
ledgerSingle = sorted(ledgerSingle, key=lambda x: x['count'], reverse=True)
32+
ledgerDouble = sorted(ledgerDouble, key=lambda x: x['count'], reverse=True)
33+
ledgerTriple = sorted(ledgerTriple, key=lambda x: x['count'], reverse=True)
2434

2535
out = {}
2636
out['ledgerSingle'] = ledgerSingle
2737
out['ledgerDouble'] = ledgerDouble
2838
out['ledgerTriple'] = ledgerTriple
29-
out['charCount']=counter.charCount
30-
out['charCountNoWhiteSpace']=counter.charCountNoWhiteSpace
31-
out['wordCount']=counter.wordCount
32-
out['unicodeRange']=counter.unicodeRange
33-
out['name']=counter.name
34-
out['source']=counter.source
35-
36-
return "textReport("+json.dumps(out, ensure_ascii=False)+")"
39+
out['charCount'] = counter.charCount
40+
out['charCountNoWhiteSpace'] = counter.charCountNoWhiteSpace
41+
out['wordCount'] = counter.wordCount
42+
out['unicodeRange'] = counter.unicodeRange
43+
out['name'] = counter.name
44+
out['source'] = counter.source
45+
46+
return "textReport(" + json.dumps(out, ensure_ascii=False) + ")"

main.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#
2+
# main.py
3+
#
4+
# Copyright (c) 2015,
5+
# Mooniak <[email protected]>
6+
# Ayantha Randika <[email protected]>
7+
# Improvements: https://github.com/mooniak/textual-tools
8+
# Released under the GNU General Public License version 3 or later.
9+
# See accompanying LICENSE file for details.
10+
111
import sys
212
import json
313

@@ -6,11 +16,12 @@
616
from scraper import scrape
717
from jsonFormulate import json_formulate
818

19+
920
def local_count(name, out=os.getcwd() + "/report.JSON"):
1021
file_list = folder_reader(name)
1122
count = Counter()
1223
count.name = name
13-
count.source=name
24+
count.source = name
1425
if file_list == None:
1526
count.name = name
1627
print(json.dumps(count))

scraper.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#
2+
# scraper.py
3+
#
4+
# Copyright (c) 2015,
5+
# Mooniak <[email protected]>
6+
# Ayantha Randika <[email protected]>
7+
# Improvements: https://github.com/mooniak/textual-tools
8+
# Released under the GNU General Public License version 3 or later.
9+
# See accompanying LICENSE file for details.
10+
111
from urllib.parse import urlparse, urljoin
212
from urllib.request import Request, urlopen
313
import os

0 commit comments

Comments
 (0)