<commit_before>#!/usr/bin/env python
"""
.. module:: main
    :synopsis: This module shows example usage
"""

from similarity.text.document import TrainingDocument
from similarity.text.clustering import cluster_documents
from similarity.text.train import create_categories_with_documents

from nltk.cluster import (
    KMeansClusterer,
    GAAClusterer,
    euclidean_distance,
)

doc = TrainingDocument(name="Test", text="To jest taki, a nie inny tekst. TO jest to.")
doc.calculate_terms_belongness()

print "Lista termow z dokumentu:"
print doc.termsWithWeights.keys()
# print "Zbior termow z dokumemntu (lista bez powtorzen):"
# print doc.uniqueTerms
print "Wagi termow w dokumencie:"
print doc.termsWithWeights
print "Stopien przynaleznosci termow do dokumentu:"
print doc.termsBelongness

# cluster_documents("texts/ufo/", "[0-9]*.txt", KMeansClusterer, 2, euclidean_distance)
# cluster_documents("texts/", "*/[0-9]*.txt", KMeansClusterer, 5, euclidean_distance)

categories = create_categories_with_documents()
for category in categories:
    for td in category.trainingDocuments:
        print(td.termsBelongness)<commit_msg>Poprawione błędy w category.py<commit_after>#!/usr/bin/env python
"""
.. module:: main
    :synopsis: This module shows example usage
"""

from similarity.text.document import TrainingDocument
from similarity.text.clustering import cluster_documents
from similarity.text.train import create_categories_with_documents

from nltk.cluster import (
    KMeansClusterer,
    GAAClusterer,
    euclidean_distance,
)

doc = TrainingDocument(name="Test", text="To jest taki, a nie inny tekst. TO jest to.")
doc.calculate_terms_belongness()

print "Lista termow z dokumentu:"
print doc.termsWithWeights.keys()
# print "Zbior termow z dokumemntu (lista bez powtorzen):"
# print doc.uniqueTerms
print "Wagi termow w dokumencie:"
print doc.termsWithWeights
print "Stopien przynaleznosci termow do dokumentu:"
print doc.termsBelongness

# cluster_documents("texts/ufo/", "[0-9]*.txt", KMeansClusterer, 2, euclidean_distance)
# cluster_documents("texts/", "*/[0-9]*.txt", KMeansClusterer, 12, euclidean_distance)

categories = create_categories_with_documents()
for category in categories:
    for td in category.trainingDocuments:
        print(td.termsBelongness)
{'fraction_non_alphanumeric': 0.10288966725043783, 'fraction_numerical': 0.005691768826619965, 'mean_word_length': 5.700879765395895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3444002', 'n_tokens_mistral': 776, 'n_tokens_neox': 749, 'n_words': 190}