diff --git a/src/freestylo/AlliterationAnnotation.py b/src/freestylo/AlliterationAnnotation.py index ee878aa..cf6d418 100644 --- a/src/freestylo/AlliterationAnnotation.py +++ b/src/freestylo/AlliterationAnnotation.py @@ -6,10 +6,20 @@ """ class AlliterationAnnotation: + """ This class is used to find alliterations candidates in a text. + It uses the TextObject class to store the text and its annotations. + """ + def __init__(self, text : TextObject, max_skip = 2, min_length=3, skip_tokens=[".", ",", ":", ";", "!", "?", "…", "(", ")", "[", "]", "{", "}", "„", "“", "‚", "‘:", "‘", "’"]): """ - Constructor for the AlliterationAnnotation class. - @param text: TextObject stores the text and its annotations + Parameters + ---------- + text : TextObject + The text to be analyzed. + max_skip : int, optional + min_length : int, optional + skip_tokens : list, optional + A list of tokens that should be skipped when looking for alliterations. """ self.text = text @@ -64,6 +74,14 @@ def find_candidates(self): def serialize(self) -> list: + """ + This method serializes the alliteration candidates into a list of dictionaries. + + Returns + ------- + list + A list of dictionaries containing the ids, length and character of the alliteration candidates. + """ candidates = [] for c in self.candidates: candidates.append({ @@ -74,14 +92,31 @@ def serialize(self) -> list: class AlliterationCandidate(): + """ + This class represents an alliteration candidate. + """ def __init__(self, ids, char): + """ + Parameters + ---------- + ids : list + A list of token ids that form the alliteration candidate. + char : str + The character that the candidate starts with. + """ self.ids = ids self.char = char @property def score(self): + """ + This property returns the score of the alliteration candidate. + """ return len(self.ids) @property def length(self): + """ + This property returns the length of the alliteration candidate. + """ return len(self.ids) diff --git a/src/freestylo/ChiasmusAnnotation.py b/src/freestylo/ChiasmusAnnotation.py index 7e90759..8d91866 100644 --- a/src/freestylo/ChiasmusAnnotation.py +++ b/src/freestylo/ChiasmusAnnotation.py @@ -2,17 +2,20 @@ from freestylo.Configs import get_model_path import numpy as np -""" -This class is used to find chiasmus candidates in a text. -It uses the TextObject class to store the text and its annotations. -""" class ChiasmusAnnotation: """ - Constructor for the ChiasmusAnnotation class. - @param text: TextObject stores the text and its annotations - @param window_size: int size of the window to search for chiasmus candidates + This class is used to find chiasmus candidates in a text. + It uses the TextObject class to store the text and its annotations. """ def __init__(self, text : TextObject, window_size=30): + """ + Parameters + ---------- + text : TextObject + The text to be analyzed. + window_size : int, optional + The window size to search for chiasmus candidates + """ self.text = text text.annotations.append(self) self.window_size = window_size @@ -26,11 +29,11 @@ def __init__(self, text : TextObject, window_size=30): self.model = None - """ - This method finds chiasmus candidates in the text. - It uses the window_size to search for candidates. - """ def find_candidates(self): + """ + This method finds chiasmus candidates in the text. + It uses the window_size to search for candidates. + """ pos = self.text.pos outer_matches = [] @@ -45,11 +48,26 @@ def find_candidates(self): self.candidates.append(ChiasmusCandidate(A, B, B_, A_)) def load_classification_model(self, model_path): + """ + This method loads a classification model to score the chiasmus candidates. + Parameters + ---------- + model_path : str + The path to the model file. + """ import pickle with open(get_model_path(model_path), "rb") as f: self.model = pickle.load(f) def serialize(self) -> list: + """ + This method serializes the chiasmus candidates. + + Returns + ------- + list + A list of serialized candidates. + """ candidates = [] for c in self.candidates: candidates.append({ @@ -64,14 +82,18 @@ def serialize(self) -> list: - """ - This method finds matches in the pos list of the text. - It uses the start and end index to search for matches. - @param start: int start index of the search - @param end: int end index of the search - @return list of matches - """ def _find_matches(self, start : int, end : int) -> list: + """ + This method finds matches in the pos list of the text. + It uses the start and end index to search for matches. + + Parameters + ---------- + start : int + The start index of the search. + end : int + The end index of the search. + """ pos = self.text.pos #if end > len(pos): @@ -91,29 +113,31 @@ def _find_matches(self, start : int, end : int) -> list: pass return matches - """ - This method checks if a pos is in the allowlist or not in the denylist. - @param pos: str pos to check - @return bool True if pos is in allowlist or not in denylist, False otherwise - """ def _check_pos(self, pos): + """ + This method checks if a pos is in the allowlist or not in the denylist. + + Parameters + ---------- + pos : str + The pos to check. + """ if len(self.allowlist) > 0 and pos not in self.allowlist: return False if len(self.denylist) > 0 and pos in self.denylist: return False return True - """ - This method checks if the text has chiasmus candidates. - @return bool True if there are candidates, False otherwise - """ def has_candidates(self): + """ + This method checks if the text has chiasmus candidates. + """ return len(self.candidates) > 0 - """ - This method scores the chiasmus candidates. - """ def score_candidates(self): + """ + This method scores the chiasmus candidates. + """ features = [] for candidate in self.candidates: features.append(self.get_features(candidate)) @@ -126,22 +150,35 @@ def score_candidates(self): candidate.score = score return True - """ - This method ranks a chiasmus candidate. - @param candidate: ChiasmusCandidate candidate to rank - """ - def score_candidate(self, candidate): + def get_features(self, candidate): + """ + This method extracts features for a chiasmus candidate. - features = get_features(candidate) + Parameters + ---------- + candidate : ChiasmusCandidate + The candidate to extract features from. + + Returns + ------- + np.array + An array of features. + """ - def get_features(self, candidate): dubremetz_features = self.get_dubremetz_features(candidate) lexical_features = self.get_lexical_features(candidate) semantic_features = self.get_semantic_features(candidate) return np.concatenate((dubremetz_features, lexical_features, semantic_features)) def get_dubremetz_features(self, candidate): - + """ + This method extracts Dubremetz features for a chiasmus candidate. + + Returns + ------- + np.array + An array of Dubremetz features + """ tokens = self.text.tokens lemmas = self.text.lemmas pos = self.text.pos @@ -311,6 +348,14 @@ def get_dubremetz_features(self, candidate): return features def get_lexical_features(self, candidate): + """ + This method extracts lexical features for a chiasmus candidate. + + Returns + ------- + np.array + An array of lexical features + """ tokens = self.text.tokens lemmas = self.text.lemmas pos = self.text.pos @@ -340,6 +385,14 @@ def get_lexical_features(self, candidate): return features def get_semantic_features(self, candidate): + """ + This method extracts semantic features for a chiasmus candidate. + + Returns + ------- + np.array + An array of semantic features + """ tokens = self.text.tokens lemmas = self.text.lemmas pos = self.text.pos @@ -363,6 +416,16 @@ def get_semantic_features(self, candidate): def cosine_similarity(vec1, vec2): + """ + This method calculates the cosine similarity between two vectors. + + Parameters + ---------- + vec1 : np.array + The first vector. + vec2 : np.array + The second vector. + """ result = np.dot(vec1, vec2) / (np.linalg.norm(vec1) * np.linalg.norm(vec2)) if np.isnan(result): result = 0 @@ -370,7 +433,23 @@ def cosine_similarity(vec1, vec2): class ChiasmusCandidate: + """ + This class represents a chiasmus candidate. + """ def __init__(self, A, B, B_, A_): + """ + Parameters + ---------- + A : int + Index of the first supporting word + B : int + Index of the second supporting word + B_ : int + Index of the third supporting word, paired with B + A_ : int + Index of the fourth supporting word, paired with A + """ + self.ids = [A, B, B_, A_] self.A = A self.B = B @@ -379,6 +458,9 @@ def __init__(self, A, B, B_, A_): self.score = None def __str__(self): + """ + This method returns a string representation of the chiasmus candidate. + """ return f"{self.A} {self.B} {self.B_} {self.A_}" diff --git a/src/freestylo/EpiphoraAnnotation.py b/src/freestylo/EpiphoraAnnotation.py index 930143d..9ae62a1 100644 --- a/src/freestylo/EpiphoraAnnotation.py +++ b/src/freestylo/EpiphoraAnnotation.py @@ -1,16 +1,26 @@ from freestylo.TextObject import TextObject -""" -this class is used to find polysyndeton candidates in a text. -it uses the textobject class to store the text and its annotations. -""" class EpiphoraAnnotation: + """ + This class is used to find epiphora candidates in a text. + It uses the TextObject class to store the text and its annotations. + """ def __init__(self, text : TextObject, min_length=2, conj = ["and", "or", "but", "nor"], punct_pos="PUNCT"): """ Constructor for the EpiphoraAnnotation class. - @param text: TextObject stores the text and its annotations + + Parameters + ---------- + text : TextObject + The text to be analyzed. + min_length : int, optional + The minimum length of the epiphora candidates. + conj : list, optional + A list of conjunctions that should be considered when looking for epiphora. + punct_pos : str, optional + The part of speech tag for punctuation. """ self.text = text @@ -22,6 +32,11 @@ def __init__(self, text : TextObject, min_length=2, conj = ["and", "or", "but", def split_in_phrases(self): """ This method splits the text into phrases. + + Returns + ------- + list + A list of lists, each containing the start and end index of a phrase. """ phrases = [] @@ -53,6 +68,14 @@ def find_candidates(self): self.candidates = candidates def serialize(self) -> list: + """ + This method serializes the epiphora candidates. + + Returns + ------- + list + A list of dictionaries, each containing the ids, length, and word of an epiphora candidate. + """ candidates = [] for c in self.candidates: candidates.append({ @@ -63,10 +86,26 @@ def serialize(self) -> list: class EpiphoraCandidate(): + """ + This class represents an epiphora candidate. + """ def __init__(self, ids, word): + """ + Constructor for the EpiphoraCandidate class. + + Parameters + ---------- + ids : list + A list of token ids that form the candidate. + word : str + The word that the candidate ends with. + """ self.ids = ids self.word = word @property def score(self): + """ + This property returns the score of the candidate. + """ return len(self.ids) diff --git a/src/freestylo/MGHPreprocessor.py b/src/freestylo/MGHPreprocessor.py index 643779d..f905b1a 100644 --- a/src/freestylo/MGHPreprocessor.py +++ b/src/freestylo/MGHPreprocessor.py @@ -6,14 +6,34 @@ from cltk.lemmatize.middle_high_german.backoff import BackoffMHGLemmatizer +# TODO: add vector representation class MGHPreprocessor: + """ + This class preprocesses Middle High German text. + """ def __init__(self): + """ + Constructor for the MGHPreprocessor class. + """ self.text = "" pass # make class callable with () def __call__(self, text): + """ + This method preprocesses Middle High German text. + + Parameters + ---------- + text : str + The text to be preprocessed. + + Returns + ------- + list + A list of MGH tokens. + """ self.text = normalize_middle_high_german(text) tokens = [] @@ -44,6 +64,23 @@ def __call__(self, text): def get_next_word(self, text, idx): + """ + This method finds the next word in a text. + + Parameters + ---------- + text : list[str] + The text to be searched. + idx : int + The index of the current word. + + Returns + ------- + str + The next word in the text. + int + The index of the next word. + """ cursor = idx is_end = False #find end of current word @@ -78,7 +115,28 @@ def get_next_word(self, text, idx): return word, next_word class MGHToken: + """ + This class represents a Middle High German token. + """ def __init__(self, text, pos, lemma, dep, vector, idx): + """ + Constructor for the MGHToken class. + + Parameters + ---------- + text : str + The text of the token. + pos : str + The part of speech of the token. + lemma : str + The lemma of the token. + dep : str + The dependency of the token. + vector : np.array + The vector representation of the token. + idx : int + The index of the token in the text. + """ self.text = text self.pos = pos self.lemma = lemma diff --git a/src/freestylo/MetaphorAnnotation.py b/src/freestylo/MetaphorAnnotation.py index 84bc9ec..35a891c 100644 --- a/src/freestylo/MetaphorAnnotation.py +++ b/src/freestylo/MetaphorAnnotation.py @@ -5,10 +5,21 @@ from freestylo.Configs import get_model_path -# TODO: automatically select cuda device class MetaphorAnnotation: + """ + This class is used to find metaphor candidates in a text. + It uses the TextObject class to store the text and its annotations. + """ def __init__(self, text): + """ + Constructor for the MetaphorAnnotation class. + + Parameters + ---------- + text : TextObject + The text to be analyzed. + """ self.text = text text.annotations.append(self) self.candidates = [] @@ -17,12 +28,23 @@ def __init__(self, text): self.model = None def find_candidates(self): + """ + This method finds metaphor candidates in the text. + """ pos = self.text.pos for i in range(len(pos)-1): if pos[i] == "ADJ" and pos[i+1] == "NOUN": self.candidates.append(MetaphorCandidate(i, i+1)) def serialize(self) -> list: + """ + This method serializes the metaphor candidates. + + Returns + ------- + list + A list of dictionaries, each containing the ids of the adjective and noun, the adjective, the noun, and the score. + """ candidates = [] for c in self.candidates: candidates.append({ @@ -34,6 +56,14 @@ def serialize(self) -> list: def load_model(self, model_path): + """ + This method loads a model for metaphor detection. + + Parameters + ---------- + model_path : str + The path to the model. + """ model_path = get_model_path(model_path) self.model = SimilarityNN.SimilarityNN(300, 128, 1, 128, self.device) self.model.load_state_dict(torch.load(model_path, weights_only=True, map_location=self.device)) @@ -41,6 +71,16 @@ def load_model(self, model_path): self.model.eval() def get_vectors(self): + """ + This method returns the vectors of the adjective and noun candidates. + + Returns + ------- + np.array + An array of adjective vectors. + np.array + An array of noun vectors. + """ adj_vectors = [] noun_vectors = [] for candidate in self.candidates: @@ -52,6 +92,9 @@ def get_vectors(self): return adj_vectors, noun_vectors def score_candidates(self): + """ + This method scores the metaphor candidates. + """ adj_vectors, noun_vectors = self.get_vectors() adj_tensor = torch.tensor(adj_vectors, device=self.device).to(self.device) noun_tensor = torch.tensor(noun_vectors, device=self.device).to(self.device) @@ -64,10 +107,38 @@ def score_candidates(self): candidate.score = score.item() def cosine_distance(a, b): + """ + This function calculates the cosine distance between two vectors. + + Parameters + ---------- + a : torch.Tensor + The first vector. + b : torch.Tensor + The second vector. + + Returns + ------- + float + The cosine distance between the two vectors. + """ return 1 - torch.nn.functional.cosine_similarity(a, b) class MetaphorCandidate(): + """ + This class represents a metaphor candidate. + """ def __init__(self, adj_id, noun_id): + """ + Constructor for the MetaphorCandidate class. + + Parameters + ---------- + adj_id : int + The id of the adjective. + noun_id : int + The id of the noun. + """ self.ids = [adj_id, noun_id] self.noun_id = noun_id self.adj_id = adj_id diff --git a/src/freestylo/PolysyndetonAnnotation.py b/src/freestylo/PolysyndetonAnnotation.py index b6969d8..56ea244 100644 --- a/src/freestylo/PolysyndetonAnnotation.py +++ b/src/freestylo/PolysyndetonAnnotation.py @@ -1,16 +1,28 @@ from freestylo.TextObject import TextObject -""" -this class is used to find polysyndeton candidates in a text. -it uses the textobject class to store the text and its annotations. -""" class PolysyndetonAnnotation: + """ + This class is used to find polysyndeton candidates in a text. + It uses the TextObject class to store the text and its annotations. + """ def __init__(self, text : TextObject, min_length=2, conj = ["and", "or", "but", "nor"], sentence_end_tokens=[".", "?", "!", ":", ";", "..."], punct_pos="PUNCT"): """ Constructor for the PolysyndetonAnnotation class. - @param text: TextObject stores the text and its annotations + + Parameters + ---------- + text : TextObject + The text to be analyzed. + min_length : int, optional + The minimum length of the polysyndeton candidates. + conj : list, optional + A list of conjunctions that should be considered when looking for polysyndeton. + sentence_end_tokens : list, optional + A list of tokens that indicate the end of a sentence. + punct_pos : str, optional + The part of speech tag for punctuation. """ self.text = text @@ -23,6 +35,11 @@ def __init__(self, text : TextObject, min_length=2, conj = ["and", "or", "but", def split_in_phrases(self): """ This method splits the text into phrases. + + Returns + ------- + list + A list of lists, each containing the start and end index of a phrase. """ phrases_in_sentences = [] @@ -44,6 +61,11 @@ def split_in_phrases(self): def check_add_candidate(self, candidates, candidate): """ This method checks if the candidate is long enough to be a polysyndeton candidate. + + Parameters + ---------- + candidates : list + A list of polysyndeton candidates. """ if len(candidate.ids) >= self.min_length: candidates.append(candidate) @@ -76,6 +98,14 @@ def find_candidates(self): def serialize(self) -> list: + """ + This method serializes the polysyndeton candidates. + + Returns + ------- + list + A list of dictionaries, each containing the ids, word, and score of a polysyndeton candidate. + """ candidates = [] for c in self.candidates: candidates.append({ @@ -86,10 +116,26 @@ def serialize(self) -> list: class PolysyndetonCandidate(): + """ + This class represents a polysyndeton candidate. + """ def __init__(self, ids, word): + """ + Constructor for the PolysyndetonCandidate class. + + Parameters + ---------- + ids : list + A list of token ids that form the candidate. + word : str + The word that the candidate ends with. + """ self.ids = ids self.word = word @property def score(self): + """ + This property returns the score of the polysyndeton candidate. + """ return len(self.ids) diff --git a/src/freestylo/SimilarityNN.py b/src/freestylo/SimilarityNN.py index a08b50c..82c7bf3 100644 --- a/src/freestylo/SimilarityNN.py +++ b/src/freestylo/SimilarityNN.py @@ -1,6 +1,25 @@ import torch.nn as nn class SimilarityNN(nn.Module): + """ + This class defines a neural network for metaphor detection. + """ def __init__(self, input_dim, hidden_dim, num_hidden, output_dim, device): + """ + Constructor for the SimilarityNN class. + + Parameters + ---------- + input_dim : int + The dimension of the input. + hidden_dim : int + The dimension of the hidden layers. + num_hidden : int + The number of hidden layers. + output_dim : int + The dimension of the output. + device : str + The device to run the model on. + """ super(SimilarityNN, self).__init__() self.hidden_dim = hidden_dim self.num_hidden = num_hidden @@ -14,6 +33,19 @@ def __init__(self, input_dim, hidden_dim, num_hidden, output_dim, device): def forward(self, data): + """ + This method defines the forward pass of the neural network. + + Parameters + ---------- + data : tensor + The input data. + + Returns + ------- + tensor + The output of the neural network. + """ intermediate = [nn.ReLU()(self.input_layer(data))] for i in range(self.num_hidden): intermediate.append(nn.ReLU()(self.hidden_layers[i](intermediate[i]))) diff --git a/src/freestylo/TextObject.py b/src/freestylo/TextObject.py index d65e31f..4a95367 100644 --- a/src/freestylo/TextObject.py +++ b/src/freestylo/TextObject.py @@ -2,7 +2,22 @@ import json class TextObject: + """ + This class is used to store a text and its annotations. + """ def __init__(self, textfile=None, text=None, language=''): + """ + Constructor for the TextObject class. + + Parameters + ---------- + textfile : str, optional + The path to a text file. + text : str, optional + + language : str, optional + The language of the text. + """ self.textfile = textfile self.language = language self.tokens = [] @@ -24,10 +39,24 @@ def __init__(self, textfile=None, text=None, language=''): self.text = text def save_as(self, filename): + """ + This method saves the TextObject as a pickle file. + + Parameters + ---------- + filename : str + """ with open(filename, 'wb') as f: pickle.dump(self, f) def serialize(self, filename): + """ + This method serializes the TextObject as a JSON file. + + Parameters + ---------- + filename : str + """ with open(filename, 'w') as f: annotations = {} for anno in self.annotations: @@ -46,22 +75,43 @@ def serialize(self, filename): def has_text(self): + """ + This method checks if the TextObject has a text. + """ return len(self.text) > 0 def has_tokens(self): + """ + This method checks if the TextObject has tokens. + """ return len(self.tokens) > 0 def has_pos(self): + """ + This method checks if the TextObject has part-of-speech tags. + """ return len(self.pos) > 0 def has_lemmas(self): + """ + This method checks if the TextObject has lemmas. + """ return len(self.lemmas) > 0 def has_dep(self): + """ + This method checks if the TextObject has dependency relations. + """ return len(self.dep) > 0 def has_vectors(self): + """ + This method checks if the TextObject has vectors. + """ return len(self.vectors) > 0 def has_annotations(self): + """ + This method checks if the TextObject has annotations. + """ return len(self.annotations) > 0 diff --git a/src/freestylo/TextPreprocessor.py b/src/freestylo/TextPreprocessor.py index 8fcc605..eaa73aa 100644 --- a/src/freestylo/TextPreprocessor.py +++ b/src/freestylo/TextPreprocessor.py @@ -2,16 +2,21 @@ from freestylo.TextObject import TextObject from freestylo.MGHPreprocessor import MGHPreprocessor -""" -This class is used to preprocess text. -It uses the TextObject class to store the text and its annotations. -""" class TextPreprocessor: """ - Constructor for the TextPreprocessor class. - @param language: str language of the text + This class is used to preprocess text. + It uses the TextObject class to store the text and its annotations. """ def __init__(self, language='en'): + """ + Constructor for the TextPreprocessor class. + + Parameters + ---------- + language : str, optional + The language of the text. + """ + if language == 'en': self.nlp = self.load_spacy_nlp('en_core_web_lg') elif language == 'de': @@ -22,6 +27,19 @@ def __init__(self, language='en'): def load_spacy_nlp(self, model_name): + """ + This method loads a spaCy model. + + Parameters + ---------- + model_name : str + The name of the spaCy model. + + Returns + ------- + spacy.lang + The spaCy model. + """ nlp = None while nlp is None: try: @@ -35,11 +53,10 @@ def load_spacy_nlp(self, model_name): return nlp - """ - This method processes the text and stores the annotations in the TextObject. - @param text: TextObject stores the text and its annotations - """ def process_text(self, text : TextObject): + """ + This method processes a text. + """ processed = self.nlp(text.text) try: text.tokens = [token.text for token in processed] diff --git a/src/freestylo/freestylo_main.py b/src/freestylo/freestylo_main.py index a359b6d..dcf953a 100644 --- a/src/freestylo/freestylo_main.py +++ b/src/freestylo/freestylo_main.py @@ -9,6 +9,12 @@ import freestylo.TextPreprocessor as tp def main(): + """ + This is the main function of the freestylo tool. + When you run the tool from the command line, this function is called. + It reads the input text, preprocesses it, and adds the specified annotations. + The results are then serialized to a file. + """ parser = argparse.ArgumentParser(description="Stylometric analysis tool") parser.add_argument("--input", help="Input text file") parser.add_argument("--output", help="Output file") @@ -42,6 +48,9 @@ def main(): text.serialize(args.output) def add_chiasmus_annotation(text, config): + """ + This function adds chiasmus annotations to the text. + """ chiasmus = ca.ChiasmusAnnotation( text=text, window_size = config["window_size"]) @@ -52,12 +61,18 @@ def add_chiasmus_annotation(text, config): chiasmus.score_candidates() def add_metaphor_annotation(text, config): + """ + This function adds metaphor annotations to the text. + """ metaphor = ma.MetaphorAnnotation(text) metaphor.find_candidates() metaphor.load_model(config["model"]) metaphor.score_candidates() def add_epiphora_annotation(text, config): + """ + This function adds epiphora annotations to the text. + """ epiphora = ea.EpiphoraAnnotation( text = text, min_length = config["min_length"], @@ -66,6 +81,9 @@ def add_epiphora_annotation(text, config): epiphora.find_candidates() def add_polysyndeton_annotation(text, config): + """ + This function adds polysyndeton annotations to the text. + """ polysyndeton = pa.PolysyndetonAnnotation( text = text, min_length = config["min_length"], @@ -74,6 +92,9 @@ def add_polysyndeton_annotation(text, config): polysyndeton.find_candidates() def add_alliteration_annotation(text, config): + """ + This function adds alliteration annotations to the text. + """ alliteration = aa.AlliterationAnnotation( text = text, max_skip = config["max_skip"], diff --git a/src/freestylo/stylotool.egg-info/PKG-INFO b/src/freestylo/stylotool.egg-info/PKG-INFO new file mode 100644 index 0000000..3e416e7 --- /dev/null +++ b/src/freestylo/stylotool.egg-info/PKG-INFO @@ -0,0 +1,28 @@ +Metadata-Version: 2.1 +Name: stylotool +Version: 0.0.1 +Summary: A tool for stylistic device detection +Author-email: Felix Schneider +Project-URL: Homepage, https://github.com/cvjena/stylotool +Project-URL: Issues, https://github.com/cvjena/stylotool/issues +Classifier: Programming Language :: Python :: 3 +Classifier: Operating System :: OS Independent +Requires-Python: >=3.6 +Description-Content-Type: text/markdown + +# STYLOTOOL - an easy-to-use stylistic device detection tool for stylometry + +An easy-to-use package for detecting stylistic devices in text. This package is designed to be used in stylometry, the study of linguistic style. + +For those proficient in python, this package provides a collection of approaches to detect stylistic devices in text. For those less proficient in python, this package provides a simple interface to detect stylistic devices in text with simple commands and user-friendly configuration. +For an example on usage, see `example_chiasmus.sh` and the config file `example_config.json`. + +# Installation +The package is available on PyPi and can be installed using pip. +TODO: add installation instructions + +# Participation +The package is free and open-source software and contributions are very welcome. +It is designed to be a living project that is constantly improved and extended. +If you have implemented your own stylistic device detector, please consider contributing it to the package. +Also, if you have any suggestions for improvements or if you find any bugs, please open an issue on the GitHub page. diff --git a/src/freestylo/stylotool.egg-info/SOURCES.txt b/src/freestylo/stylotool.egg-info/SOURCES.txt new file mode 100644 index 0000000..c17391c --- /dev/null +++ b/src/freestylo/stylotool.egg-info/SOURCES.txt @@ -0,0 +1,23 @@ +README.md +pyproject.toml +src/AlliterationAnnotation.py +src/ChiasmusAnnotation.py +src/EpiphoraAnnotation.py +src/MGHPreprocessor.py +src/MetaphorAnnotation.py +src/PolysyndetonAnnotation.py +src/SimilarityNN.py +src/TextObject.py +src/TextPreprocessor.py +src/stylotool.py +src/test_alliteration_annotation.py +src/test_chiasmus_annotation.py +src/test_metaphor_annotations.py +src/test_polysyndeton_annotation.py +src/test_text_object.py +src/test_tree.py +src/train_chiasmus_model.py +src/stylotool.egg-info/PKG-INFO +src/stylotool.egg-info/SOURCES.txt +src/stylotool.egg-info/dependency_links.txt +src/stylotool.egg-info/top_level.txt \ No newline at end of file diff --git a/src/freestylo/stylotool.egg-info/dependency_links.txt b/src/freestylo/stylotool.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/freestylo/stylotool.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/src/freestylo/stylotool.egg-info/top_level.txt b/src/freestylo/stylotool.egg-info/top_level.txt new file mode 100644 index 0000000..27179ed --- /dev/null +++ b/src/freestylo/stylotool.egg-info/top_level.txt @@ -0,0 +1,18 @@ +AlliterationAnnotation +ChiasmusAnnotation +EpiphoraAnnotation +MGHPreprocessor +MetaphorAnnotation +PolysyndetonAnnotation +SimilarityNN +TextObject +TextPreprocessor +stylotool +test +test_alliteration_annotation +test_chiasmus_annotation +test_metaphor_annotations +test_polysyndeton_annotation +test_text_object +test_tree +train_chiasmus_model