repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
bcbnz/pylabels
labels/sheet.py
Sheet._shade_missing_label
def _shade_missing_label(self): """Helper method to shade a missing label. Not intended for external use. """ # Start a drawing for the whole label. label = Drawing(float(self._lw), float(self._lh)) label.add(self._clip_label) # Fill with a rectangle; the clipping path ...
python
def _shade_missing_label(self): """Helper method to shade a missing label. Not intended for external use. """ # Start a drawing for the whole label. label = Drawing(float(self._lw), float(self._lh)) label.add(self._clip_label) # Fill with a rectangle; the clipping path ...
[ "def", "_shade_missing_label", "(", "self", ")", ":", "# Start a drawing for the whole label.", "label", "=", "Drawing", "(", "float", "(", "self", ".", "_lw", ")", ",", "float", "(", "self", ".", "_lh", ")", ")", "label", ".", "add", "(", "self", ".", "...
Helper method to shade a missing label. Not intended for external use.
[ "Helper", "method", "to", "shade", "a", "missing", "label", ".", "Not", "intended", "for", "external", "use", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L328-L344
bcbnz/pylabels
labels/sheet.py
Sheet._shade_remaining_missing
def _shade_remaining_missing(self): """Helper method to shade any missing labels remaining on the current page. Not intended for external use. Note that this will modify the internal _position attribute and should therefore only be used once all the 'real' labels have been drawn. ...
python
def _shade_remaining_missing(self): """Helper method to shade any missing labels remaining on the current page. Not intended for external use. Note that this will modify the internal _position attribute and should therefore only be used once all the 'real' labels have been drawn. ...
[ "def", "_shade_remaining_missing", "(", "self", ")", ":", "# Sanity check.", "if", "not", "self", ".", "shade_missing", ":", "return", "# Run through each missing label left in the current page and shade it.", "missing", "=", "self", ".", "_used", ".", "get", "(", "self...
Helper method to shade any missing labels remaining on the current page. Not intended for external use. Note that this will modify the internal _position attribute and should therefore only be used once all the 'real' labels have been drawn.
[ "Helper", "method", "to", "shade", "any", "missing", "labels", "remaining", "on", "the", "current", "page", ".", "Not", "intended", "for", "external", "use", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L346-L362
bcbnz/pylabels
labels/sheet.py
Sheet._draw_label
def _draw_label(self, obj, count): """Helper method to draw on the current label. Not intended for external use. """ # Start a drawing for the whole label. label = Drawing(float(self._lw), float(self._lh)) label.add(self._clip_label) # And one for the available area (i....
python
def _draw_label(self, obj, count): """Helper method to draw on the current label. Not intended for external use. """ # Start a drawing for the whole label. label = Drawing(float(self._lw), float(self._lh)) label.add(self._clip_label) # And one for the available area (i....
[ "def", "_draw_label", "(", "self", ",", "obj", ",", "count", ")", ":", "# Start a drawing for the whole label.", "label", "=", "Drawing", "(", "float", "(", "self", ".", "_lw", ")", ",", "float", "(", "self", ".", "_lh", ")", ")", "label", ".", "add", ...
Helper method to draw on the current label. Not intended for external use.
[ "Helper", "method", "to", "draw", "on", "the", "current", "label", ".", "Not", "intended", "for", "external", "use", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L364-L400
bcbnz/pylabels
labels/sheet.py
Sheet.add_labels
def add_labels(self, objects, count=1): """Add multiple labels to the sheet. Parameters ---------- objects: iterable An iterable of the objects to add. Each of these will be passed to the add_label method. Note that if this is a generator it will be c...
python
def add_labels(self, objects, count=1): """Add multiple labels to the sheet. Parameters ---------- objects: iterable An iterable of the objects to add. Each of these will be passed to the add_label method. Note that if this is a generator it will be c...
[ "def", "add_labels", "(", "self", ",", "objects", ",", "count", "=", "1", ")", ":", "# If we can convert it to an int, do so and use the itertools.repeat()", "# method to create an infinite iterator from it. Otherwise, assume it", "# is an iterable or sequence.", "try", ":", "count...
Add multiple labels to the sheet. Parameters ---------- objects: iterable An iterable of the objects to add. Each of these will be passed to the add_label method. Note that if this is a generator it will be consumed. count: positive integer or iterabl...
[ "Add", "multiple", "labels", "to", "the", "sheet", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L419-L468
bcbnz/pylabels
labels/sheet.py
Sheet.save
def save(self, filelike): """Save the file as a PDF. Parameters ---------- filelike: path or file-like object The filename or file-like object to save the labels under. Any existing contents will be overwritten. """ # Shade any remaining missing ...
python
def save(self, filelike): """Save the file as a PDF. Parameters ---------- filelike: path or file-like object The filename or file-like object to save the labels under. Any existing contents will be overwritten. """ # Shade any remaining missing ...
[ "def", "save", "(", "self", ",", "filelike", ")", ":", "# Shade any remaining missing labels if desired.", "self", ".", "_shade_remaining_missing", "(", ")", "# Create a canvas.", "canvas", "=", "Canvas", "(", "filelike", ",", "pagesize", "=", "self", ".", "_pagesiz...
Save the file as a PDF. Parameters ---------- filelike: path or file-like object The filename or file-like object to save the labels under. Any existing contents will be overwritten.
[ "Save", "the", "file", "as", "a", "PDF", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L470-L492
bcbnz/pylabels
labels/sheet.py
Sheet.preview
def preview(self, page, filelike, format='png', dpi=72, background_colour=0xFFFFFF): """Render a preview image of a page. Parameters ---------- page: positive integer Which page to render. Must be in the range [1, page_count] filelike: path or file-like object ...
python
def preview(self, page, filelike, format='png', dpi=72, background_colour=0xFFFFFF): """Render a preview image of a page. Parameters ---------- page: positive integer Which page to render. Must be in the range [1, page_count] filelike: path or file-like object ...
[ "def", "preview", "(", "self", ",", "page", ",", "filelike", ",", "format", "=", "'png'", ",", "dpi", "=", "72", ",", "background_colour", "=", "0xFFFFFF", ")", ":", "# Check the page number.", "if", "page", "<", "1", "or", "page", ">", "self", ".", "p...
Render a preview image of a page. Parameters ---------- page: positive integer Which page to render. Must be in the range [1, page_count] filelike: path or file-like object Can be a filename as a string, a Python file object, or something which behave...
[ "Render", "a", "preview", "image", "of", "a", "page", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L494-L553
bcbnz/pylabels
labels/sheet.py
Sheet.preview_string
def preview_string(self, page, format='png', dpi=72, background_colour=0xFFFFFF): """Render a preview image of a page as a string. Parameters ---------- page: positive integer Which page to render. Must be in the range [1, page_count] format: string The i...
python
def preview_string(self, page, format='png', dpi=72, background_colour=0xFFFFFF): """Render a preview image of a page as a string. Parameters ---------- page: positive integer Which page to render. Must be in the range [1, page_count] format: string The i...
[ "def", "preview_string", "(", "self", ",", "page", ",", "format", "=", "'png'", ",", "dpi", "=", "72", ",", "background_colour", "=", "0xFFFFFF", ")", ":", "# Check the page number.", "if", "page", "<", "1", "or", "page", ">", "self", ".", "page_count", ...
Render a preview image of a page as a string. Parameters ---------- page: positive integer Which page to render. Must be in the range [1, page_count] format: string The image format to use for the preview. ReportLab uses the Python Imaging Library (PI...
[ "Render", "a", "preview", "image", "of", "a", "page", "as", "a", "string", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L555-L610
bcbnz/pylabels
labels/specifications.py
Specification._calculate
def _calculate(self): """Checks the dimensions of the sheet are valid and consistent. NB: this is called internally when needed; there should be no need for user code to call it. """ # Check the dimensions are larger than zero. for dimension in ('_sheet_width', '_sheet_...
python
def _calculate(self): """Checks the dimensions of the sheet are valid and consistent. NB: this is called internally when needed; there should be no need for user code to call it. """ # Check the dimensions are larger than zero. for dimension in ('_sheet_width', '_sheet_...
[ "def", "_calculate", "(", "self", ")", ":", "# Check the dimensions are larger than zero.", "for", "dimension", "in", "(", "'_sheet_width'", ",", "'_sheet_height'", ",", "'_columns'", ",", "'_rows'", ",", "'_label_width'", ",", "'_label_height'", ")", ":", "if", "ge...
Checks the dimensions of the sheet are valid and consistent. NB: this is called internally when needed; there should be no need for user code to call it.
[ "Checks", "the", "dimensions", "of", "the", "sheet", "are", "valid", "and", "consistent", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/specifications.py#L135-L255
bcbnz/pylabels
labels/specifications.py
Specification.bounding_boxes
def bounding_boxes(self, mode='fraction', output='dict'): """Get the bounding boxes of the labels on a page. Parameters ---------- mode: 'fraction', 'actual' If 'fraction', the bounding boxes are expressed as a fraction of the height and width of the sheet. If 'a...
python
def bounding_boxes(self, mode='fraction', output='dict'): """Get the bounding boxes of the labels on a page. Parameters ---------- mode: 'fraction', 'actual' If 'fraction', the bounding boxes are expressed as a fraction of the height and width of the sheet. If 'a...
[ "def", "bounding_boxes", "(", "self", ",", "mode", "=", "'fraction'", ",", "output", "=", "'dict'", ")", ":", "boxes", "=", "{", "}", "# Check the parameters.", "if", "mode", "not", "in", "(", "'fraction'", ",", "'actual'", ")", ":", "raise", "ValueError",...
Get the bounding boxes of the labels on a page. Parameters ---------- mode: 'fraction', 'actual' If 'fraction', the bounding boxes are expressed as a fraction of the height and width of the sheet. If 'actual', they are the actual position of the labels in mil...
[ "Get", "the", "bounding", "boxes", "of", "the", "labels", "on", "a", "page", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/specifications.py#L257-L325
estnltk/estnltk
estnltk/wiki/parser.py
templatesCollector
def templatesCollector(text, open, close): """leaves related articles and wikitables in place""" others = [] spans = [i for i in findBalanced(text, open, close)] spanscopy = copy(spans) for i in range(len(spans)): start, end = spans[i] o = text[start:end] ol = o.lower() ...
python
def templatesCollector(text, open, close): """leaves related articles and wikitables in place""" others = [] spans = [i for i in findBalanced(text, open, close)] spanscopy = copy(spans) for i in range(len(spans)): start, end = spans[i] o = text[start:end] ol = o.lower() ...
[ "def", "templatesCollector", "(", "text", ",", "open", ",", "close", ")", ":", "others", "=", "[", "]", "spans", "=", "[", "i", "for", "i", "in", "findBalanced", "(", "text", ",", "open", ",", "close", ")", "]", "spanscopy", "=", "copy", "(", "span...
leaves related articles and wikitables in place
[ "leaves", "related", "articles", "and", "wikitables", "in", "place" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/parser.py#L66-L82
estnltk/estnltk
estnltk/prettyprinter/prettyprinter.py
assert_legal_arguments
def assert_legal_arguments(kwargs): """Assert that PrettyPrinter arguments are correct. Raises ------ ValueError In case there are unknown arguments or a single layer is mapped to more than one aesthetic. """ seen_layers = set() for k, v in kwargs.items(): if k not in LEGAL_...
python
def assert_legal_arguments(kwargs): """Assert that PrettyPrinter arguments are correct. Raises ------ ValueError In case there are unknown arguments or a single layer is mapped to more than one aesthetic. """ seen_layers = set() for k, v in kwargs.items(): if k not in LEGAL_...
[ "def", "assert_legal_arguments", "(", "kwargs", ")", ":", "seen_layers", "=", "set", "(", ")", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k", "not", "in", "LEGAL_ARGUMENTS", ":", "raise", "ValueError", "(", "'Illegal argume...
Assert that PrettyPrinter arguments are correct. Raises ------ ValueError In case there are unknown arguments or a single layer is mapped to more than one aesthetic.
[ "Assert", "that", "PrettyPrinter", "arguments", "are", "correct", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/prettyprinter.py#L17-L41
estnltk/estnltk
estnltk/prettyprinter/prettyprinter.py
parse_arguments
def parse_arguments(kwargs): """Function that parses PrettyPrinter arguments. Detects which aesthetics are mapped to which layers and collects user-provided values. Parameters ---------- kwargs: dict The keyword arguments to PrettyPrinter. Returns ------- dict, dict ...
python
def parse_arguments(kwargs): """Function that parses PrettyPrinter arguments. Detects which aesthetics are mapped to which layers and collects user-provided values. Parameters ---------- kwargs: dict The keyword arguments to PrettyPrinter. Returns ------- dict, dict ...
[ "def", "parse_arguments", "(", "kwargs", ")", ":", "aesthetics", "=", "{", "}", "values", "=", "{", "}", "for", "aes", "in", "AESTHETICS", ":", "if", "aes", "in", "kwargs", ":", "aesthetics", "[", "aes", "]", "=", "kwargs", "[", "aes", "]", "val_name...
Function that parses PrettyPrinter arguments. Detects which aesthetics are mapped to which layers and collects user-provided values. Parameters ---------- kwargs: dict The keyword arguments to PrettyPrinter. Returns ------- dict, dict First dictionary is aesthetic to la...
[ "Function", "that", "parses", "PrettyPrinter", "arguments", ".", "Detects", "which", "aesthetics", "are", "mapped", "to", "which", "layers", "and", "collects", "user", "-", "provided", "values", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/prettyprinter.py#L44-L68
estnltk/estnltk
estnltk/prettyprinter/prettyprinter.py
PrettyPrinter.css
def css(self): """Returns ------- str The CSS. """ css_list = [DEFAULT_MARK_CSS] for aes in self.aesthetics: css_list.extend(get_mark_css(aes, self.values[aes])) #print('\n'.join(css_list)) return '\n'.join(css_list)
python
def css(self): """Returns ------- str The CSS. """ css_list = [DEFAULT_MARK_CSS] for aes in self.aesthetics: css_list.extend(get_mark_css(aes, self.values[aes])) #print('\n'.join(css_list)) return '\n'.join(css_list)
[ "def", "css", "(", "self", ")", ":", "css_list", "=", "[", "DEFAULT_MARK_CSS", "]", "for", "aes", "in", "self", ".", "aesthetics", ":", "css_list", ".", "extend", "(", "get_mark_css", "(", "aes", ",", "self", ".", "values", "[", "aes", "]", ")", ")",...
Returns ------- str The CSS.
[ "Returns", "-------", "str", "The", "CSS", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/prettyprinter.py#L109-L119
estnltk/estnltk
estnltk/prettyprinter/prettyprinter.py
PrettyPrinter.render
def render(self, text, add_header=False): """Render the HTML. Parameters ---------- add_header: boolean (default: False) If True, add HTML5 header and footer. Returns ------- str The rendered HTML. """ html = mark_text(te...
python
def render(self, text, add_header=False): """Render the HTML. Parameters ---------- add_header: boolean (default: False) If True, add HTML5 header and footer. Returns ------- str The rendered HTML. """ html = mark_text(te...
[ "def", "render", "(", "self", ",", "text", ",", "add_header", "=", "False", ")", ":", "html", "=", "mark_text", "(", "text", ",", "self", ".", "aesthetics", ",", "self", ".", "rules", ")", "html", "=", "html", ".", "replace", "(", "'\\n'", ",", "'<...
Render the HTML. Parameters ---------- add_header: boolean (default: False) If True, add HTML5 header and footer. Returns ------- str The rendered HTML.
[ "Render", "the", "HTML", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/prettyprinter.py#L121-L140
estnltk/estnltk
estnltk/estner/crfsuiteutil.py
Trainer.train
def train(self, nerdocs, mode_filename): """Train a CRF model using given documents. Parameters ---------- nerdocs: list of estnltk.estner.ner.Document. The documents for model training. mode_filename: str The fielname where to save the model. """...
python
def train(self, nerdocs, mode_filename): """Train a CRF model using given documents. Parameters ---------- nerdocs: list of estnltk.estner.ner.Document. The documents for model training. mode_filename: str The fielname where to save the model. """...
[ "def", "train", "(", "self", ",", "nerdocs", ",", "mode_filename", ")", ":", "trainer", "=", "pycrfsuite", ".", "Trainer", "(", "algorithm", "=", "self", ".", "algorithm", ",", "params", "=", "{", "'c2'", ":", "self", ".", "c2", "}", ",", "verbose", ...
Train a CRF model using given documents. Parameters ---------- nerdocs: list of estnltk.estner.ner.Document. The documents for model training. mode_filename: str The fielname where to save the model.
[ "Train", "a", "CRF", "model", "using", "given", "documents", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/estner/crfsuiteutil.py#L28-L49
estnltk/estnltk
estnltk/estner/crfsuiteutil.py
Tagger.tag
def tag(self, nerdoc): """Tag the given document. Parameters ---------- nerdoc: estnltk.estner.Document The document to be tagged. Returns ------- labels: list of lists of str Predicted token Labels for each sentence in the document ...
python
def tag(self, nerdoc): """Tag the given document. Parameters ---------- nerdoc: estnltk.estner.Document The document to be tagged. Returns ------- labels: list of lists of str Predicted token Labels for each sentence in the document ...
[ "def", "tag", "(", "self", ",", "nerdoc", ")", ":", "labels", "=", "[", "]", "for", "snt", "in", "nerdoc", ".", "sentences", ":", "xseq", "=", "[", "t", ".", "feature_list", "(", ")", "for", "t", "in", "snt", "]", "yseq", "=", "self", ".", "tag...
Tag the given document. Parameters ---------- nerdoc: estnltk.estner.Document The document to be tagged. Returns ------- labels: list of lists of str Predicted token Labels for each sentence in the document
[ "Tag", "the", "given", "document", ".", "Parameters", "----------", "nerdoc", ":", "estnltk", ".", "estner", ".", "Document", "The", "document", "to", "be", "tagged", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/estner/crfsuiteutil.py#L69-L87
estnltk/estnltk
estnltk/wiki/wikiextra.py
balancedSlicer
def balancedSlicer(text, openDelim='[', closeDelim=']'): """ Assuming that text contains a properly balanced expression using :param openDelim: as opening delimiters and :param closeDelim: as closing delimiters. :return: text between the delimiters """ openbr = 0 cur = 0 for char in ...
python
def balancedSlicer(text, openDelim='[', closeDelim=']'): """ Assuming that text contains a properly balanced expression using :param openDelim: as opening delimiters and :param closeDelim: as closing delimiters. :return: text between the delimiters """ openbr = 0 cur = 0 for char in ...
[ "def", "balancedSlicer", "(", "text", ",", "openDelim", "=", "'['", ",", "closeDelim", "=", "']'", ")", ":", "openbr", "=", "0", "cur", "=", "0", "for", "char", "in", "text", ":", "cur", "+=", "1", "if", "char", "==", "openDelim", ":", "openbr", "+...
Assuming that text contains a properly balanced expression using :param openDelim: as opening delimiters and :param closeDelim: as closing delimiters. :return: text between the delimiters
[ "Assuming", "that", "text", "contains", "a", "properly", "balanced", "expression", "using", ":", "param", "openDelim", ":", "as", "opening", "delimiters", "and", ":", "param", "closeDelim", ":", "as", "closing", "delimiters", ".", ":", "return", ":", "text", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/wikiextra.py#L7-L24
estnltk/estnltk
estnltk/wiki/convert.py
json_2_text
def json_2_text(inp, out, verbose = False): """Convert a Wikipedia article to Text object. Concatenates the sections in wikipedia file and rearranges other information so it can be interpreted as a Text object. Links and other elements with start and end positions are annotated as layers. Para...
python
def json_2_text(inp, out, verbose = False): """Convert a Wikipedia article to Text object. Concatenates the sections in wikipedia file and rearranges other information so it can be interpreted as a Text object. Links and other elements with start and end positions are annotated as layers. Para...
[ "def", "json_2_text", "(", "inp", ",", "out", ",", "verbose", "=", "False", ")", ":", "for", "root", ",", "dirs", ",", "filenames", "in", "os", ".", "walk", "(", "inp", ")", ":", "for", "f", "in", "filenames", ":", "log", "=", "codecs", ".", "ope...
Convert a Wikipedia article to Text object. Concatenates the sections in wikipedia file and rearranges other information so it can be interpreted as a Text object. Links and other elements with start and end positions are annotated as layers. Parameters ---------- inp: directory of parsed ...
[ "Convert", "a", "Wikipedia", "article", "to", "Text", "object", ".", "Concatenates", "the", "sections", "in", "wikipedia", "file", "and", "rearranges", "other", "information", "so", "it", "can", "be", "interpreted", "as", "a", "Text", "object", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/convert.py#L95-L126
estnltk/estnltk
estnltk/grammar/match.py
concatenate_matches
def concatenate_matches(a, b, text, name): """Concatenate matches a and b. All submatches will be copied to result.""" match = Match(a.start, b.end, text[a.start:b.end], name) for k, v in a.matches.items(): match.matches[k] = v for k, v in b.matches.items(): match.matches[k] = v ...
python
def concatenate_matches(a, b, text, name): """Concatenate matches a and b. All submatches will be copied to result.""" match = Match(a.start, b.end, text[a.start:b.end], name) for k, v in a.matches.items(): match.matches[k] = v for k, v in b.matches.items(): match.matches[k] = v ...
[ "def", "concatenate_matches", "(", "a", ",", "b", ",", "text", ",", "name", ")", ":", "match", "=", "Match", "(", "a", ".", "start", ",", "b", ".", "end", ",", "text", "[", "a", ".", "start", ":", "b", ".", "end", "]", ",", "name", ")", "for"...
Concatenate matches a and b. All submatches will be copied to result.
[ "Concatenate", "matches", "a", "and", "b", ".", "All", "submatches", "will", "be", "copied", "to", "result", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/grammar/match.py#L81-L97
estnltk/estnltk
estnltk/grammar/match.py
Match.dict
def dict(self): """Dictionary representing this match and all child symbol matches.""" res = copy(self) if MATCHES in res: del res[MATCHES] if NAME in res: del res[NAME] res = {self.name: res} for k, v in self.matches.items(): res[k] = ...
python
def dict(self): """Dictionary representing this match and all child symbol matches.""" res = copy(self) if MATCHES in res: del res[MATCHES] if NAME in res: del res[NAME] res = {self.name: res} for k, v in self.matches.items(): res[k] = ...
[ "def", "dict", "(", "self", ")", ":", "res", "=", "copy", "(", "self", ")", "if", "MATCHES", "in", "res", ":", "del", "res", "[", "MATCHES", "]", "if", "NAME", "in", "res", ":", "del", "res", "[", "NAME", "]", "res", "=", "{", "self", ".", "n...
Dictionary representing this match and all child symbol matches.
[ "Dictionary", "representing", "this", "match", "and", "all", "child", "symbol", "matches", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/grammar/match.py#L54-L66
estnltk/estnltk
estnltk/vabamorf/morf.py
regex_from_markers
def regex_from_markers(markers): """Given a string of characters, construct a regex that matches them. Parameters ---------- markers: str The list of string containing the markers Returns ------- regex The regular expression matching the given markers. """ return re...
python
def regex_from_markers(markers): """Given a string of characters, construct a regex that matches them. Parameters ---------- markers: str The list of string containing the markers Returns ------- regex The regular expression matching the given markers. """ return re...
[ "def", "regex_from_markers", "(", "markers", ")", ":", "return", "re", ".", "compile", "(", "'|'", ".", "join", "(", "[", "re", ".", "escape", "(", "c", ")", "for", "c", "in", "markers", "]", ")", ")" ]
Given a string of characters, construct a regex that matches them. Parameters ---------- markers: str The list of string containing the markers Returns ------- regex The regular expression matching the given markers.
[ "Given", "a", "string", "of", "characters", "construct", "a", "regex", "that", "matches", "them", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L45-L58
estnltk/estnltk
estnltk/vabamorf/morf.py
convert
def convert(word): """This method converts given `word` to UTF-8 encoding and `bytes` type for the SWIG wrapper.""" if six.PY2: if isinstance(word, unicode): return word.encode('utf-8') else: return word.decode('utf-8').encode('utf-8') # make sure it is real utf8, ...
python
def convert(word): """This method converts given `word` to UTF-8 encoding and `bytes` type for the SWIG wrapper.""" if six.PY2: if isinstance(word, unicode): return word.encode('utf-8') else: return word.decode('utf-8').encode('utf-8') # make sure it is real utf8, ...
[ "def", "convert", "(", "word", ")", ":", "if", "six", ".", "PY2", ":", "if", "isinstance", "(", "word", ",", "unicode", ")", ":", "return", "word", ".", "encode", "(", "'utf-8'", ")", "else", ":", "return", "word", ".", "decode", "(", "'utf-8'", ")...
This method converts given `word` to UTF-8 encoding and `bytes` type for the SWIG wrapper.
[ "This", "method", "converts", "given", "word", "to", "UTF", "-", "8", "encoding", "and", "bytes", "type", "for", "the", "SWIG", "wrapper", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L64-L75
estnltk/estnltk
estnltk/vabamorf/morf.py
postprocess_result
def postprocess_result(morphresult, trim_phonetic, trim_compound): """Postprocess vabamorf wrapper output.""" word, analysis = morphresult return { 'text': deconvert(word), 'analysis': [postprocess_analysis(a, trim_phonetic, trim_compound) for a in analysis] }
python
def postprocess_result(morphresult, trim_phonetic, trim_compound): """Postprocess vabamorf wrapper output.""" word, analysis = morphresult return { 'text': deconvert(word), 'analysis': [postprocess_analysis(a, trim_phonetic, trim_compound) for a in analysis] }
[ "def", "postprocess_result", "(", "morphresult", ",", "trim_phonetic", ",", "trim_compound", ")", ":", "word", ",", "analysis", "=", "morphresult", "return", "{", "'text'", ":", "deconvert", "(", "word", ")", ",", "'analysis'", ":", "[", "postprocess_analysis", ...
Postprocess vabamorf wrapper output.
[ "Postprocess", "vabamorf", "wrapper", "output", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L302-L308
estnltk/estnltk
estnltk/vabamorf/morf.py
trim_phonetics
def trim_phonetics(root): """Function that trims phonetic markup from the root. Parameters ---------- root: str The string to remove the phonetic markup. Returns ------- str The string with phonetic markup removed. """ global phonetic_markers global phonetic_reg...
python
def trim_phonetics(root): """Function that trims phonetic markup from the root. Parameters ---------- root: str The string to remove the phonetic markup. Returns ------- str The string with phonetic markup removed. """ global phonetic_markers global phonetic_reg...
[ "def", "trim_phonetics", "(", "root", ")", ":", "global", "phonetic_markers", "global", "phonetic_regex", "if", "root", "in", "phonetic_markers", ":", "return", "root", "else", ":", "return", "phonetic_regex", ".", "sub", "(", "''", ",", "root", ")" ]
Function that trims phonetic markup from the root. Parameters ---------- root: str The string to remove the phonetic markup. Returns ------- str The string with phonetic markup removed.
[ "Function", "that", "trims", "phonetic", "markup", "from", "the", "root", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L330-L348
estnltk/estnltk
estnltk/vabamorf/morf.py
get_root
def get_root(root, phonetic, compound): """Get the root form without markers. Parameters ---------- root: str The word root form. phonetic: boolean If True, add phonetic information to the root forms. compound: boolean if True, add compound word markers to root forms. ...
python
def get_root(root, phonetic, compound): """Get the root form without markers. Parameters ---------- root: str The word root form. phonetic: boolean If True, add phonetic information to the root forms. compound: boolean if True, add compound word markers to root forms. ...
[ "def", "get_root", "(", "root", ",", "phonetic", ",", "compound", ")", ":", "global", "compound_regex", "if", "not", "phonetic", ":", "root", "=", "trim_phonetics", "(", "root", ")", "if", "not", "compound", ":", "root", "=", "trim_compounds", "(", "root",...
Get the root form without markers. Parameters ---------- root: str The word root form. phonetic: boolean If True, add phonetic information to the root forms. compound: boolean if True, add compound word markers to root forms.
[ "Get", "the", "root", "form", "without", "markers", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L370-L387
estnltk/estnltk
estnltk/vabamorf/morf.py
get_group_tokens
def get_group_tokens(root): """Function to extract tokens in hyphenated groups (saunameheks-tallimeheks). Parameters ---------- root: str The root form. Returns ------- list of (list of str) List of grouped root tokens. """ global all_markers if root in all_mark...
python
def get_group_tokens(root): """Function to extract tokens in hyphenated groups (saunameheks-tallimeheks). Parameters ---------- root: str The root form. Returns ------- list of (list of str) List of grouped root tokens. """ global all_markers if root in all_mark...
[ "def", "get_group_tokens", "(", "root", ")", ":", "global", "all_markers", "if", "root", "in", "all_markers", "or", "root", "in", "[", "'-'", ",", "'_'", "]", ":", "# special case", "return", "[", "[", "root", "]", "]", "groups", "=", "[", "]", "for", ...
Function to extract tokens in hyphenated groups (saunameheks-tallimeheks). Parameters ---------- root: str The root form. Returns ------- list of (list of str) List of grouped root tokens.
[ "Function", "to", "extract", "tokens", "in", "hyphenated", "groups", "(", "saunameheks", "-", "tallimeheks", ")", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L390-L410
estnltk/estnltk
estnltk/vabamorf/morf.py
fix_spelling
def fix_spelling(words, join=True, joinstring=' '): """Simple function for quickly correcting misspelled words. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using default behaviour of string.spl...
python
def fix_spelling(words, join=True, joinstring=' '): """Simple function for quickly correcting misspelled words. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using default behaviour of string.spl...
[ "def", "fix_spelling", "(", "words", ",", "join", "=", "True", ",", "joinstring", "=", "' '", ")", ":", "return", "Vabamorf", ".", "instance", "(", ")", ".", "fix_spelling", "(", "words", ",", "join", ",", "joinstring", ")" ]
Simple function for quickly correcting misspelled words. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using default behaviour of string.split() function. join: boolean (default: True) Sh...
[ "Simple", "function", "for", "quickly", "correcting", "misspelled", "words", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L508-L528
estnltk/estnltk
estnltk/vabamorf/morf.py
synthesize
def synthesize(lemma, form, partofspeech='', hint='', guess=True, phonetic=False): """Synthesize a single word based on given morphological attributes. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ---------- lemma: ...
python
def synthesize(lemma, form, partofspeech='', hint='', guess=True, phonetic=False): """Synthesize a single word based on given morphological attributes. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ---------- lemma: ...
[ "def", "synthesize", "(", "lemma", ",", "form", ",", "partofspeech", "=", "''", ",", "hint", "=", "''", ",", "guess", "=", "True", ",", "phonetic", "=", "False", ")", ":", "return", "Vabamorf", ".", "instance", "(", ")", ".", "synthesize", "(", "lemm...
Synthesize a single word based on given morphological attributes. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ---------- lemma: str The lemma of the word(s) to be synthesized. form: str The form of ...
[ "Synthesize", "a", "single", "word", "based", "on", "given", "morphological", "attributes", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L531-L557
estnltk/estnltk
estnltk/vabamorf/morf.py
Vabamorf.instance
def instance(): """Return an PyVabamorf instance. It returns the previously initialized instance or creates a new one if nothing exists. Also creates new instance in case the process has been forked. """ if not hasattr(Vabamorf, 'pid') or Vabamorf.pid != os.getpid(): ...
python
def instance(): """Return an PyVabamorf instance. It returns the previously initialized instance or creates a new one if nothing exists. Also creates new instance in case the process has been forked. """ if not hasattr(Vabamorf, 'pid') or Vabamorf.pid != os.getpid(): ...
[ "def", "instance", "(", ")", ":", "if", "not", "hasattr", "(", "Vabamorf", ",", "'pid'", ")", "or", "Vabamorf", ".", "pid", "!=", "os", ".", "getpid", "(", ")", ":", "Vabamorf", ".", "pid", "=", "os", ".", "getpid", "(", ")", "Vabamorf", ".", "mo...
Return an PyVabamorf instance. It returns the previously initialized instance or creates a new one if nothing exists. Also creates new instance in case the process has been forked.
[ "Return", "an", "PyVabamorf", "instance", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L101-L111
estnltk/estnltk
estnltk/vabamorf/morf.py
Vabamorf.analyze
def analyze(self, words, **kwargs): """Perform morphological analysis and disambiguation of given text. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using default behavio...
python
def analyze(self, words, **kwargs): """Perform morphological analysis and disambiguation of given text. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using default behavio...
[ "def", "analyze", "(", "self", ",", "words", ",", "*", "*", "kwargs", ")", ":", "# if input is a string, then tokenize it", "if", "isinstance", "(", "words", ",", "six", ".", "string_types", ")", ":", "words", "=", "words", ".", "split", "(", ")", "# conve...
Perform morphological analysis and disambiguation of given text. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using default behaviour of string.split() function. disambig...
[ "Perform", "morphological", "analysis", "and", "disambiguation", "of", "given", "text", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L129-L169
estnltk/estnltk
estnltk/vabamorf/morf.py
Vabamorf.disambiguate
def disambiguate(self, words): """Disambiguate previously analyzed words. Parameters ---------- words: list of dict A sentence of words. Returns ------- list of dict Sentence of disambiguated words. """ words = vm.Sentence...
python
def disambiguate(self, words): """Disambiguate previously analyzed words. Parameters ---------- words: list of dict A sentence of words. Returns ------- list of dict Sentence of disambiguated words. """ words = vm.Sentence...
[ "def", "disambiguate", "(", "self", ",", "words", ")", ":", "words", "=", "vm", ".", "SentenceAnalysis", "(", "[", "as_wordanalysis", "(", "w", ")", "for", "w", "in", "words", "]", ")", "disambiguated", "=", "self", ".", "_morf", ".", "disambiguate", "...
Disambiguate previously analyzed words. Parameters ---------- words: list of dict A sentence of words. Returns ------- list of dict Sentence of disambiguated words.
[ "Disambiguate", "previously", "analyzed", "words", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L171-L186
estnltk/estnltk
estnltk/vabamorf/morf.py
Vabamorf.spellcheck
def spellcheck(self, words, suggestions=True): """Spellcheck given sentence. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ---------- words: list of str or str Either a list of pre...
python
def spellcheck(self, words, suggestions=True): """Spellcheck given sentence. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ---------- words: list of str or str Either a list of pre...
[ "def", "spellcheck", "(", "self", ",", "words", ",", "suggestions", "=", "True", ")", ":", "if", "isinstance", "(", "words", ",", "six", ".", "string_types", ")", ":", "words", "=", "words", ".", "split", "(", ")", "# convert words to native strings", "wor...
Spellcheck given sentence. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will ...
[ "Spellcheck", "given", "sentence", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L188-L226
estnltk/estnltk
estnltk/vabamorf/morf.py
Vabamorf.fix_spelling
def fix_spelling(self, words, join=True, joinstring=' '): """Simple function for quickly correcting misspelled words. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using d...
python
def fix_spelling(self, words, join=True, joinstring=' '): """Simple function for quickly correcting misspelled words. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using d...
[ "def", "fix_spelling", "(", "self", ",", "words", ",", "join", "=", "True", ",", "joinstring", "=", "' '", ")", ":", "fixed_words", "=", "[", "]", "for", "word", "in", "self", ".", "spellcheck", "(", "words", ",", "suggestions", "=", "True", ")", ":"...
Simple function for quickly correcting misspelled words. Parameters ---------- words: list of str or str Either a list of pretokenized words or a string. In case of a string, it will be splitted using default behaviour of string.split() function. join: boolean (d...
[ "Simple", "function", "for", "quickly", "correcting", "misspelled", "words", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L228-L262
estnltk/estnltk
estnltk/vabamorf/morf.py
Vabamorf.synthesize
def synthesize(self, lemma, form, partofspeech='', hint='', guess=True, phonetic=False): """Synthesize a single word based on given morphological attributes. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ...
python
def synthesize(self, lemma, form, partofspeech='', hint='', guess=True, phonetic=False): """Synthesize a single word based on given morphological attributes. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ...
[ "def", "synthesize", "(", "self", ",", "lemma", ",", "form", ",", "partofspeech", "=", "''", ",", "hint", "=", "''", ",", "guess", "=", "True", ",", "phonetic", "=", "False", ")", ":", "words", "=", "self", ".", "_morf", ".", "synthesize", "(", "co...
Synthesize a single word based on given morphological attributes. Note that spellchecker does not respect pre-tokenized words and concatenates token sequences such as "New York". Parameters ---------- lemma: str The lemma of the word(s) to be synthesized. fo...
[ "Synthesize", "a", "single", "word", "based", "on", "given", "morphological", "attributes", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L265-L299
estnltk/estnltk
estnltk/clausesegmenter.py
ClauseSegmenter.prepare_sentence
def prepare_sentence(self, sentence): """Prepare the sentence for segment detection.""" # depending on how the morphological analysis was added, there may be # phonetic markup. Remove it, if it exists. for word in sentence: for analysis in word[ANALYSIS]: anal...
python
def prepare_sentence(self, sentence): """Prepare the sentence for segment detection.""" # depending on how the morphological analysis was added, there may be # phonetic markup. Remove it, if it exists. for word in sentence: for analysis in word[ANALYSIS]: anal...
[ "def", "prepare_sentence", "(", "self", ",", "sentence", ")", ":", "# depending on how the morphological analysis was added, there may be", "# phonetic markup. Remove it, if it exists.", "for", "word", "in", "sentence", ":", "for", "analysis", "in", "word", "[", "ANALYSIS", ...
Prepare the sentence for segment detection.
[ "Prepare", "the", "sentence", "for", "segment", "detection", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/clausesegmenter.py#L53-L61
estnltk/estnltk
estnltk/clausesegmenter.py
ClauseSegmenter.annotate_indices
def annotate_indices(self, sentence): """Add clause indexes to already annotated sentence.""" max_index = 0 max_depth = 1 stack_of_indexes = [ max_index ] for token in sentence: if CLAUSE_ANNOT not in token: token[CLAUSE_IDX] = stack_of_indexes[-1] ...
python
def annotate_indices(self, sentence): """Add clause indexes to already annotated sentence.""" max_index = 0 max_depth = 1 stack_of_indexes = [ max_index ] for token in sentence: if CLAUSE_ANNOT not in token: token[CLAUSE_IDX] = stack_of_indexes[-1] ...
[ "def", "annotate_indices", "(", "self", ",", "sentence", ")", ":", "max_index", "=", "0", "max_depth", "=", "1", "stack_of_indexes", "=", "[", "max_index", "]", "for", "token", "in", "sentence", ":", "if", "CLAUSE_ANNOT", "not", "in", "token", ":", "token"...
Add clause indexes to already annotated sentence.
[ "Add", "clause", "indexes", "to", "already", "annotated", "sentence", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/clausesegmenter.py#L64-L91
estnltk/estnltk
estnltk/clausesegmenter.py
ClauseSegmenter.rename_annotations
def rename_annotations(self, sentence): """Function that renames and restructures clause information.""" annotations = [] for token in sentence: data = {CLAUSE_IDX: token[CLAUSE_IDX]} if CLAUSE_ANNOT in token: if 'KINDEL_PIIR' in token[CLAUSE_ANNOT]: ...
python
def rename_annotations(self, sentence): """Function that renames and restructures clause information.""" annotations = [] for token in sentence: data = {CLAUSE_IDX: token[CLAUSE_IDX]} if CLAUSE_ANNOT in token: if 'KINDEL_PIIR' in token[CLAUSE_ANNOT]: ...
[ "def", "rename_annotations", "(", "self", ",", "sentence", ")", ":", "annotations", "=", "[", "]", "for", "token", "in", "sentence", ":", "data", "=", "{", "CLAUSE_IDX", ":", "token", "[", "CLAUSE_IDX", "]", "}", "if", "CLAUSE_ANNOT", "in", "token", ":",...
Function that renames and restructures clause information.
[ "Function", "that", "renames", "and", "restructures", "clause", "information", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/clausesegmenter.py#L93-L106
estnltk/estnltk
estnltk/examples/split_large_koondkorpus_files.py
format_time
def format_time( sec ): ''' Re-formats time duration in seconds (*sec*) into more easily readable form, where (days,) hours, minutes, and seconds are explicitly shown. Returns the new duration as a formatted string. ''' import time if sec < 864000: # Idea from: http://stackover...
python
def format_time( sec ): ''' Re-formats time duration in seconds (*sec*) into more easily readable form, where (days,) hours, minutes, and seconds are explicitly shown. Returns the new duration as a formatted string. ''' import time if sec < 864000: # Idea from: http://stackover...
[ "def", "format_time", "(", "sec", ")", ":", "import", "time", "if", "sec", "<", "864000", ":", "# Idea from: http://stackoverflow.com/a/1384565", "return", "time", ".", "strftime", "(", "'%H:%M:%S'", ",", "time", ".", "gmtime", "(", "sec", ")", ")", "else", ...
Re-formats time duration in seconds (*sec*) into more easily readable form, where (days,) hours, minutes, and seconds are explicitly shown. Returns the new duration as a formatted string.
[ "Re", "-", "formats", "time", "duration", "in", "seconds", "(", "*", "sec", "*", ")", "into", "more", "easily", "readable", "form", "where", "(", "days", ")", "hours", "minutes", "and", "seconds", "are", "explicitly", "shown", ".", "Returns", "the", "new...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/examples/split_large_koondkorpus_files.py#L35-L47
estnltk/estnltk
estnltk/examples/split_large_koondkorpus_files.py
split_Text
def split_Text( text, file_name, verbose = True ): ''' Tokenizes the *text* (from *file_name*) into sentences, and if the number of sentences exceeds *max_sentences*, splits the text into smaller texts. Returns a list containing the original text (if no splitting was required), or a list c...
python
def split_Text( text, file_name, verbose = True ): ''' Tokenizes the *text* (from *file_name*) into sentences, and if the number of sentences exceeds *max_sentences*, splits the text into smaller texts. Returns a list containing the original text (if no splitting was required), or a list c...
[ "def", "split_Text", "(", "text", ",", "file_name", ",", "verbose", "=", "True", ")", ":", "if", "verbose", ":", "print", "(", "' processing '", "+", "file_name", "+", "' ... '", ",", "end", "=", "\"\"", ")", "# Tokenize text into sentences", "start", "=", ...
Tokenizes the *text* (from *file_name*) into sentences, and if the number of sentences exceeds *max_sentences*, splits the text into smaller texts. Returns a list containing the original text (if no splitting was required), or a list containing results of the splitting (smaller texts);
[ "Tokenizes", "the", "*", "text", "*", "(", "from", "*", "file_name", "*", ")", "into", "sentences", "and", "if", "the", "number", "of", "sentences", "exceeds", "*", "max_sentences", "*", "splits", "the", "text", "into", "smaller", "texts", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/examples/split_large_koondkorpus_files.py#L50-L103
estnltk/estnltk
estnltk/examples/split_large_koondkorpus_files.py
write_Text_into_file
def write_Text_into_file( text, old_file_name, out_dir, suffix='__split', verbose=True ): ''' Based on *old_file_name*, *suffix* and *out_dir*, constructs a new file name and writes *text* (in the ascii normalised JSON format) into the new file. ''' name = os.path.basename( old_file_name ) if ...
python
def write_Text_into_file( text, old_file_name, out_dir, suffix='__split', verbose=True ): ''' Based on *old_file_name*, *suffix* and *out_dir*, constructs a new file name and writes *text* (in the ascii normalised JSON format) into the new file. ''' name = os.path.basename( old_file_name ) if ...
[ "def", "write_Text_into_file", "(", "text", ",", "old_file_name", ",", "out_dir", ",", "suffix", "=", "'__split'", ",", "verbose", "=", "True", ")", ":", "name", "=", "os", ".", "path", ".", "basename", "(", "old_file_name", ")", "if", "'.'", "in", "name...
Based on *old_file_name*, *suffix* and *out_dir*, constructs a new file name and writes *text* (in the ascii normalised JSON format) into the new file.
[ "Based", "on", "*", "old_file_name", "*", "*", "suffix", "*", "and", "*", "out_dir", "*", "constructs", "a", "new", "file", "name", "and", "writes", "*", "text", "*", "(", "in", "the", "ascii", "normalised", "JSON", "format", ")", "into", "the", "new",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/examples/split_large_koondkorpus_files.py#L106-L124
estnltk/estnltk
estnltk/teicorpus.py
parse_tei_corpora
def parse_tei_corpora(root, prefix='', suffix='.xml', target=['artikkel'], encoding=None): """Parse documents from TEI style XML files. Gives each document FILE attribute that denotes the original filename. Parameters ---------- root: str The directory path containing the TEI corpo...
python
def parse_tei_corpora(root, prefix='', suffix='.xml', target=['artikkel'], encoding=None): """Parse documents from TEI style XML files. Gives each document FILE attribute that denotes the original filename. Parameters ---------- root: str The directory path containing the TEI corpo...
[ "def", "parse_tei_corpora", "(", "root", ",", "prefix", "=", "''", ",", "suffix", "=", "'.xml'", ",", "target", "=", "[", "'artikkel'", "]", ",", "encoding", "=", "None", ")", ":", "documents", "=", "[", "]", "for", "fnm", "in", "get_filenames", "(", ...
Parse documents from TEI style XML files. Gives each document FILE attribute that denotes the original filename. Parameters ---------- root: str The directory path containing the TEI corpora XMl files. prefix: str The prefix of filenames to include (default: '') suffix:...
[ "Parse", "documents", "from", "TEI", "style", "XML", "files", ".", "Gives", "each", "document", "FILE", "attribute", "that", "denotes", "the", "original", "filename", ".", "Parameters", "----------", "root", ":", "str", "The", "directory", "path", "containing", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/teicorpus.py#L27-L59
estnltk/estnltk
estnltk/teicorpus.py
parse_tei_corpus
def parse_tei_corpus(path, target=['artikkel'], encoding=None): """Parse documents from a TEI style XML file. Parameters ---------- path: str The path of the XML file. target: list of str List of <div> types, that are considered documents in the XML files (default: ["artikkel"])...
python
def parse_tei_corpus(path, target=['artikkel'], encoding=None): """Parse documents from a TEI style XML file. Parameters ---------- path: str The path of the XML file. target: list of str List of <div> types, that are considered documents in the XML files (default: ["artikkel"])...
[ "def", "parse_tei_corpus", "(", "path", ",", "target", "=", "[", "'artikkel'", "]", ",", "encoding", "=", "None", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "html_doc", "=", "f", ".", "read", "(", ")", "if", "encoding"...
Parse documents from a TEI style XML file. Parameters ---------- path: str The path of the XML file. target: list of str List of <div> types, that are considered documents in the XML files (default: ["artikkel"]). encoding: str Encoding to be used for decoding the conten...
[ "Parse", "documents", "from", "a", "TEI", "style", "XML", "file", ".", "Parameters", "----------", "path", ":", "str", "The", "path", "of", "the", "XML", "file", ".", "target", ":", "list", "of", "str", "List", "of", "<div", ">", "types", "that", "are"...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/teicorpus.py#L62-L89
estnltk/estnltk
estnltk/teicorpus.py
parse_div
def parse_div(soup, metadata, target): """Parse a <div> tag from the file. The sections in XML files are given in <div1>, <div2> and <div3> tags. Each such tag has a type and name (plus possibly more extra attributes). If the div type is found in target variable, the div is parsed into str...
python
def parse_div(soup, metadata, target): """Parse a <div> tag from the file. The sections in XML files are given in <div1>, <div2> and <div3> tags. Each such tag has a type and name (plus possibly more extra attributes). If the div type is found in target variable, the div is parsed into str...
[ "def", "parse_div", "(", "soup", ",", "metadata", ",", "target", ")", ":", "documents", "=", "[", "]", "div_type", "=", "soup", ".", "get", "(", "'type'", ",", "None", ")", "div_title", "=", "list", "(", "soup", ".", "children", ")", "[", "0", "]",...
Parse a <div> tag from the file. The sections in XML files are given in <div1>, <div2> and <div3> tags. Each such tag has a type and name (plus possibly more extra attributes). If the div type is found in target variable, the div is parsed into structured paragraphs, sentences and words. ...
[ "Parse", "a", "<div", ">", "tag", "from", "the", "file", ".", "The", "sections", "in", "XML", "files", "are", "given", "in", "<div1", ">", "<div2", ">", "and", "<div3", ">", "tags", ".", "Each", "such", "tag", "has", "a", "type", "and", "name", "("...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/teicorpus.py#L97-L149
estnltk/estnltk
estnltk/teicorpus.py
parse_paragraphs
def parse_paragraphs(soup): """Parse sentences and paragraphs in the section. Parameters ---------- soup: bs4.BeautifulSoup The parsed XML data. Returns ------- list of (list of str) List of paragraphs given as list of sentences. """ paragraphs = [] ...
python
def parse_paragraphs(soup): """Parse sentences and paragraphs in the section. Parameters ---------- soup: bs4.BeautifulSoup The parsed XML data. Returns ------- list of (list of str) List of paragraphs given as list of sentences. """ paragraphs = [] ...
[ "def", "parse_paragraphs", "(", "soup", ")", ":", "paragraphs", "=", "[", "]", "for", "para", "in", "soup", ".", "find_all", "(", "'p'", ")", ":", "sentences", "=", "[", "]", "for", "sent", "in", "para", ".", "find_all", "(", "'s'", ")", ":", "sent...
Parse sentences and paragraphs in the section. Parameters ---------- soup: bs4.BeautifulSoup The parsed XML data. Returns ------- list of (list of str) List of paragraphs given as list of sentences.
[ "Parse", "sentences", "and", "paragraphs", "in", "the", "section", ".", "Parameters", "----------", "soup", ":", "bs4", ".", "BeautifulSoup", "The", "parsed", "XML", "data", ".", "Returns", "-------", "list", "of", "(", "list", "of", "str", ")", "List", "o...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/teicorpus.py#L152-L174
estnltk/estnltk
estnltk/teicorpus.py
tokenize_documents
def tokenize_documents(docs): """Convert the imported documents to :py:class:'~estnltk.text.Text' instances.""" sep = '\n\n' texts = [] for doc in docs: text = '\n\n'.join(['\n'.join(para[SENTENCES]) for para in doc[PARAGRAPHS]]) doc[TEXT] = text del doc[PARAGRAPHS] texts...
python
def tokenize_documents(docs): """Convert the imported documents to :py:class:'~estnltk.text.Text' instances.""" sep = '\n\n' texts = [] for doc in docs: text = '\n\n'.join(['\n'.join(para[SENTENCES]) for para in doc[PARAGRAPHS]]) doc[TEXT] = text del doc[PARAGRAPHS] texts...
[ "def", "tokenize_documents", "(", "docs", ")", ":", "sep", "=", "'\\n\\n'", "texts", "=", "[", "]", "for", "doc", "in", "docs", ":", "text", "=", "'\\n\\n'", ".", "join", "(", "[", "'\\n'", ".", "join", "(", "para", "[", "SENTENCES", "]", ")", "for...
Convert the imported documents to :py:class:'~estnltk.text.Text' instances.
[ "Convert", "the", "imported", "documents", "to", ":", "py", ":", "class", ":", "~estnltk", ".", "text", ".", "Text", "instances", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/teicorpus.py#L186-L195
estnltk/estnltk
estnltk/tools/train_default_ner_model.py
train_default_model
def train_default_model(): """Function for training the default NER model. NB! It overwrites the default model, so do not use it unless you know what are you doing. The training data is in file estnltk/corpora/estner.json.bz2 . The resulting model will be saved to estnltk/estner/models/default.bin...
python
def train_default_model(): """Function for training the default NER model. NB! It overwrites the default model, so do not use it unless you know what are you doing. The training data is in file estnltk/corpora/estner.json.bz2 . The resulting model will be saved to estnltk/estner/models/default.bin...
[ "def", "train_default_model", "(", ")", ":", "docs", "=", "read_json_corpus", "(", "DEFAULT_NER_DATASET", ")", "trainer", "=", "NerTrainer", "(", "default_nersettings", ")", "trainer", ".", "train", "(", "docs", ",", "DEFAULT_NER_MODEL_DIR", ")" ]
Function for training the default NER model. NB! It overwrites the default model, so do not use it unless you know what are you doing. The training data is in file estnltk/corpora/estner.json.bz2 . The resulting model will be saved to estnltk/estner/models/default.bin
[ "Function", "for", "training", "the", "default", "NER", "model", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/tools/train_default_ner_model.py#L10-L21
estnltk/estnltk
estnltk/javaprocess.py
JavaProcess.process_line
def process_line(self, line): """Process a line of data. Sends the data through the pipe to the process and flush it. Reads a resulting line and returns it. Parameters ---------- line: str The data sent to process. Make sur...
python
def process_line(self, line): """Process a line of data. Sends the data through the pipe to the process and flush it. Reads a resulting line and returns it. Parameters ---------- line: str The data sent to process. Make sur...
[ "def", "process_line", "(", "self", ",", "line", ")", ":", "assert", "isinstance", "(", "line", ",", "str", ")", "try", ":", "self", ".", "_process", ".", "stdin", ".", "write", "(", "as_binary", "(", "line", ")", ")", "self", ".", "_process", ".", ...
Process a line of data. Sends the data through the pipe to the process and flush it. Reads a resulting line and returns it. Parameters ---------- line: str The data sent to process. Make sure it does not contain any newline characte...
[ "Process", "a", "line", "of", "data", ".", "Sends", "the", "data", "through", "the", "pipe", "to", "the", "process", "and", "flush", "it", ".", "Reads", "a", "resulting", "line", "and", "returns", "it", ".", "Parameters", "----------", "line", ":", "str"...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/javaprocess.py#L52-L87
estnltk/estnltk
estnltk/wordnet/wn.py
_get_synset_offsets
def _get_synset_offsets(synset_idxes): """Returs pointer offset in the WordNet file for every synset index. Notes ----- Internal function. Do not call directly. Preserves order -- for [x,y,z] returns [offset(x),offset(y),offset(z)]. Parameters ---------- synset_idxes : list of ints ...
python
def _get_synset_offsets(synset_idxes): """Returs pointer offset in the WordNet file for every synset index. Notes ----- Internal function. Do not call directly. Preserves order -- for [x,y,z] returns [offset(x),offset(y),offset(z)]. Parameters ---------- synset_idxes : list of ints ...
[ "def", "_get_synset_offsets", "(", "synset_idxes", ")", ":", "offsets", "=", "{", "}", "current_seeked_offset_idx", "=", "0", "ordered_synset_idxes", "=", "sorted", "(", "synset_idxes", ")", "with", "codecs", ".", "open", "(", "_SOI", ",", "'rb'", ",", "'utf-8...
Returs pointer offset in the WordNet file for every synset index. Notes ----- Internal function. Do not call directly. Preserves order -- for [x,y,z] returns [offset(x),offset(y),offset(z)]. Parameters ---------- synset_idxes : list of ints Lists synset IDs, which need offset. ...
[ "Returs", "pointer", "offset", "in", "the", "WordNet", "file", "for", "every", "synset", "index", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L53-L88
estnltk/estnltk
estnltk/wordnet/wn.py
_get_synsets
def _get_synsets(synset_offsets): """Given synset offsets in the WordNet file, parses synset object for every offset. Notes ----- Internal function. Do not call directly. Stores every parsed synset into global synset dictionary under two keys: synset's name lemma.pos.sense_no and synset's id ...
python
def _get_synsets(synset_offsets): """Given synset offsets in the WordNet file, parses synset object for every offset. Notes ----- Internal function. Do not call directly. Stores every parsed synset into global synset dictionary under two keys: synset's name lemma.pos.sense_no and synset's id ...
[ "def", "_get_synsets", "(", "synset_offsets", ")", ":", "global", "parser", "if", "parser", "is", "None", ":", "parser", "=", "Parser", "(", "_WN_FILE", ")", "synsets", "=", "[", "]", "for", "offset", "in", "synset_offsets", ":", "raw_synset", "=", "parser...
Given synset offsets in the WordNet file, parses synset object for every offset. Notes ----- Internal function. Do not call directly. Stores every parsed synset into global synset dictionary under two keys: synset's name lemma.pos.sense_no and synset's id (unique integer). Parameters ---...
[ "Given", "synset", "offsets", "in", "the", "WordNet", "file", "parses", "synset", "object", "for", "every", "offset", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L90-L124
estnltk/estnltk
estnltk/wordnet/wn.py
_get_key_from_raw_synset
def _get_key_from_raw_synset(raw_synset): """Derives synset key in the form of `lemma.pos.sense_no` from the provided eurown.py Synset class, Notes ----- Internal function. Do not call directly. Parameters ---------- raw_synset : eurown.Synset Synset representation from which lemma,...
python
def _get_key_from_raw_synset(raw_synset): """Derives synset key in the form of `lemma.pos.sense_no` from the provided eurown.py Synset class, Notes ----- Internal function. Do not call directly. Parameters ---------- raw_synset : eurown.Synset Synset representation from which lemma,...
[ "def", "_get_key_from_raw_synset", "(", "raw_synset", ")", ":", "pos", "=", "raw_synset", ".", "pos", "literal", "=", "raw_synset", ".", "variants", "[", "0", "]", ".", "literal", "sense", "=", "\"%02d\"", "%", "raw_synset", ".", "variants", "[", "0", "]",...
Derives synset key in the form of `lemma.pos.sense_no` from the provided eurown.py Synset class, Notes ----- Internal function. Do not call directly. Parameters ---------- raw_synset : eurown.Synset Synset representation from which lemma, part-of-speech and sense is derived. Return...
[ "Derives", "synset", "key", "in", "the", "form", "of", "lemma", ".", "pos", ".", "sense_no", "from", "the", "provided", "eurown", ".", "py", "Synset", "class" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L126-L148
estnltk/estnltk
estnltk/wordnet/wn.py
synset
def synset(synset_key): """Returns synset object with the provided key. Notes ----- Uses lazy initialization - synsets will be fetched from a dictionary after the first request. Parameters ---------- synset_key : string Unique synset identifier in the form of `lemma.pos.sense_no`. ...
python
def synset(synset_key): """Returns synset object with the provided key. Notes ----- Uses lazy initialization - synsets will be fetched from a dictionary after the first request. Parameters ---------- synset_key : string Unique synset identifier in the form of `lemma.pos.sense_no`. ...
[ "def", "synset", "(", "synset_key", ")", ":", "if", "synset_key", "in", "SYNSETS_DICT", ":", "return", "SYNSETS_DICT", "[", "synset_key", "]", "def", "_get_synset_idx", "(", "synset_key", ")", ":", "\"\"\"Returns synset index for the provided key.\n\n Note\n ...
Returns synset object with the provided key. Notes ----- Uses lazy initialization - synsets will be fetched from a dictionary after the first request. Parameters ---------- synset_key : string Unique synset identifier in the form of `lemma.pos.sense_no`. Returns ------- ...
[ "Returns", "synset", "object", "with", "the", "provided", "key", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L150-L196
estnltk/estnltk
estnltk/wordnet/wn.py
synsets
def synsets(lemma,pos=None): """Returns all synset objects which have lemma as one of the variant literals and fixed pos, if provided. Notes ----- Uses lazy initialization - parses only those synsets which are not yet initialized, others are fetched from a dictionary. Parameters ---------- ...
python
def synsets(lemma,pos=None): """Returns all synset objects which have lemma as one of the variant literals and fixed pos, if provided. Notes ----- Uses lazy initialization - parses only those synsets which are not yet initialized, others are fetched from a dictionary. Parameters ---------- ...
[ "def", "synsets", "(", "lemma", ",", "pos", "=", "None", ")", ":", "def", "_get_synset_idxes", "(", "lemma", ",", "pos", ")", ":", "line_prefix_regexp", "=", "\"%s:%s:(.*)\"", "%", "(", "lemma", ",", "pos", "if", "pos", "else", "\"\\w+\"", ")", "line_pre...
Returns all synset objects which have lemma as one of the variant literals and fixed pos, if provided. Notes ----- Uses lazy initialization - parses only those synsets which are not yet initialized, others are fetched from a dictionary. Parameters ---------- lemma : str Lemma of the syns...
[ "Returns", "all", "synset", "objects", "which", "have", "lemma", "as", "one", "of", "the", "variant", "literals", "and", "fixed", "pos", "if", "provided", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L199-L256
estnltk/estnltk
estnltk/wordnet/wn.py
all_synsets
def all_synsets(pos=None): """Return all the synsets which have the provided pos. Notes ----- Returns thousands or tens of thousands of synsets - first time will take significant time. Useful for initializing synsets as each returned synset is also stored in a global dictionary for fast retrieval t...
python
def all_synsets(pos=None): """Return all the synsets which have the provided pos. Notes ----- Returns thousands or tens of thousands of synsets - first time will take significant time. Useful for initializing synsets as each returned synset is also stored in a global dictionary for fast retrieval t...
[ "def", "all_synsets", "(", "pos", "=", "None", ")", ":", "def", "_get_unique_synset_idxes", "(", "pos", ")", ":", "idxes", "=", "[", "]", "with", "codecs", ".", "open", "(", "_LIT_POS_FILE", ",", "'rb'", ",", "'utf-8'", ")", "as", "fin", ":", "if", "...
Return all the synsets which have the provided pos. Notes ----- Returns thousands or tens of thousands of synsets - first time will take significant time. Useful for initializing synsets as each returned synset is also stored in a global dictionary for fast retrieval the next time. Parameters ...
[ "Return", "all", "the", "synsets", "which", "have", "the", "provided", "pos", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L258-L316
estnltk/estnltk
estnltk/wordnet/wn.py
lemma
def lemma(lemma_key): """Returns the Lemma object with the given key. Parameters ---------- lemma_key : str Key of the returned lemma. Returns ------- Lemma Lemma matching the `lemma_key`. """ if lemma_key in LEMMAS_DICT: return LEMMAS_DICT[lemma_key] split...
python
def lemma(lemma_key): """Returns the Lemma object with the given key. Parameters ---------- lemma_key : str Key of the returned lemma. Returns ------- Lemma Lemma matching the `lemma_key`. """ if lemma_key in LEMMAS_DICT: return LEMMAS_DICT[lemma_key] split...
[ "def", "lemma", "(", "lemma_key", ")", ":", "if", "lemma_key", "in", "LEMMAS_DICT", ":", "return", "LEMMAS_DICT", "[", "lemma_key", "]", "split_lemma_key", "=", "lemma_key", ".", "split", "(", "'.'", ")", "synset_key", "=", "'.'", ".", "join", "(", "split_...
Returns the Lemma object with the given key. Parameters ---------- lemma_key : str Key of the returned lemma. Returns ------- Lemma Lemma matching the `lemma_key`.
[ "Returns", "the", "Lemma", "object", "with", "the", "given", "key", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L318-L341
estnltk/estnltk
estnltk/wordnet/wn.py
lemmas
def lemmas(lemma,pos=None): """Returns all the Lemma objects of which name is `lemma` and which have `pos` as part of speech. Parameters ---------- lemma : str Literal of the sought Lemma objects. pos : str, optional Part of speech of the sought Lemma objects. If None, matches any p...
python
def lemmas(lemma,pos=None): """Returns all the Lemma objects of which name is `lemma` and which have `pos` as part of speech. Parameters ---------- lemma : str Literal of the sought Lemma objects. pos : str, optional Part of speech of the sought Lemma objects. If None, matches any p...
[ "def", "lemmas", "(", "lemma", ",", "pos", "=", "None", ")", ":", "lemma", "=", "lemma", ".", "lower", "(", ")", "return", "[", "lemma_obj", "for", "synset", "in", "synsets", "(", "lemma", ",", "pos", ")", "for", "lemma_obj", "in", "synset", ".", "...
Returns all the Lemma objects of which name is `lemma` and which have `pos` as part of speech. Parameters ---------- lemma : str Literal of the sought Lemma objects. pos : str, optional Part of speech of the sought Lemma objects. If None, matches any part of speech. Defaults to No...
[ "Returns", "all", "the", "Lemma", "objects", "of", "which", "name", "is", "lemma", "and", "which", "have", "pos", "as", "part", "of", "speech", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L348-L369
estnltk/estnltk
estnltk/wordnet/wn.py
Synset._recursive_hypernyms
def _recursive_hypernyms(self, hypernyms): """Finds all the hypernyms of the synset transitively. Notes ----- Internal method. Do not call directly. Parameters ---------- hypernyms : set of Synsets An set of hypernyms met so far. Returns ...
python
def _recursive_hypernyms(self, hypernyms): """Finds all the hypernyms of the synset transitively. Notes ----- Internal method. Do not call directly. Parameters ---------- hypernyms : set of Synsets An set of hypernyms met so far. Returns ...
[ "def", "_recursive_hypernyms", "(", "self", ",", "hypernyms", ")", ":", "hypernyms", "|=", "set", "(", "self", ".", "hypernyms", "(", ")", ")", "for", "synset", "in", "self", ".", "hypernyms", "(", ")", ":", "hypernyms", "|=", "synset", ".", "_recursive_...
Finds all the hypernyms of the synset transitively. Notes ----- Internal method. Do not call directly. Parameters ---------- hypernyms : set of Synsets An set of hypernyms met so far. Returns ------- set of Synsets Returns ...
[ "Finds", "all", "the", "hypernyms", "of", "the", "synset", "transitively", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L427-L449
estnltk/estnltk
estnltk/wordnet/wn.py
Synset._min_depth
def _min_depth(self): """Finds minimum path length from the root. Notes ----- Internal method. Do not call directly. Returns ------- int Minimum path length from the root. """ if "min_depth" in self.__dict__: return self....
python
def _min_depth(self): """Finds minimum path length from the root. Notes ----- Internal method. Do not call directly. Returns ------- int Minimum path length from the root. """ if "min_depth" in self.__dict__: return self....
[ "def", "_min_depth", "(", "self", ")", ":", "if", "\"min_depth\"", "in", "self", ".", "__dict__", ":", "return", "self", ".", "__dict__", "[", "\"min_depth\"", "]", "min_depth", "=", "0", "hypernyms", "=", "self", ".", "hypernyms", "(", ")", "if", "hyper...
Finds minimum path length from the root. Notes ----- Internal method. Do not call directly. Returns ------- int Minimum path length from the root.
[ "Finds", "minimum", "path", "length", "from", "the", "root", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L451-L473
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.get_related_synsets
def get_related_synsets(self,relation): """Retrieves all the synsets which are related by given relation. Parameters ---------- relation : str Name of the relation via which the sought synsets are linked. Returns ------- list of Synsets Synse...
python
def get_related_synsets(self,relation): """Retrieves all the synsets which are related by given relation. Parameters ---------- relation : str Name of the relation via which the sought synsets are linked. Returns ------- list of Synsets Synse...
[ "def", "get_related_synsets", "(", "self", ",", "relation", ")", ":", "results", "=", "[", "]", "for", "relation_candidate", "in", "self", ".", "_raw_synset", ".", "internalLinks", ":", "if", "relation_candidate", ".", "name", "==", "relation", ":", "linked_sy...
Retrieves all the synsets which are related by given relation. Parameters ---------- relation : str Name of the relation via which the sought synsets are linked. Returns ------- list of Synsets Synsets which are related via `relation`.
[ "Retrieves", "all", "the", "synsets", "which", "are", "related", "by", "given", "relation", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L543-L564
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.closure
def closure(self, relation, depth=float('inf')): """Finds all the ancestors of the synset using provided relation. Parameters ---------- relation : str Name of the relation which is recursively used to fetch the ancestors. Returns ------- list of ...
python
def closure(self, relation, depth=float('inf')): """Finds all the ancestors of the synset using provided relation. Parameters ---------- relation : str Name of the relation which is recursively used to fetch the ancestors. Returns ------- list of ...
[ "def", "closure", "(", "self", ",", "relation", ",", "depth", "=", "float", "(", "'inf'", ")", ")", ":", "ancestors", "=", "[", "]", "unvisited_ancestors", "=", "[", "(", "synset", ",", "1", ")", "for", "synset", "in", "self", ".", "get_related_synsets...
Finds all the ancestors of the synset using provided relation. Parameters ---------- relation : str Name of the relation which is recursively used to fetch the ancestors. Returns ------- list of Synsets Returns the ancestors of the synset via given r...
[ "Finds", "all", "the", "ancestors", "of", "the", "synset", "using", "provided", "relation", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L566-L591
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.root_hypernyms
def root_hypernyms(self): """Retrieves all the root hypernyms. Returns ------- list of Synsets Roots via hypernymy relation. """ visited = set() hypernyms_next_level = set(self.hypernyms()) current_hypernyms = set(hypernyms_next...
python
def root_hypernyms(self): """Retrieves all the root hypernyms. Returns ------- list of Synsets Roots via hypernymy relation. """ visited = set() hypernyms_next_level = set(self.hypernyms()) current_hypernyms = set(hypernyms_next...
[ "def", "root_hypernyms", "(", "self", ")", ":", "visited", "=", "set", "(", ")", "hypernyms_next_level", "=", "set", "(", "self", ".", "hypernyms", "(", ")", ")", "current_hypernyms", "=", "set", "(", "hypernyms_next_level", ")", "while", "len", "(", "hype...
Retrieves all the root hypernyms. Returns ------- list of Synsets Roots via hypernymy relation.
[ "Retrieves", "all", "the", "root", "hypernyms", ".", "Returns", "-------", "list", "of", "Synsets", "Roots", "via", "hypernymy", "relation", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L648-L671
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.lch_similarity
def lch_similarity(self, synset): """Calculates Leacock and Chodorow's similarity between the two synsets. Notes ----- Similarity is calculated using the formula -log( (dist(synset1,synset2)+1) / (2*maximum taxonomy depth) ). Parameters ---------- synset : S...
python
def lch_similarity(self, synset): """Calculates Leacock and Chodorow's similarity between the two synsets. Notes ----- Similarity is calculated using the formula -log( (dist(synset1,synset2)+1) / (2*maximum taxonomy depth) ). Parameters ---------- synset : S...
[ "def", "lch_similarity", "(", "self", ",", "synset", ")", ":", "if", "self", ".", "_raw_synset", ".", "pos", "!=", "synset", ".", "_raw_synset", ".", "pos", ":", "return", "None", "depth", "=", "MAX_TAXONOMY_DEPTHS", "[", "self", ".", "_raw_synset", ".", ...
Calculates Leacock and Chodorow's similarity between the two synsets. Notes ----- Similarity is calculated using the formula -log( (dist(synset1,synset2)+1) / (2*maximum taxonomy depth) ). Parameters ---------- synset : Synset Synset from which the similarit...
[ "Calculates", "Leacock", "and", "Chodorow", "s", "similarity", "between", "the", "two", "synsets", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L694-L724
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.wup_similarity
def wup_similarity(self, target_synset): """Calculates Wu and Palmer's similarity between the two synsets. Notes ----- Similarity is calculated using the formula ( 2*depth(least_common_subsumer(synset1,synset2)) ) / ( depth(synset1) + depth(synset2) ) Paramete...
python
def wup_similarity(self, target_synset): """Calculates Wu and Palmer's similarity between the two synsets. Notes ----- Similarity is calculated using the formula ( 2*depth(least_common_subsumer(synset1,synset2)) ) / ( depth(synset1) + depth(synset2) ) Paramete...
[ "def", "wup_similarity", "(", "self", ",", "target_synset", ")", ":", "lchs", "=", "self", ".", "lowest_common_hypernyms", "(", "target_synset", ")", "lcs_depth", "=", "lchs", "[", "0", "]", ".", "_min_depth", "(", ")", "if", "lchs", "and", "len", "(", "...
Calculates Wu and Palmer's similarity between the two synsets. Notes ----- Similarity is calculated using the formula ( 2*depth(least_common_subsumer(synset1,synset2)) ) / ( depth(synset1) + depth(synset2) ) Parameters ---------- synset : Synset ...
[ "Calculates", "Wu", "and", "Palmer", "s", "similarity", "between", "the", "two", "synsets", ".", "Notes", "-----", "Similarity", "is", "calculated", "using", "the", "formula", "(", "2", "*", "depth", "(", "least_common_subsumer", "(", "synset1", "synset2", "))...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L726-L751
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.definition
def definition(self): """Returns the definition of the synset. Returns ------- str Definition of the synset as a new-line separated concatenated string from all its variants' definitions. """ return '\n'.join([variant.gloss for variant in self....
python
def definition(self): """Returns the definition of the synset. Returns ------- str Definition of the synset as a new-line separated concatenated string from all its variants' definitions. """ return '\n'.join([variant.gloss for variant in self....
[ "def", "definition", "(", "self", ")", ":", "return", "'\\n'", ".", "join", "(", "[", "variant", ".", "gloss", "for", "variant", "in", "self", ".", "_raw_synset", ".", "variants", "if", "variant", ".", "gloss", "]", ")" ]
Returns the definition of the synset. Returns ------- str Definition of the synset as a new-line separated concatenated string from all its variants' definitions.
[ "Returns", "the", "definition", "of", "the", "synset", ".", "Returns", "-------", "str", "Definition", "of", "the", "synset", "as", "a", "new", "-", "line", "separated", "concatenated", "string", "from", "all", "its", "variants", "definitions", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L764-L773
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.examples
def examples(self): """Returns the examples of the synset. Returns ------- list of str List of its variants' examples. """ examples = [] for example in [variant.examples for variant in self._raw_synset.variants if len(variant.examples)...
python
def examples(self): """Returns the examples of the synset. Returns ------- list of str List of its variants' examples. """ examples = [] for example in [variant.examples for variant in self._raw_synset.variants if len(variant.examples)...
[ "def", "examples", "(", "self", ")", ":", "examples", "=", "[", "]", "for", "example", "in", "[", "variant", ".", "examples", "for", "variant", "in", "self", ".", "_raw_synset", ".", "variants", "if", "len", "(", "variant", ".", "examples", ")", "]", ...
Returns the examples of the synset. Returns ------- list of str List of its variants' examples.
[ "Returns", "the", "examples", "of", "the", "synset", ".", "Returns", "-------", "list", "of", "str", "List", "of", "its", "variants", "examples", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L775-L787
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.lemmas
def lemmas(self): """Returns the synset's lemmas/variants' literal represantions. Returns ------- list of Lemmas List of its variations' literals as Lemma objects. """ return [lemma("%s.%s"%(self.name,variant.literal)) for variant in self._raw_...
python
def lemmas(self): """Returns the synset's lemmas/variants' literal represantions. Returns ------- list of Lemmas List of its variations' literals as Lemma objects. """ return [lemma("%s.%s"%(self.name,variant.literal)) for variant in self._raw_...
[ "def", "lemmas", "(", "self", ")", ":", "return", "[", "lemma", "(", "\"%s.%s\"", "%", "(", "self", ".", "name", ",", "variant", ".", "literal", ")", ")", "for", "variant", "in", "self", ".", "_raw_synset", ".", "variants", "]" ]
Returns the synset's lemmas/variants' literal represantions. Returns ------- list of Lemmas List of its variations' literals as Lemma objects.
[ "Returns", "the", "synset", "s", "lemmas", "/", "variants", "literal", "represantions", ".", "Returns", "-------", "list", "of", "Lemmas", "List", "of", "its", "variations", "literals", "as", "Lemma", "objects", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L789-L798
estnltk/estnltk
estnltk/wordnet/wn.py
Synset.lowest_common_hypernyms
def lowest_common_hypernyms(self,target_synset): """Returns the common hypernyms of the synset and the target synset, which are furthest from the closest roots. Parameters ---------- target_synset : Synset Synset with which the common hypernyms are sought. ...
python
def lowest_common_hypernyms(self,target_synset): """Returns the common hypernyms of the synset and the target synset, which are furthest from the closest roots. Parameters ---------- target_synset : Synset Synset with which the common hypernyms are sought. ...
[ "def", "lowest_common_hypernyms", "(", "self", ",", "target_synset", ")", ":", "self_hypernyms", "=", "self", ".", "_recursive_hypernyms", "(", "set", "(", ")", ")", "other_hypernyms", "=", "target_synset", ".", "_recursive_hypernyms", "(", "set", "(", ")", ")",...
Returns the common hypernyms of the synset and the target synset, which are furthest from the closest roots. Parameters ---------- target_synset : Synset Synset with which the common hypernyms are sought. Returns ------- list of Synsets ...
[ "Returns", "the", "common", "hypernyms", "of", "the", "synset", "and", "the", "target", "synset", "which", "are", "furthest", "from", "the", "closest", "roots", ".", "Parameters", "----------", "target_synset", ":", "Synset", "Synset", "with", "which", "the", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L800-L827
estnltk/estnltk
estnltk/wordnet/wn.py
Lemma.synset
def synset(self): """Returns synset into which the given lemma belongs to. Returns ------- Synset Synset into which the given lemma belongs to. """ return synset('%s.%s.%s.%s'%(self.synset_literal,self.synset_pos,self.synset_sense,self.lite...
python
def synset(self): """Returns synset into which the given lemma belongs to. Returns ------- Synset Synset into which the given lemma belongs to. """ return synset('%s.%s.%s.%s'%(self.synset_literal,self.synset_pos,self.synset_sense,self.lite...
[ "def", "synset", "(", "self", ")", ":", "return", "synset", "(", "'%s.%s.%s.%s'", "%", "(", "self", ".", "synset_literal", ",", "self", ".", "synset_pos", ",", "self", ".", "synset_sense", ",", "self", ".", "literal", ")", ")" ]
Returns synset into which the given lemma belongs to. Returns ------- Synset Synset into which the given lemma belongs to.
[ "Returns", "synset", "into", "which", "the", "given", "lemma", "belongs", "to", ".", "Returns", "-------", "Synset", "Synset", "into", "which", "the", "given", "lemma", "belongs", "to", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L864-L873
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
convert_vm_json_to_mrf
def convert_vm_json_to_mrf( vabamorf_json ): ''' Converts from vabamorf's JSON output, given as dict, into pre-syntactic mrf format, given as a list of lines, as in the output of etmrf. The aimed format looks something like this: <s> Kolmandaks kolmandaks+0 //_D_ // ...
python
def convert_vm_json_to_mrf( vabamorf_json ): ''' Converts from vabamorf's JSON output, given as dict, into pre-syntactic mrf format, given as a list of lines, as in the output of etmrf. The aimed format looks something like this: <s> Kolmandaks kolmandaks+0 //_D_ // ...
[ "def", "convert_vm_json_to_mrf", "(", "vabamorf_json", ")", ":", "if", "not", "isinstance", "(", "vabamorf_json", ",", "dict", ")", ":", "raise", "Exception", "(", "' Expected dict as an input argument! '", ")", "json_sentences", "=", "[", "]", "# 1) flatten paragraph...
Converts from vabamorf's JSON output, given as dict, into pre-syntactic mrf format, given as a list of lines, as in the output of etmrf. The aimed format looks something like this: <s> Kolmandaks kolmandaks+0 //_D_ // kolmas+ks //_O_ sg tr // kihutas ...
[ "Converts", "from", "vabamorf", "s", "JSON", "output", "given", "as", "dict", "into", "pre", "-", "syntactic", "mrf", "format", "given", "as", "a", "list", "of", "lines", "as", "in", "the", "output", "of", "etmrf", ".", "The", "aimed", "format", "looks",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L95-L153
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
convert_Text_to_mrf
def convert_Text_to_mrf( text ): ''' Converts from Text object into pre-syntactic mrf format, given as a list of lines, as in the output of etmrf. *) If the input Text has already been morphologically analysed, uses the existing analysis; *) If the input has not been analysed, p...
python
def convert_Text_to_mrf( text ): ''' Converts from Text object into pre-syntactic mrf format, given as a list of lines, as in the output of etmrf. *) If the input Text has already been morphologically analysed, uses the existing analysis; *) If the input has not been analysed, p...
[ "def", "convert_Text_to_mrf", "(", "text", ")", ":", "from", "estnltk", ".", "text", "import", "Text", "if", "not", "isinstance", "(", "text", ",", "Text", ")", ":", "raise", "Exception", "(", "' Expected estnltk\\'s Text as an input argument! '", ")", "if", "no...
Converts from Text object into pre-syntactic mrf format, given as a list of lines, as in the output of etmrf. *) If the input Text has already been morphologically analysed, uses the existing analysis; *) If the input has not been analysed, performs the analysis with required settin...
[ "Converts", "from", "Text", "object", "into", "pre", "-", "syntactic", "mrf", "format", "given", "as", "a", "list", "of", "lines", "as", "in", "the", "output", "of", "etmrf", ".", "*", ")", "If", "the", "input", "Text", "has", "already", "been", "morph...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L156-L204
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
load_fs_mrf_to_syntax_mrf_translation_rules
def load_fs_mrf_to_syntax_mrf_translation_rules( rulesFile ): ''' Loads rules that can be used to convert from Filosoft's mrf format to syntactic analyzer's format. Returns a dict containing rules. Expects that each line in the input file contains a single rule, and that different parts o...
python
def load_fs_mrf_to_syntax_mrf_translation_rules( rulesFile ): ''' Loads rules that can be used to convert from Filosoft's mrf format to syntactic analyzer's format. Returns a dict containing rules. Expects that each line in the input file contains a single rule, and that different parts o...
[ "def", "load_fs_mrf_to_syntax_mrf_translation_rules", "(", "rulesFile", ")", ":", "rules", "=", "{", "}", "in_f", "=", "codecs", ".", "open", "(", "rulesFile", ",", "mode", "=", "'r'", ",", "encoding", "=", "'utf-8'", ")", "for", "line", "in", "in_f", ":",...
Loads rules that can be used to convert from Filosoft's mrf format to syntactic analyzer's format. Returns a dict containing rules. Expects that each line in the input file contains a single rule, and that different parts of the rule separated by @ symbols, e.g. 1@_S_ ?@S...
[ "Loads", "rules", "that", "can", "be", "used", "to", "convert", "from", "Filosoft", "s", "mrf", "format", "to", "syntactic", "analyzer", "s", "format", ".", "Returns", "a", "dict", "containing", "rules", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L214-L248
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
_convert_punctuation
def _convert_punctuation( line ): ''' Converts given analysis line if it describes punctuation; Uses the set of predefined punctuation conversion rules from _punctConversions; _punctConversions should be a list of lists, where each outer list stands for a single conversion rule an...
python
def _convert_punctuation( line ): ''' Converts given analysis line if it describes punctuation; Uses the set of predefined punctuation conversion rules from _punctConversions; _punctConversions should be a list of lists, where each outer list stands for a single conversion rule an...
[ "def", "_convert_punctuation", "(", "line", ")", ":", "for", "[", "pattern", ",", "replacement", "]", "in", "_punctConversions", ":", "lastline", "=", "line", "line", "=", "re", ".", "sub", "(", "pattern", ",", "replacement", ",", "line", ")", "if", "las...
Converts given analysis line if it describes punctuation; Uses the set of predefined punctuation conversion rules from _punctConversions; _punctConversions should be a list of lists, where each outer list stands for a single conversion rule and inner list contains a pair of elements: ...
[ "Converts", "given", "analysis", "line", "if", "it", "describes", "punctuation", ";", "Uses", "the", "set", "of", "predefined", "punctuation", "conversion", "rules", "from", "_punctConversions", ";", "_punctConversions", "should", "be", "a", "list", "of", "lists",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L280-L297
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
convert_mrf_to_syntax_mrf
def convert_mrf_to_syntax_mrf( mrf_lines, conversion_rules ): ''' Converts given lines from Filosoft's mrf format to syntactic analyzer's format, using the morph-category conversion rules from conversion_rules, and punctuation via method _convert_punctuation(); As a result of conversion, th...
python
def convert_mrf_to_syntax_mrf( mrf_lines, conversion_rules ): ''' Converts given lines from Filosoft's mrf format to syntactic analyzer's format, using the morph-category conversion rules from conversion_rules, and punctuation via method _convert_punctuation(); As a result of conversion, th...
[ "def", "convert_mrf_to_syntax_mrf", "(", "mrf_lines", ",", "conversion_rules", ")", ":", "i", "=", "0", "while", "(", "i", "<", "len", "(", "mrf_lines", ")", ")", ":", "line", "=", "mrf_lines", "[", "i", "]", "if", "line", ".", "startswith", "(", "' '...
Converts given lines from Filosoft's mrf format to syntactic analyzer's format, using the morph-category conversion rules from conversion_rules, and punctuation via method _convert_punctuation(); As a result of conversion, the input list mrf_lines will be modified, and also returned a...
[ "Converts", "given", "lines", "from", "Filosoft", "s", "mrf", "format", "to", "syntactic", "analyzer", "s", "format", "using", "the", "morph", "-", "category", "conversion", "rules", "from", "conversion_rules", "and", "punctuation", "via", "method", "_convert_punc...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L306-L369
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
convert_pronouns
def convert_pronouns( mrf_lines ): ''' Converts pronouns (analysis lines with '_P_') from Filosoft's mrf to syntactic analyzer's mrf format; Uses the set of predefined pronoun conversion rules from _pronConversions; _pronConversions should be a list of lists, where each outer list ...
python
def convert_pronouns( mrf_lines ): ''' Converts pronouns (analysis lines with '_P_') from Filosoft's mrf to syntactic analyzer's mrf format; Uses the set of predefined pronoun conversion rules from _pronConversions; _pronConversions should be a list of lists, where each outer list ...
[ "def", "convert_pronouns", "(", "mrf_lines", ")", ":", "i", "=", "0", "while", "(", "i", "<", "len", "(", "mrf_lines", ")", ")", ":", "line", "=", "mrf_lines", "[", "i", "]", "if", "'_P_'", "in", "line", ":", "# only consider lines containing pronoun analy...
Converts pronouns (analysis lines with '_P_') from Filosoft's mrf to syntactic analyzer's mrf format; Uses the set of predefined pronoun conversion rules from _pronConversions; _pronConversions should be a list of lists, where each outer list stands for a single conversion rul...
[ "Converts", "pronouns", "(", "analysis", "lines", "with", "_P_", ")", "from", "Filosoft", "s", "mrf", "to", "syntactic", "analyzer", "s", "mrf", "format", ";", "Uses", "the", "set", "of", "predefined", "pronoun", "conversion", "rules", "from", "_pronConversion...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L493-L517
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
remove_duplicate_analyses
def remove_duplicate_analyses( mrf_lines, allow_to_delete_all = True ): ''' Removes duplicate analysis lines from mrf_lines. Uses special logic for handling adposition analyses ('_K_ pre' && '_K_ post') that do not have subcategorization information: *) If a word has both adpositi...
python
def remove_duplicate_analyses( mrf_lines, allow_to_delete_all = True ): ''' Removes duplicate analysis lines from mrf_lines. Uses special logic for handling adposition analyses ('_K_ pre' && '_K_ post') that do not have subcategorization information: *) If a word has both adpositi...
[ "def", "remove_duplicate_analyses", "(", "mrf_lines", ",", "allow_to_delete_all", "=", "True", ")", ":", "i", "=", "0", "seen_analyses", "=", "[", "]", "analyses_count", "=", "0", "to_delete", "=", "[", "]", "Kpre_index", "=", "-", "1", "Kpost_index", "=", ...
Removes duplicate analysis lines from mrf_lines. Uses special logic for handling adposition analyses ('_K_ pre' && '_K_ post') that do not have subcategorization information: *) If a word has both adposition analyses, removes '_K_ pre'; *) If a word has '_K_ post', removes it...
[ "Removes", "duplicate", "analysis", "lines", "from", "mrf_lines", ".", "Uses", "special", "logic", "for", "handling", "adposition", "analyses", "(", "_K_", "pre", "&&", "_K_", "post", ")", "that", "do", "not", "have", "subcategorization", "information", ":", "...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L528-L595
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
add_hashtag_info
def add_hashtag_info( mrf_lines ): ''' Augments analysis lines with various hashtag information: *) marks words with capital beginning with #cap; *) marks finite verbs with #FinV; *) marks nud/tud/mine/nu/tu/v/tav/mata/ja forms; Hashtags are added at the end of the analysis con...
python
def add_hashtag_info( mrf_lines ): ''' Augments analysis lines with various hashtag information: *) marks words with capital beginning with #cap; *) marks finite verbs with #FinV; *) marks nud/tud/mine/nu/tu/v/tav/mata/ja forms; Hashtags are added at the end of the analysis con...
[ "def", "add_hashtag_info", "(", "mrf_lines", ")", ":", "i", "=", "0", "cap", "=", "False", "while", "(", "i", "<", "len", "(", "mrf_lines", ")", ")", ":", "line", "=", "mrf_lines", "[", "i", "]", "if", "not", "line", ".", "startswith", "(", "' '",...
Augments analysis lines with various hashtag information: *) marks words with capital beginning with #cap; *) marks finite verbs with #FinV; *) marks nud/tud/mine/nu/tu/v/tav/mata/ja forms; Hashtags are added at the end of the analysis content (just before the last '//'); ...
[ "Augments", "analysis", "lines", "with", "various", "hashtag", "information", ":", "*", ")", "marks", "words", "with", "capital", "beginning", "with", "#cap", ";", "*", ")", "marks", "finite", "verbs", "with", "#FinV", ";", "*", ")", "marks", "nud", "/", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L622-L647
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
load_subcat_info
def load_subcat_info( subcat_lex_file ): ''' Loads subcategorization rules (for verbs and adpositions) from a text file. It is expected that the rules are given as pairs, where the first item is the lemma (of verb/adposition), followed on the next line by the subcategori...
python
def load_subcat_info( subcat_lex_file ): ''' Loads subcategorization rules (for verbs and adpositions) from a text file. It is expected that the rules are given as pairs, where the first item is the lemma (of verb/adposition), followed on the next line by the subcategori...
[ "def", "load_subcat_info", "(", "subcat_lex_file", ")", ":", "rules", "=", "{", "}", "nonSpacePattern", "=", "re", ".", "compile", "(", "'^\\S+$'", ")", "posTagPattern", "=", "re", ".", "compile", "(", "'_._'", ")", "in_f", "=", "codecs", ".", "open", "(...
Loads subcategorization rules (for verbs and adpositions) from a text file. It is expected that the rules are given as pairs, where the first item is the lemma (of verb/adposition), followed on the next line by the subcategorization rule, in the following form: o...
[ "Loads", "subcategorization", "rules", "(", "for", "verbs", "and", "adpositions", ")", "from", "a", "text", "file", ".", "It", "is", "expected", "that", "the", "rules", "are", "given", "as", "pairs", "where", "the", "first", "item", "is", "the", "lemma", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L657-L705
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
tag_subcat_info
def tag_subcat_info( mrf_lines, subcat_rules ): ''' Adds subcategorization information (hashtags) to verbs and adpositions; Argument subcat_rules must be a dict containing subcategorization information, loaded via method load_subcat_info(); Performs word lemma lookups in subcat_rul...
python
def tag_subcat_info( mrf_lines, subcat_rules ): ''' Adds subcategorization information (hashtags) to verbs and adpositions; Argument subcat_rules must be a dict containing subcategorization information, loaded via method load_subcat_info(); Performs word lemma lookups in subcat_rul...
[ "def", "tag_subcat_info", "(", "mrf_lines", ",", "subcat_rules", ")", ":", "i", "=", "0", "while", "(", "i", "<", "len", "(", "mrf_lines", ")", ")", ":", "line", "=", "mrf_lines", "[", "i", "]", "if", "line", ".", "startswith", "(", "' '", ")", ":...
Adds subcategorization information (hashtags) to verbs and adpositions; Argument subcat_rules must be a dict containing subcategorization information, loaded via method load_subcat_info(); Performs word lemma lookups in subcat_rules, and in case of a match, checks word part-of...
[ "Adds", "subcategorization", "information", "(", "hashtags", ")", "to", "verbs", "and", "adpositions", ";", "Argument", "subcat_rules", "must", "be", "a", "dict", "containing", "subcategorization", "information", "loaded", "via", "method", "load_subcat_info", "()", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L721-L784
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
convert_to_cg3_input
def convert_to_cg3_input( mrf_lines ): ''' Converts given mrf lines from syntax preprocessing format to cg3 input format: *) surrounds words/tokens with "< and >" *) surrounds word lemmas with " in analysis; *) separates word endings from lemmas in analysis, and adds prefix 'L'...
python
def convert_to_cg3_input( mrf_lines ): ''' Converts given mrf lines from syntax preprocessing format to cg3 input format: *) surrounds words/tokens with "< and >" *) surrounds word lemmas with " in analysis; *) separates word endings from lemmas in analysis, and adds prefix 'L'...
[ "def", "convert_to_cg3_input", "(", "mrf_lines", ")", ":", "i", "=", "0", "while", "(", "i", "<", "len", "(", "mrf_lines", ")", ")", ":", "line", "=", "mrf_lines", "[", "i", "]", "if", "not", "line", ".", "startswith", "(", "' '", ")", "and", "len...
Converts given mrf lines from syntax preprocessing format to cg3 input format: *) surrounds words/tokens with "< and >" *) surrounds word lemmas with " in analysis; *) separates word endings from lemmas in analysis, and adds prefix 'L'; *) removes '//' and '//' from analy...
[ "Converts", "given", "mrf", "lines", "from", "syntax", "preprocessing", "format", "to", "cg3", "input", "format", ":", "*", ")", "surrounds", "words", "/", "tokens", "with", "<", "and", ">", "*", ")", "surrounds", "word", "lemmas", "with", "in", "analysis"...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L794-L843
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
SyntaxPreprocessing.process_vm_json
def process_vm_json( self, json_dict, **kwargs ): ''' Executes the preprocessing pipeline on vabamorf's JSON, given as a dict; Returns a list: lines of analyses in the VISL CG3 input format; ''' mrf_lines = convert_vm_json_to_mrf( json_dict ) return self.process_mrf_lines( ...
python
def process_vm_json( self, json_dict, **kwargs ): ''' Executes the preprocessing pipeline on vabamorf's JSON, given as a dict; Returns a list: lines of analyses in the VISL CG3 input format; ''' mrf_lines = convert_vm_json_to_mrf( json_dict ) return self.process_mrf_lines( ...
[ "def", "process_vm_json", "(", "self", ",", "json_dict", ",", "*", "*", "kwargs", ")", ":", "mrf_lines", "=", "convert_vm_json_to_mrf", "(", "json_dict", ")", "return", "self", ".", "process_mrf_lines", "(", "mrf_lines", ",", "*", "*", "kwargs", ")" ]
Executes the preprocessing pipeline on vabamorf's JSON, given as a dict; Returns a list: lines of analyses in the VISL CG3 input format;
[ "Executes", "the", "preprocessing", "pipeline", "on", "vabamorf", "s", "JSON", "given", "as", "a", "dict", ";" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L945-L951
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
SyntaxPreprocessing.process_Text
def process_Text( self, text, **kwargs ): ''' Executes the preprocessing pipeline on estnltk's Text object. Returns a list: lines of analyses in the VISL CG3 input format; ''' mrf_lines = convert_Text_to_mrf( text ) return self.process_mrf_lines( mrf_lines, **kwargs )
python
def process_Text( self, text, **kwargs ): ''' Executes the preprocessing pipeline on estnltk's Text object. Returns a list: lines of analyses in the VISL CG3 input format; ''' mrf_lines = convert_Text_to_mrf( text ) return self.process_mrf_lines( mrf_lines, **kwargs )
[ "def", "process_Text", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "mrf_lines", "=", "convert_Text_to_mrf", "(", "text", ")", "return", "self", ".", "process_mrf_lines", "(", "mrf_lines", ",", "*", "*", "kwargs", ")" ]
Executes the preprocessing pipeline on estnltk's Text object. Returns a list: lines of analyses in the VISL CG3 input format;
[ "Executes", "the", "preprocessing", "pipeline", "on", "estnltk", "s", "Text", "object", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L954-L960
estnltk/estnltk
estnltk/syntax/syntax_preprocessing.py
SyntaxPreprocessing.process_mrf_lines
def process_mrf_lines( self, mrf_lines, **kwargs ): ''' Executes the preprocessing pipeline on mrf_lines. The input should be an analysis of the text in Filosoft's old mrf format; Returns the input list, where elements (tokens/analyses) have been converted into the new form...
python
def process_mrf_lines( self, mrf_lines, **kwargs ): ''' Executes the preprocessing pipeline on mrf_lines. The input should be an analysis of the text in Filosoft's old mrf format; Returns the input list, where elements (tokens/analyses) have been converted into the new form...
[ "def", "process_mrf_lines", "(", "self", ",", "mrf_lines", ",", "*", "*", "kwargs", ")", ":", "converted1", "=", "convert_mrf_to_syntax_mrf", "(", "mrf_lines", ",", "self", ".", "fs_to_synt_rules", ")", "converted2", "=", "convert_pronouns", "(", "converted1", "...
Executes the preprocessing pipeline on mrf_lines. The input should be an analysis of the text in Filosoft's old mrf format; Returns the input list, where elements (tokens/analyses) have been converted into the new format;
[ "Executes", "the", "preprocessing", "pipeline", "on", "mrf_lines", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L963-L978
estnltk/estnltk
setup.py
get_sources
def get_sources(src_dir='src', ending='.cpp'): """Function to get a list of files ending with `ending` in `src_dir`.""" return [os.path.join(src_dir, fnm) for fnm in os.listdir(src_dir) if fnm.endswith(ending)]
python
def get_sources(src_dir='src', ending='.cpp'): """Function to get a list of files ending with `ending` in `src_dir`.""" return [os.path.join(src_dir, fnm) for fnm in os.listdir(src_dir) if fnm.endswith(ending)]
[ "def", "get_sources", "(", "src_dir", "=", "'src'", ",", "ending", "=", "'.cpp'", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "src_dir", ",", "fnm", ")", "for", "fnm", "in", "os", ".", "listdir", "(", "src_dir", ")", "if", "fnm", ...
Function to get a list of files ending with `ending` in `src_dir`.
[ "Function", "to", "get", "a", "list", "of", "files", "ending", "with", "ending", "in", "src_dir", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/setup.py#L14-L16
estnltk/estnltk
estnltk/prettyprinter/terminalprettyprinter.py
_get_ANSI_colored_font
def _get_ANSI_colored_font( color ): ''' Returns an ANSI escape code (a string) corresponding to switching the font to given color, or None, if the given color could not be associated with the available colors. See also: https://en.wikipedia.org/wiki/ANSI_escape_cod...
python
def _get_ANSI_colored_font( color ): ''' Returns an ANSI escape code (a string) corresponding to switching the font to given color, or None, if the given color could not be associated with the available colors. See also: https://en.wikipedia.org/wiki/ANSI_escape_cod...
[ "def", "_get_ANSI_colored_font", "(", "color", ")", ":", "color", "=", "(", "color", ".", "replace", "(", "'-'", ",", "''", ")", ")", ".", "lower", "(", ")", "#\r", "# Bright colors:\r", "#\r", "if", "color", "==", "'white'", ":", "return", "'\\033[97m...
Returns an ANSI escape code (a string) corresponding to switching the font to given color, or None, if the given color could not be associated with the available colors. See also: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors http://stackoverflow.com/q...
[ "Returns", "an", "ANSI", "escape", "code", "(", "a", "string", ")", "corresponding", "to", "switching", "the", "font", "to", "given", "color", "or", "None", "if", "the", "given", "color", "could", "not", "be", "associated", "with", "the", "available", "col...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/terminalprettyprinter.py#L34-L78
estnltk/estnltk
estnltk/prettyprinter/terminalprettyprinter.py
_construct_start_index
def _construct_start_index(text, layer, markup_settings, spansStartingFrom=None): ''' Creates an index which stores all annotations of given text layer, indexed by the start position of the annotation (annotation[START]). Alternatively, if the index spansStartingFrom is already provided ...
python
def _construct_start_index(text, layer, markup_settings, spansStartingFrom=None): ''' Creates an index which stores all annotations of given text layer, indexed by the start position of the annotation (annotation[START]). Alternatively, if the index spansStartingFrom is already provided ...
[ "def", "_construct_start_index", "(", "text", ",", "layer", ",", "markup_settings", ",", "spansStartingFrom", "=", "None", ")", ":", "if", "not", "markup_settings", "or", "not", "isinstance", "(", "markup_settings", ",", "dict", ")", ":", "raise", "Exception", ...
Creates an index which stores all annotations of given text layer, indexed by the start position of the annotation (annotation[START]). Alternatively, if the index spansStartingFrom is already provided as an input argument, obtains annotation information from the given text layer, a...
[ "Creates", "an", "index", "which", "stores", "all", "annotations", "of", "given", "text", "layer", "indexed", "by", "the", "start", "position", "of", "the", "annotation", "(", "annotation", "[", "START", "]", ")", ".", "Alternatively", "if", "the", "index", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/terminalprettyprinter.py#L84-L207
estnltk/estnltk
estnltk/prettyprinter/terminalprettyprinter.py
_construct_end_index
def _construct_end_index( spansStartingFrom ): ''' Creates an index which stores all annotations (from spansStartingFrom) by their end position in text (annotation[END]). Each start position (in the index) is associated with a list of annotation objects (annotations ending at that...
python
def _construct_end_index( spansStartingFrom ): ''' Creates an index which stores all annotations (from spansStartingFrom) by their end position in text (annotation[END]). Each start position (in the index) is associated with a list of annotation objects (annotations ending at that...
[ "def", "_construct_end_index", "(", "spansStartingFrom", ")", ":", "endIndex", "=", "{", "}", "for", "i", "in", "spansStartingFrom", ":", "for", "span1", "in", "spansStartingFrom", "[", "i", "]", ":", "# keep the record of endTags, start positions (for determining the l...
Creates an index which stores all annotations (from spansStartingFrom) by their end position in text (annotation[END]). Each start position (in the index) is associated with a list of annotation objects (annotations ending at that position). An annotation object is also a list...
[ "Creates", "an", "index", "which", "stores", "all", "annotations", "(", "from", "spansStartingFrom", ")", "by", "their", "end", "position", "in", "text", "(", "annotation", "[", "END", "]", ")", ".", "Each", "start", "position", "(", "in", "the", "index", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/terminalprettyprinter.py#L210-L254
estnltk/estnltk
estnltk/prettyprinter/terminalprettyprinter.py
_fix_overlapping_graphics
def _fix_overlapping_graphics( spansStartingFrom ): ''' Provides a fix for overlapping annotations that are formatted graphically (underlined or printed in non-default color). If two graphically formatted annotations overlap, and if one annotation, say A, ends within another an...
python
def _fix_overlapping_graphics( spansStartingFrom ): ''' Provides a fix for overlapping annotations that are formatted graphically (underlined or printed in non-default color). If two graphically formatted annotations overlap, and if one annotation, say A, ends within another an...
[ "def", "_fix_overlapping_graphics", "(", "spansStartingFrom", ")", ":", "for", "startIndex", "in", "sorted", "(", "spansStartingFrom", ".", "keys", "(", ")", ")", ":", "for", "span1", "in", "spansStartingFrom", "[", "startIndex", "]", ":", "# If the span is not gr...
Provides a fix for overlapping annotations that are formatted graphically (underlined or printed in non-default color). If two graphically formatted annotations overlap, and if one annotation, say A, ends within another annotation, say B, then ending of graphics of A also c...
[ "Provides", "a", "fix", "for", "overlapping", "annotations", "that", "are", "formatted", "graphically", "(", "underlined", "or", "printed", "in", "non", "-", "default", "color", ")", ".", "If", "two", "graphically", "formatted", "annotations", "overlap", "and", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/terminalprettyprinter.py#L257-L296
estnltk/estnltk
estnltk/prettyprinter/terminalprettyprinter.py
_preformat
def _preformat( text, layers, markup_settings = None ): ''' Formats given text, adding a special ( ANSI-terminal compatible ) markup to the annotations of given layers, and returns formatted text as a string. *) layers is a list containing names of the layers to be preformatted in ...
python
def _preformat( text, layers, markup_settings = None ): ''' Formats given text, adding a special ( ANSI-terminal compatible ) markup to the annotations of given layers, and returns formatted text as a string. *) layers is a list containing names of the layers to be preformatted in ...
[ "def", "_preformat", "(", "text", ",", "layers", ",", "markup_settings", "=", "None", ")", ":", "if", "markup_settings", "and", "len", "(", "layers", ")", "!=", "len", "(", "markup_settings", ")", ":", "raise", "Exception", "(", "' Input arguments layers and m...
Formats given text, adding a special ( ANSI-terminal compatible ) markup to the annotations of given layers, and returns formatted text as a string. *) layers is a list containing names of the layers to be preformatted in the text (these layers must be present in Text); *) ma...
[ "Formats", "given", "text", "adding", "a", "special", "(", "ANSI", "-", "terminal", "compatible", ")", "markup", "to", "the", "annotations", "of", "given", "layers", "and", "returns", "formatted", "text", "as", "a", "string", ".", "*", ")", "layers", "is",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/terminalprettyprinter.py#L317-L409
estnltk/estnltk
estnltk/prettyprinter/terminalprettyprinter.py
tprint
def tprint( text, layers, markup_settings = None ): ''' Formats given text, adding a special ( ANSI-terminal compatible ) markup to the annotations of given layers, and prints the formatted text to the screen. *) layers is a list containing names of the layers to be preformatted in ...
python
def tprint( text, layers, markup_settings = None ): ''' Formats given text, adding a special ( ANSI-terminal compatible ) markup to the annotations of given layers, and prints the formatted text to the screen. *) layers is a list containing names of the layers to be preformatted in ...
[ "def", "tprint", "(", "text", ",", "layers", ",", "markup_settings", "=", "None", ")", ":", "if", "markup_settings", "and", "len", "(", "layers", ")", "!=", "len", "(", "markup_settings", ")", ":", "raise", "Exception", "(", "' Input arguments layers and marku...
Formats given text, adding a special ( ANSI-terminal compatible ) markup to the annotations of given layers, and prints the formatted text to the screen. *) layers is a list containing names of the layers to be preformatted in the text (these layers must be present in Text); ...
[ "Formats", "given", "text", "adding", "a", "special", "(", "ANSI", "-", "terminal", "compatible", ")", "markup", "to", "the", "annotations", "of", "given", "layers", "and", "prints", "the", "formatted", "text", "to", "the", "screen", ".", "*", ")", "layers...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/terminalprettyprinter.py#L418-L454
estnltk/estnltk
estnltk/prettyprinter/templates.py
get_mark_css
def get_mark_css(aes_name, css_value): """Generate CSS class for <mark> tag. Parameters ---------- aes_name: str The name of the class. css_value: str The value for the CSS property defined by aes_name. Returns ------- list of str The CSS codeblocks """ ...
python
def get_mark_css(aes_name, css_value): """Generate CSS class for <mark> tag. Parameters ---------- aes_name: str The name of the class. css_value: str The value for the CSS property defined by aes_name. Returns ------- list of str The CSS codeblocks """ ...
[ "def", "get_mark_css", "(", "aes_name", ",", "css_value", ")", ":", "css_prop", "=", "AES_CSS_MAP", "[", "aes_name", "]", "if", "isinstance", "(", "css_value", ",", "list", ")", ":", "return", "get_mark_css_for_rules", "(", "aes_name", ",", "css_prop", ",", ...
Generate CSS class for <mark> tag. Parameters ---------- aes_name: str The name of the class. css_value: str The value for the CSS property defined by aes_name. Returns ------- list of str The CSS codeblocks
[ "Generate", "CSS", "class", "for", "<mark", ">", "tag", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/templates.py#L44-L63
estnltk/estnltk
estnltk/mw_verbs/verbchain_nom_vinf_extender.py
VerbChainNomVInfExtender._loadSubcatRelations
def _loadSubcatRelations( self, inputFile ): ''' Laeb sisendfailist (inputFile) verb-nom/adv-vinf rektsiooniseoste mustrid. Iga muster peab olema failis eraldi real, kujul: (verbikirjeldus)\TAB(nom/adv-kirjeldus)\TAB(vinfkirjeldus) nt leid NEG aeg;S;(...
python
def _loadSubcatRelations( self, inputFile ): ''' Laeb sisendfailist (inputFile) verb-nom/adv-vinf rektsiooniseoste mustrid. Iga muster peab olema failis eraldi real, kujul: (verbikirjeldus)\TAB(nom/adv-kirjeldus)\TAB(vinfkirjeldus) nt leid NEG aeg;S;(...
[ "def", "_loadSubcatRelations", "(", "self", ",", "inputFile", ")", ":", "self", ".", "nomAdvWordTemplates", "=", "dict", "(", ")", "self", ".", "verbRules", "=", "dict", "(", ")", "self", ".", "verbToVinf", "=", "dict", "(", ")", "in_f", "=", "codecs", ...
Laeb sisendfailist (inputFile) verb-nom/adv-vinf rektsiooniseoste mustrid. Iga muster peab olema failis eraldi real, kujul: (verbikirjeldus)\TAB(nom/adv-kirjeldus)\TAB(vinfkirjeldus) nt leid NEG aeg;S;((sg|pl) (p)|adt) da leid POS võimalus;S;(...
[ "Laeb", "sisendfailist", "(", "inputFile", ")", "verb", "-", "nom", "/", "adv", "-", "vinf", "rektsiooniseoste", "mustrid", ".", "Iga", "muster", "peab", "olema", "failis", "eraldi", "real", "kujul", ":", "(", "verbikirjeldus", ")", "\\", "TAB", "(", "nom"...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_nom_vinf_extender.py#L66-L105
estnltk/estnltk
estnltk/mw_verbs/verbchain_nom_vinf_extender.py
VerbChainNomVInfExtender.tokenMatchesNomAdvVinf
def tokenMatchesNomAdvVinf( self, token, verb, vinf): ''' Teeb kindlaks, kas etteantud token v6iks olla verb'i alluv ning vinf'i ylemus (st paikneda nende vahel). Kui see nii on, tagastab j2rjendi vahele sobiva s6na morf analyysidega (meetodi _getMatchingAnalysisIDs abil), vastasel ...
python
def tokenMatchesNomAdvVinf( self, token, verb, vinf): ''' Teeb kindlaks, kas etteantud token v6iks olla verb'i alluv ning vinf'i ylemus (st paikneda nende vahel). Kui see nii on, tagastab j2rjendi vahele sobiva s6na morf analyysidega (meetodi _getMatchingAnalysisIDs abil), vastasel ...
[ "def", "tokenMatchesNomAdvVinf", "(", "self", ",", "token", ",", "verb", ",", "vinf", ")", ":", "if", "verb", "in", "self", ".", "verbRules", ":", "for", "(", "nounAdv", ",", "vinf1", ")", "in", "self", ".", "verbRules", "[", "verb", "]", ":", "if", ...
Teeb kindlaks, kas etteantud token v6iks olla verb'i alluv ning vinf'i ylemus (st paikneda nende vahel). Kui see nii on, tagastab j2rjendi vahele sobiva s6na morf analyysidega (meetodi _getMatchingAnalysisIDs abil), vastasel juhul tagastab tyhja j2rjendi;
[ "Teeb", "kindlaks", "kas", "etteantud", "token", "v6iks", "olla", "verb", "i", "alluv", "ning", "vinf", "i", "ylemus", "(", "st", "paikneda", "nende", "vahel", ")", ".", "Kui", "see", "nii", "on", "tagastab", "j2rjendi", "vahele", "sobiva", "s6na", "morf",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_nom_vinf_extender.py#L107-L117
estnltk/estnltk
estnltk/mw_verbs/verbchain_nom_vinf_extender.py
VerbChainNomVInfExtender.extendChainsInSentence
def extendChainsInSentence( self, sentence, foundChains ): ''' Rakendab meetodit self.extendChainsInClause() antud lause igal osalausel. ''' # 1) Preprocessing clauses = getClausesByClauseIDs( sentence ) # 2) Extend verb chains in each clause allDetectedVerbChains...
python
def extendChainsInSentence( self, sentence, foundChains ): ''' Rakendab meetodit self.extendChainsInClause() antud lause igal osalausel. ''' # 1) Preprocessing clauses = getClausesByClauseIDs( sentence ) # 2) Extend verb chains in each clause allDetectedVerbChains...
[ "def", "extendChainsInSentence", "(", "self", ",", "sentence", ",", "foundChains", ")", ":", "# 1) Preprocessing\r", "clauses", "=", "getClausesByClauseIDs", "(", "sentence", ")", "# 2) Extend verb chains in each clause\r", "allDetectedVerbChains", "=", "[", "]", "for", ...
Rakendab meetodit self.extendChainsInClause() antud lause igal osalausel.
[ "Rakendab", "meetodit", "self", ".", "extendChainsInClause", "()", "antud", "lause", "igal", "osalausel", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_nom_vinf_extender.py#L120-L130
estnltk/estnltk
estnltk/mw_verbs/verbchain_nom_vinf_extender.py
VerbChainNomVInfExtender._isLikelyNotPhrase
def _isLikelyNotPhrase( self, headVerbRoot, headVerbWID, nomAdvWID, widToToken): ''' Kontrollib, et nom/adv ei kuuluks mingi suurema fraasi kooseisu (poleks fraasi peas6na). Tagastab True, kui: *) nom/adv j2rgneb vahetult peaverbile *) või nom/adv on vahetult osalau...
python
def _isLikelyNotPhrase( self, headVerbRoot, headVerbWID, nomAdvWID, widToToken): ''' Kontrollib, et nom/adv ei kuuluks mingi suurema fraasi kooseisu (poleks fraasi peas6na). Tagastab True, kui: *) nom/adv j2rgneb vahetult peaverbile *) või nom/adv on vahetult osalau...
[ "def", "_isLikelyNotPhrase", "(", "self", ",", "headVerbRoot", ",", "headVerbWID", ",", "nomAdvWID", ",", "widToToken", ")", ":", "minWID", "=", "min", "(", "widToToken", ".", "keys", "(", ")", ")", "nomAdvToken", "=", "widToToken", "[", "nomAdvWID", "]", ...
Kontrollib, et nom/adv ei kuuluks mingi suurema fraasi kooseisu (poleks fraasi peas6na). Tagastab True, kui: *) nom/adv j2rgneb vahetult peaverbile *) või nom/adv on vahetult osalause alguses *) või nom-ile eelneb vahetult selline s6na, mis kindlasti ei saa o...
[ "Kontrollib", "et", "nom", "/", "adv", "ei", "kuuluks", "mingi", "suurema", "fraasi", "kooseisu", "(", "poleks", "fraasi", "peas6na", ")", ".", "Tagastab", "True", "kui", ":", "*", ")", "nom", "/", "adv", "j2rgneb", "vahetult", "peaverbile", "*", ")", "v...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_nom_vinf_extender.py#L133-L207
estnltk/estnltk
estnltk/mw_verbs/verbchain_nom_vinf_extender.py
VerbChainNomVInfExtender._canBeExpanded
def _canBeExpanded( self, headVerbRoot, headVerbWID, suitableNomAdvExpansions, expansionVerbs, widToToken ): ''' Teeb kindlaks, kas kontekst on verbiahela laiendamiseks piisavalt selge/yhene: 1) Nii 'nom/adv' kandidaate kui ka Vinf kandidaate on täpselt üks; 2) Nom/adv ei kuulu mi...
python
def _canBeExpanded( self, headVerbRoot, headVerbWID, suitableNomAdvExpansions, expansionVerbs, widToToken ): ''' Teeb kindlaks, kas kontekst on verbiahela laiendamiseks piisavalt selge/yhene: 1) Nii 'nom/adv' kandidaate kui ka Vinf kandidaate on täpselt üks; 2) Nom/adv ei kuulu mi...
[ "def", "_canBeExpanded", "(", "self", ",", "headVerbRoot", ",", "headVerbWID", ",", "suitableNomAdvExpansions", ",", "expansionVerbs", ",", "widToToken", ")", ":", "if", "len", "(", "suitableNomAdvExpansions", ")", "==", "1", "and", "expansionVerbs", ":", "# Kontr...
Teeb kindlaks, kas kontekst on verbiahela laiendamiseks piisavalt selge/yhene: 1) Nii 'nom/adv' kandidaate kui ka Vinf kandidaate on täpselt üks; 2) Nom/adv ei kuulu mingi suurema fraasi kooseisu (meetodi _isLikelyNotPhrase() abil); Kui tingimused täidetud, tagastab lisatava v...
[ "Teeb", "kindlaks", "kas", "kontekst", "on", "verbiahela", "laiendamiseks", "piisavalt", "selge", "/", "yhene", ":", "1", ")", "Nii", "nom", "/", "adv", "kandidaate", "kui", "ka", "Vinf", "kandidaate", "on", "täpselt", "üks", ";", "2", ")", "Nom", "/", "...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_nom_vinf_extender.py#L210-L229
estnltk/estnltk
estnltk/mw_verbs/verbchain_nom_vinf_extender.py
VerbChainNomVInfExtender.extendChainsInClause
def extendChainsInClause( self, clause, clauseID, foundChains ): ''' Proovime etteantud osalauses leiduvaid verbiahelaid täiendada 'verb-nom/adv-vinf' rektsiooniseostega, nt: andma + võimalus + Vda : talle anti_0 võimalus_0 olukorda parandada_0 olema + vaja + V...
python
def extendChainsInClause( self, clause, clauseID, foundChains ): ''' Proovime etteantud osalauses leiduvaid verbiahelaid täiendada 'verb-nom/adv-vinf' rektsiooniseostega, nt: andma + võimalus + Vda : talle anti_0 võimalus_0 olukorda parandada_0 olema + vaja + V...
[ "def", "extendChainsInClause", "(", "self", ",", "clause", ",", "clauseID", ",", "foundChains", ")", ":", "expansionPerformed", "=", "False", "# J22dvustame s6nad, mis kuuluvad juba mingi tuvastatud verbifraasi koosseisu\r", "annotatedWords", "=", "[", "]", "for", "verbObj"...
Proovime etteantud osalauses leiduvaid verbiahelaid täiendada 'verb-nom/adv-vinf' rektsiooniseostega, nt: andma + võimalus + Vda : talle anti_0 võimalus_0 olukorda parandada_0 olema + vaja + Vda : nüüd on_0 küll vaja_0 asi lõpetada_0 Teeme seda kahel m...
[ "Proovime", "etteantud", "osalauses", "leiduvaid", "verbiahelaid", "täiendada", "verb", "-", "nom", "/", "adv", "-", "vinf", "rektsiooniseostega", "nt", ":", "andma", "+", "võimalus", "+", "Vda", ":", "talle", "anti_0", "võimalus_0", "olukorda", "parandada_0", "...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_nom_vinf_extender.py#L232-L418
estnltk/estnltk
estnltk/wiki/sections.py
sectionsParser
def sectionsParser(text): """ :param text: the whole text of an wikipedia article :return: a list of nested section objects [{title: "Rahvaarv", text: "Eestis elab..."}, {title: "Ajalugu", text: "..."}, sections: [{title: "Rahvaarv", ...
python
def sectionsParser(text): """ :param text: the whole text of an wikipedia article :return: a list of nested section objects [{title: "Rahvaarv", text: "Eestis elab..."}, {title: "Ajalugu", text: "..."}, sections: [{title: "Rahvaarv", ...
[ "def", "sectionsParser", "(", "text", ")", ":", "textStart", "=", "0", "#Split the text in sections. Hackish part, but seems to work fine.", "entries", "=", "re", ".", "split", "(", "\"\\n=\"", ",", "text", "[", "textStart", ":", "]", ")", "stack", "=", "[", "["...
:param text: the whole text of an wikipedia article :return: a list of nested section objects [{title: "Rahvaarv", text: "Eestis elab..."}, {title: "Ajalugu", text: "..."}, sections: [{title: "Rahvaarv", text: "Eestis elab..."}, ...
[ ":", "param", "text", ":", "the", "whole", "text", "of", "an", "wikipedia", "article", ":", "return", ":", "a", "list", "of", "nested", "section", "objects", "[", "{", "title", ":", "Rahvaarv", "text", ":", "Eestis", "elab", "...", "}", "{", "title", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/sections.py#L13-L144
estnltk/estnltk
estnltk/textcleaner.py
TextCleaner.clean
def clean(self, text): """Remove all unwanted characters from text.""" return ''.join([c for c in text if c in self.alphabet])
python
def clean(self, text): """Remove all unwanted characters from text.""" return ''.join([c for c in text if c in self.alphabet])
[ "def", "clean", "(", "self", ",", "text", ")", ":", "return", "''", ".", "join", "(", "[", "c", "for", "c", "in", "text", "if", "c", "in", "self", ".", "alphabet", "]", ")" ]
Remove all unwanted characters from text.
[ "Remove", "all", "unwanted", "characters", "from", "text", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/textcleaner.py#L36-L38
estnltk/estnltk
estnltk/textcleaner.py
TextCleaner.invalid_characters
def invalid_characters(self, text): """Give simple list of invalid characters present in text.""" return ''.join(sorted(set([c for c in text if c not in self.alphabet])))
python
def invalid_characters(self, text): """Give simple list of invalid characters present in text.""" return ''.join(sorted(set([c for c in text if c not in self.alphabet])))
[ "def", "invalid_characters", "(", "self", ",", "text", ")", ":", "return", "''", ".", "join", "(", "sorted", "(", "set", "(", "[", "c", "for", "c", "in", "text", "if", "c", "not", "in", "self", ".", "alphabet", "]", ")", ")", ")" ]
Give simple list of invalid characters present in text.
[ "Give", "simple", "list", "of", "invalid", "characters", "present", "in", "text", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/textcleaner.py#L49-L51
estnltk/estnltk
estnltk/textcleaner.py
TextCleaner.find_invalid_chars
def find_invalid_chars(self, text, context_size=20): """Find invalid characters in text and store information about the findings. Parameters ---------- context_size: int How many characters to return as the context. """ result = defaultdict(list) ...
python
def find_invalid_chars(self, text, context_size=20): """Find invalid characters in text and store information about the findings. Parameters ---------- context_size: int How many characters to return as the context. """ result = defaultdict(list) ...
[ "def", "find_invalid_chars", "(", "self", ",", "text", ",", "context_size", "=", "20", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "for", "idx", ",", "char", "in", "enumerate", "(", "text", ")", ":", "if", "char", "not", "in", "self", "...
Find invalid characters in text and store information about the findings. Parameters ---------- context_size: int How many characters to return as the context.
[ "Find", "invalid", "characters", "in", "text", "and", "store", "information", "about", "the", "findings", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/textcleaner.py#L53-L69
estnltk/estnltk
estnltk/textcleaner.py
TextCleaner.compute_report
def compute_report(self, texts, context_size=10): """Compute statistics of invalid characters on given texts. Parameters ---------- texts: list of str The texts to search for invalid characters. context_size: int How many characters to return as the conte...
python
def compute_report(self, texts, context_size=10): """Compute statistics of invalid characters on given texts. Parameters ---------- texts: list of str The texts to search for invalid characters. context_size: int How many characters to return as the conte...
[ "def", "compute_report", "(", "self", ",", "texts", ",", "context_size", "=", "10", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "for", "text", "in", "texts", ":", "for", "char", ",", "examples", "in", "self", ".", "find_invalid_chars", "(",...
Compute statistics of invalid characters on given texts. Parameters ---------- texts: list of str The texts to search for invalid characters. context_size: int How many characters to return as the context. Returns ------- dict of (char ->...
[ "Compute", "statistics", "of", "invalid", "characters", "on", "given", "texts", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/textcleaner.py#L71-L92