def test_wps_wordcount():
    client = client_for(Service(processes=[WordCounter()]))
    datainputs = "text={0}".format(
        "https://en.wikipedia.org/wiki/Web_Processing_Service")
    resp = client.get(
        service='wps', request='execute', version='1.0.0',
        identifier='wordcounter',
        datainputs=datainputs)
    assert_response_success(resp)
Beispiel #2
0
 def set_word_counter(self):
     self.word_counter = WordCounter.WordCounter()
Beispiel #3
0
 def test_text_length(self):
     c = wc.Count("hello 2 times  ")
     truth = json.dumps({"withSpaces":15,"withoutSpaces":11}, separators=(',', ':'))
     self.assertEqual(c.text_length(), truth)
Beispiel #4
0
 def test_character_count(self):
     c = wc.Count("hello 2 times  ")
     truth = json.dumps([{"e":2},{"h":1},{"i":1},{"l":2},{"m":1},{"o":1},{"s":1},{"t":1}], separators=(',', ':'))
     self.assertEqual(c.character_count(), truth)
Beispiel #5
0
 def test_word_count(self):
     c = wc.Count("hello 2 times  ")
     self.assertEqual(c.word_count(), 3)
Beispiel #6
0
def analyze():
    text = request.json
    p = wc.Print(text['text'].lower())
    return p.print()
def main():
    args = sys.argv[1:]
    WordCounter.main(args[0], '')
    print(len(WordCounter.load_data()))
Beispiel #8
0
import sys
from _tkinter import TclError

import WordCounter

common = [
    'się', 'nie', 'w', 'na', 'i', 'z', 'to', 'do', 'a', 'że', 'co', 'po',
    'ale', 'tak', 'o', 'jak', 'jest', 'no', 'za', 'jej', 'żeby', 'już', 'coś',
    'od', 'tylko', 'czy', 'tym', 'może', 'jednak', 'tu'
]

input_path, output_path, special_words = WordCounter.interpret_args(sys.argv)

raw_text = WordCounter.extract_text_from_path(input_path)
all_words, words = WordCounter.extract_words(raw_text)

all_words_count, words_count = WordCounter.count_words(
    all_words), WordCounter.count_words(words)

words = WordCounter.count_each_word(words)
WordCounter.results_to_path(output_path, words, all_words_count, words_count,
                            special_words)

cloud_words = {}

for word in words:
    if word not in common:
        cloud_words[word] = words[word]

try:
    WordCounter.to_cloud(cloud_words)