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 |
|---|---|---|---|---|---|---|---|---|---|---|
estnltk/estnltk | estnltk/textcleaner.py | TextCleaner.report | def report(self, texts, n_examples=10, context_size=10, f=sys.stdout):
"""Compute statistics of invalid characters and print them.
Parameters
----------
texts: list of str
The texts to search for invalid characters.
n_examples: int
How many examples to di... | python | def report(self, texts, n_examples=10, context_size=10, f=sys.stdout):
"""Compute statistics of invalid characters and print them.
Parameters
----------
texts: list of str
The texts to search for invalid characters.
n_examples: int
How many examples to di... | [
"def",
"report",
"(",
"self",
",",
"texts",
",",
"n_examples",
"=",
"10",
",",
"context_size",
"=",
"10",
",",
"f",
"=",
"sys",
".",
"stdout",
")",
":",
"result",
"=",
"list",
"(",
"self",
".",
"compute_report",
"(",
"texts",
",",
"context_size",
")"... | Compute statistics of invalid characters and print them.
Parameters
----------
texts: list of str
The texts to search for invalid characters.
n_examples: int
How many examples to display per invalid character.
context_size: int
How many charac... | [
"Compute",
"statistics",
"of",
"invalid",
"characters",
"and",
"print",
"them",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/textcleaner.py#L94-L128 |
estnltk/estnltk | estnltk/syntax/parsers.py | VISLCG3Parser.parse_text | def parse_text(self, text, **kwargs):
""" Parses given text with VISLCG3 based syntactic analyzer.
As a result of parsing, the input Text object will obtain a new
layer named LAYER_VISLCG3, which contains a list of dicts.
Each dicts corresponds to analysis of... | python | def parse_text(self, text, **kwargs):
""" Parses given text with VISLCG3 based syntactic analyzer.
As a result of parsing, the input Text object will obtain a new
layer named LAYER_VISLCG3, which contains a list of dicts.
Each dicts corresponds to analysis of... | [
"def",
"parse_text",
"(",
"self",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"# a) get the configuration:",
"apply_tag_analysis",
"=",
"False",
"augment_words",
"=",
"False",
"all_return_types",
"=",
"[",
"\"text\"",
",",
"\"vislcg3\"",
",",
"\"trees\"",
",... | Parses given text with VISLCG3 based syntactic analyzer.
As a result of parsing, the input Text object will obtain a new
layer named LAYER_VISLCG3, which contains a list of dicts.
Each dicts corresponds to analysis of a single word token, and
has the foll... | [
"Parses",
"given",
"text",
"with",
"VISLCG3",
"based",
"syntactic",
"analyzer",
".",
"As",
"a",
"result",
"of",
"parsing",
"the",
"input",
"Text",
"object",
"will",
"obtain",
"a",
"new",
"layer",
"named",
"LAYER_VISLCG3",
"which",
"contains",
"a",
"list",
"o... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/parsers.py#L143-L269 |
estnltk/estnltk | estnltk/syntax/parsers.py | VISLCG3Parser._filter_kwargs | def _filter_kwargs(self, keep_list, **kwargs):
''' Filters the dict of *kwargs*, keeping only arguments
whose keys are in *keep_list* and discarding all other
arguments.
Based on the filtring, constructs and returns a new
dict.
'''
n... | python | def _filter_kwargs(self, keep_list, **kwargs):
''' Filters the dict of *kwargs*, keeping only arguments
whose keys are in *keep_list* and discarding all other
arguments.
Based on the filtring, constructs and returns a new
dict.
'''
n... | [
"def",
"_filter_kwargs",
"(",
"self",
",",
"keep_list",
",",
"*",
"*",
"kwargs",
")",
":",
"new_kwargs",
"=",
"{",
"}",
"for",
"argName",
",",
"argVal",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"argName",
".",
"lower",
"(",
")",
"in",
"ke... | Filters the dict of *kwargs*, keeping only arguments
whose keys are in *keep_list* and discarding all other
arguments.
Based on the filtring, constructs and returns a new
dict. | [
"Filters",
"the",
"dict",
"of",
"*",
"kwargs",
"*",
"keeping",
"only",
"arguments",
"whose",
"keys",
"are",
"in",
"*",
"keep_list",
"*",
"and",
"discarding",
"all",
"other",
"arguments",
".",
"Based",
"on",
"the",
"filtring",
"constructs",
"and",
"returns",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/parsers.py#L272-L284 |
estnltk/estnltk | estnltk/syntax/parsers.py | VISLCG3Parser._augment_text_w_syntactic_info | def _augment_text_w_syntactic_info( self, text, text_layer ):
''' Augments given Text object with the syntactic information
from the *text_layer*. More specifically, adds information
about SYNTAX_LABEL, SYNTAX_HEAD and DEPREL to each token
in the Text object;
... | python | def _augment_text_w_syntactic_info( self, text, text_layer ):
''' Augments given Text object with the syntactic information
from the *text_layer*. More specifically, adds information
about SYNTAX_LABEL, SYNTAX_HEAD and DEPREL to each token
in the Text object;
... | [
"def",
"_augment_text_w_syntactic_info",
"(",
"self",
",",
"text",
",",
"text_layer",
")",
":",
"j",
"=",
"0",
"for",
"sentence",
"in",
"text",
".",
"divide",
"(",
"layer",
"=",
"WORDS",
",",
"by",
"=",
"SENTENCES",
")",
":",
"for",
"i",
"in",
"range",... | Augments given Text object with the syntactic information
from the *text_layer*. More specifically, adds information
about SYNTAX_LABEL, SYNTAX_HEAD and DEPREL to each token
in the Text object;
(!) Note: this method is added to provide some initial
... | [
"Augments",
"given",
"Text",
"object",
"with",
"the",
"syntactic",
"information",
"from",
"the",
"*",
"text_layer",
"*",
".",
"More",
"specifically",
"adds",
"information",
"about",
"SYNTAX_LABEL",
"SYNTAX_HEAD",
"and",
"DEPREL",
"to",
"each",
"token",
"in",
"th... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/parsers.py#L287-L317 |
estnltk/estnltk | estnltk/syntax/parsers.py | MaltParser.parse_text | def parse_text( self, text, **kwargs ):
''' Parses given text with Maltparser.
As a result of parsing, the input Text object will obtain a new
layer named LAYER_CONLL, which contains a list of dicts.
Each dicts corresponds to analysis of a single word token, ... | python | def parse_text( self, text, **kwargs ):
''' Parses given text with Maltparser.
As a result of parsing, the input Text object will obtain a new
layer named LAYER_CONLL, which contains a list of dicts.
Each dicts corresponds to analysis of a single word token, ... | [
"def",
"parse_text",
"(",
"self",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"# a) get the configuration:",
"augment_words",
"=",
"False",
"all_return_types",
"=",
"[",
"\"text\"",
",",
"\"conll\"",
",",
"\"trees\"",
",",
"\"dep_graphs\"",
"]",
"return_type... | Parses given text with Maltparser.
As a result of parsing, the input Text object will obtain a new
layer named LAYER_CONLL, which contains a list of dicts.
Each dicts corresponds to analysis of a single word token, and
has the following attributes (at min... | [
"Parses",
"given",
"text",
"with",
"Maltparser",
".",
"As",
"a",
"result",
"of",
"parsing",
"the",
"input",
"Text",
"object",
"will",
"obtain",
"a",
"new",
"layer",
"named",
"LAYER_CONLL",
"which",
"contains",
"a",
"list",
"of",
"dicts",
".",
"Each",
"dict... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/parsers.py#L400-L520 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _create_clause_based_dep_links | def _create_clause_based_dep_links( orig_text, layer=LAYER_CONLL ):
''' Rewrites dependency links in the text from sentence-based linking to clause-
based linking:
*) words which have their parent outside-the-clause will become root
nodes (will obtain link value -1), and
... | python | def _create_clause_based_dep_links( orig_text, layer=LAYER_CONLL ):
''' Rewrites dependency links in the text from sentence-based linking to clause-
based linking:
*) words which have their parent outside-the-clause will become root
nodes (will obtain link value -1), and
... | [
"def",
"_create_clause_based_dep_links",
"(",
"orig_text",
",",
"layer",
"=",
"LAYER_CONLL",
")",
":",
"sent_start_index",
"=",
"0",
"for",
"sent_text",
"in",
"orig_text",
".",
"split_by",
"(",
"SENTENCES",
")",
":",
"# 1) Create a mapping: from sentence-based dependenc... | Rewrites dependency links in the text from sentence-based linking to clause-
based linking:
*) words which have their parent outside-the-clause will become root
nodes (will obtain link value -1), and
*) words which have their parent inside-the-clause will have parent index
... | [
"Rewrites",
"dependency",
"links",
"in",
"the",
"text",
"from",
"sentence",
"-",
"based",
"linking",
"to",
"clause",
"-",
"based",
"linking",
":",
"*",
")",
"words",
"which",
"have",
"their",
"parent",
"outside",
"-",
"the",
"-",
"clause",
"will",
"become"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L267-L312 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | __sort_analyses | def __sort_analyses(sentence):
''' Sorts analysis of all the words in the sentence.
This is required for consistency, because by default, analyses are
listed in arbitrary order; '''
for word in sentence:
if ANALYSIS not in word:
raise Exception( '(!) Error: no analysis foun... | python | def __sort_analyses(sentence):
''' Sorts analysis of all the words in the sentence.
This is required for consistency, because by default, analyses are
listed in arbitrary order; '''
for word in sentence:
if ANALYSIS not in word:
raise Exception( '(!) Error: no analysis foun... | [
"def",
"__sort_analyses",
"(",
"sentence",
")",
":",
"for",
"word",
"in",
"sentence",
":",
"if",
"ANALYSIS",
"not",
"in",
"word",
":",
"raise",
"Exception",
"(",
"'(!) Error: no analysis found from word: '",
"+",
"str",
"(",
"word",
")",
")",
"else",
":",
"w... | Sorts analysis of all the words in the sentence.
This is required for consistency, because by default, analyses are
listed in arbitrary order; | [
"Sorts",
"analysis",
"of",
"all",
"the",
"words",
"in",
"the",
"sentence",
".",
"This",
"is",
"required",
"for",
"consistency",
"because",
"by",
"default",
"analyses",
"are",
"listed",
"in",
"arbitrary",
"order",
";"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L315-L325 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | convert_text_to_CONLL | def convert_text_to_CONLL( text, feature_generator ):
''' Converts given estnltk Text object into CONLL format and returns as a
string.
Uses given *feature_generator* to produce fields ID, FORM, LEMMA, CPOSTAG,
POSTAG, FEATS for each token.
Fields to predict (HEAD, DEPREL) will be ... | python | def convert_text_to_CONLL( text, feature_generator ):
''' Converts given estnltk Text object into CONLL format and returns as a
string.
Uses given *feature_generator* to produce fields ID, FORM, LEMMA, CPOSTAG,
POSTAG, FEATS for each token.
Fields to predict (HEAD, DEPREL) will be ... | [
"def",
"convert_text_to_CONLL",
"(",
"text",
",",
"feature_generator",
")",
":",
"from",
"estnltk",
".",
"text",
"import",
"Text",
"if",
"not",
"isinstance",
"(",
"text",
",",
"Text",
")",
":",
"raise",
"Exception",
"(",
"'(!) Unexpected type of input argument! Ex... | Converts given estnltk Text object into CONLL format and returns as a
string.
Uses given *feature_generator* to produce fields ID, FORM, LEMMA, CPOSTAG,
POSTAG, FEATS for each token.
Fields to predict (HEAD, DEPREL) will be left empty.
This method is used in preparing parsing &... | [
"Converts",
"given",
"estnltk",
"Text",
"object",
"into",
"CONLL",
"format",
"and",
"returns",
"as",
"a",
"string",
".",
"Uses",
"given",
"*",
"feature_generator",
"*",
"to",
"produce",
"fields",
"ID",
"FORM",
"LEMMA",
"CPOSTAG",
"POSTAG",
"FEATS",
"for",
"e... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L328-L379 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | convert_text_w_syntax_to_CONLL | def convert_text_w_syntax_to_CONLL( text, feature_generator, layer=LAYER_CONLL ):
''' Converts given estnltk Text object into CONLL format and returns as a
string.
Uses given *feature_generator* to produce fields ID, FORM, LEMMA, CPOSTAG,
POSTAG, FEATS for each token.
Fills fields ... | python | def convert_text_w_syntax_to_CONLL( text, feature_generator, layer=LAYER_CONLL ):
''' Converts given estnltk Text object into CONLL format and returns as a
string.
Uses given *feature_generator* to produce fields ID, FORM, LEMMA, CPOSTAG,
POSTAG, FEATS for each token.
Fills fields ... | [
"def",
"convert_text_w_syntax_to_CONLL",
"(",
"text",
",",
"feature_generator",
",",
"layer",
"=",
"LAYER_CONLL",
")",
":",
"from",
"estnltk",
".",
"text",
"import",
"Text",
"if",
"not",
"isinstance",
"(",
"text",
",",
"Text",
")",
":",
"raise",
"Exception",
... | Converts given estnltk Text object into CONLL format and returns as a
string.
Uses given *feature_generator* to produce fields ID, FORM, LEMMA, CPOSTAG,
POSTAG, FEATS for each token.
Fills fields to predict (HEAD, DEPREL) with the syntactic information from
given *layer* (defau... | [
"Converts",
"given",
"estnltk",
"Text",
"object",
"into",
"CONLL",
"format",
"and",
"returns",
"as",
"a",
"string",
".",
"Uses",
"given",
"*",
"feature_generator",
"*",
"to",
"produce",
"fields",
"ID",
"FORM",
"LEMMA",
"CPOSTAG",
"POSTAG",
"FEATS",
"for",
"e... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L382-L449 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _executeMaltparser | def _executeMaltparser( input_string, maltparser_dir, maltparser_jar, model_name ):
''' Executes Maltparser on given (CONLL-style) input string, and
returns the result. The result is an array of lines from Maltparser's
output.
Parameters
----------
input_string: st... | python | def _executeMaltparser( input_string, maltparser_dir, maltparser_jar, model_name ):
''' Executes Maltparser on given (CONLL-style) input string, and
returns the result. The result is an array of lines from Maltparser's
output.
Parameters
----------
input_string: st... | [
"def",
"_executeMaltparser",
"(",
"input_string",
",",
"maltparser_dir",
",",
"maltparser_jar",
",",
"model_name",
")",
":",
"temp_input_file",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"'malt_in.'",
",",
"mode",
"=",
"'w'",
",",
"delete",
... | Executes Maltparser on given (CONLL-style) input string, and
returns the result. The result is an array of lines from Maltparser's
output.
Parameters
----------
input_string: string
input text in CONLL format;
maltparser_jar: string
... | [
"Executes",
"Maltparser",
"on",
"given",
"(",
"CONLL",
"-",
"style",
")",
"input",
"string",
"and",
"returns",
"the",
"result",
".",
"The",
"result",
"is",
"an",
"array",
"of",
"lines",
"from",
"Maltparser",
"s",
"output",
".",
"Parameters",
"----------",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L458-L523 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | loadCONLLannotations | def loadCONLLannotations( in_file, addDepRels = False, splitIntoSentences = True ):
''' Loads syntactically annotated text from CONLL format input file and
returns as an array of tokens, where each token is represented as
an array in the format:
[sentenceID, wordID, tokenString, morphIn... | python | def loadCONLLannotations( in_file, addDepRels = False, splitIntoSentences = True ):
''' Loads syntactically annotated text from CONLL format input file and
returns as an array of tokens, where each token is represented as
an array in the format:
[sentenceID, wordID, tokenString, morphIn... | [
"def",
"loadCONLLannotations",
"(",
"in_file",
",",
"addDepRels",
"=",
"False",
",",
"splitIntoSentences",
"=",
"True",
")",
":",
"sentenceCount",
"=",
"0",
"wordCountInSent",
"=",
"0",
"tokens",
"=",
"[",
"]",
"in_f",
"=",
"codecs",
".",
"open",
"(",
"in_... | Loads syntactically annotated text from CONLL format input file and
returns as an array of tokens, where each token is represented as
an array in the format:
[sentenceID, wordID, tokenString, morphInfo, selfID, parentID]
If addDepRels == True, then the dependency relation label is a... | [
"Loads",
"syntactically",
"annotated",
"text",
"from",
"CONLL",
"format",
"input",
"file",
"and",
"returns",
"as",
"an",
"array",
"of",
"tokens",
"where",
"each",
"token",
"is",
"represented",
"as",
"an",
"array",
"in",
"the",
"format",
":",
"[",
"sentenceID... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L531-L588 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | convertCONLLtoText | def convertCONLLtoText( in_file, addDepRels = False, verbose = False, **kwargs ):
''' Loads CONLL format data from given input file, and creates
estnltk Text objects from the data, one Text per each
sentence. Returns a list of Text objects.
By default, applies estnltk's morphologic... | python | def convertCONLLtoText( in_file, addDepRels = False, verbose = False, **kwargs ):
''' Loads CONLL format data from given input file, and creates
estnltk Text objects from the data, one Text per each
sentence. Returns a list of Text objects.
By default, applies estnltk's morphologic... | [
"def",
"convertCONLLtoText",
"(",
"in_file",
",",
"addDepRels",
"=",
"False",
",",
"verbose",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"estnltk",
".",
"text",
"import",
"Text",
"sentences",
"=",
"loadCONLLannotations",
"(",
"in_file",
",",
... | Loads CONLL format data from given input file, and creates
estnltk Text objects from the data, one Text per each
sentence. Returns a list of Text objects.
By default, applies estnltk's morphological analysis, clause
detection, and verb chain detection to each input sentence.
... | [
"Loads",
"CONLL",
"format",
"data",
"from",
"given",
"input",
"file",
"and",
"creates",
"estnltk",
"Text",
"objects",
"from",
"the",
"data",
"one",
"Text",
"per",
"each",
"sentence",
".",
"Returns",
"a",
"list",
"of",
"Text",
"objects",
".",
"By",
"default... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L591-L632 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | augmentTextWithCONLLstr | def augmentTextWithCONLLstr( conll_str_array, text ):
''' Augments given Text object with the information from Maltparser's output.
More specifically, adds information about SYNTAX_LABEL, SYNTAX_HEAD and
DEPREL to each token in the Text object;
'''
j = 0
for sentence in text.divide( laye... | python | def augmentTextWithCONLLstr( conll_str_array, text ):
''' Augments given Text object with the information from Maltparser's output.
More specifically, adds information about SYNTAX_LABEL, SYNTAX_HEAD and
DEPREL to each token in the Text object;
'''
j = 0
for sentence in text.divide( laye... | [
"def",
"augmentTextWithCONLLstr",
"(",
"conll_str_array",
",",
"text",
")",
":",
"j",
"=",
"0",
"for",
"sentence",
"in",
"text",
".",
"divide",
"(",
"layer",
"=",
"WORDS",
",",
"by",
"=",
"SENTENCES",
")",
":",
"sentence",
"=",
"__sort_analyses",
"(",
"s... | Augments given Text object with the information from Maltparser's output.
More specifically, adds information about SYNTAX_LABEL, SYNTAX_HEAD and
DEPREL to each token in the Text object; | [
"Augments",
"given",
"Text",
"object",
"with",
"the",
"information",
"from",
"Maltparser",
"s",
"output",
".",
"More",
"specifically",
"adds",
"information",
"about",
"SYNTAX_LABEL",
"SYNTAX_HEAD",
"and",
"DEPREL",
"to",
"each",
"token",
"in",
"the",
"Text",
"ob... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L635-L658 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | align_CONLL_with_Text | def align_CONLL_with_Text( lines, text, feature_generator, **kwargs ):
''' Aligns CONLL format syntactic analysis (a list of strings) with given EstNLTK's Text
object.
Basically, for each word position in the Text object, finds corresponding line(s) in
the CONLL format output;
Retur... | python | def align_CONLL_with_Text( lines, text, feature_generator, **kwargs ):
''' Aligns CONLL format syntactic analysis (a list of strings) with given EstNLTK's Text
object.
Basically, for each word position in the Text object, finds corresponding line(s) in
the CONLL format output;
Retur... | [
"def",
"align_CONLL_with_Text",
"(",
"lines",
",",
"text",
",",
"feature_generator",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"estnltk",
".",
"text",
"import",
"Text",
"if",
"not",
"isinstance",
"(",
"text",
",",
"Text",
")",
":",
"raise",
"Exception",
... | Aligns CONLL format syntactic analysis (a list of strings) with given EstNLTK's Text
object.
Basically, for each word position in the Text object, finds corresponding line(s) in
the CONLL format output;
Returns a list of dicts, where each dict has following attributes:
'start'... | [
"Aligns",
"CONLL",
"format",
"syntactic",
"analysis",
"(",
"a",
"list",
"of",
"strings",
")",
"with",
"given",
"EstNLTK",
"s",
"Text",
"object",
".",
"Basically",
"for",
"each",
"word",
"position",
"in",
"the",
"Text",
"object",
"finds",
"corresponding",
"li... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L661-L830 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _get_clause_words | def _get_clause_words( sentence_text, clause_id ):
''' Collects clause with index *clause_id* from given *sentence_text*.
Returns a pair (clause, isEmbedded), where:
*clause* is a list of word tokens in the clause;
*isEmbedded* is a bool indicating whether the clause is embedded;
'''
... | python | def _get_clause_words( sentence_text, clause_id ):
''' Collects clause with index *clause_id* from given *sentence_text*.
Returns a pair (clause, isEmbedded), where:
*clause* is a list of word tokens in the clause;
*isEmbedded* is a bool indicating whether the clause is embedded;
'''
... | [
"def",
"_get_clause_words",
"(",
"sentence_text",
",",
"clause_id",
")",
":",
"clause",
"=",
"[",
"]",
"isEmbedded",
"=",
"False",
"indices",
"=",
"sentence_text",
".",
"clause_indices",
"clause_anno",
"=",
"sentence_text",
".",
"clause_annotations",
"for",
"wid",... | Collects clause with index *clause_id* from given *sentence_text*.
Returns a pair (clause, isEmbedded), where:
*clause* is a list of word tokens in the clause;
*isEmbedded* is a bool indicating whether the clause is embedded; | [
"Collects",
"clause",
"with",
"index",
"*",
"clause_id",
"*",
"from",
"given",
"*",
"sentence_text",
"*",
".",
"Returns",
"a",
"pair",
"(",
"clause",
"isEmbedded",
")",
"where",
":",
"*",
"clause",
"*",
"is",
"a",
"list",
"of",
"word",
"tokens",
"in",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L893-L908 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _detect_quotes | def _detect_quotes( sentence_text, wid, fromRight = True ):
''' Searches for quotation marks (both opening and closing) closest to
given location in sentence (given as word index *wid*);
If *fromRight == True* (default), searches from the right (all the
words having index greater ... | python | def _detect_quotes( sentence_text, wid, fromRight = True ):
''' Searches for quotation marks (both opening and closing) closest to
given location in sentence (given as word index *wid*);
If *fromRight == True* (default), searches from the right (all the
words having index greater ... | [
"def",
"_detect_quotes",
"(",
"sentence_text",
",",
"wid",
",",
"fromRight",
"=",
"True",
")",
":",
"i",
"=",
"wid",
"while",
"(",
"i",
">",
"-",
"1",
"and",
"i",
"<",
"len",
"(",
"sentence_text",
"[",
"WORDS",
"]",
")",
")",
":",
"token",
"=",
"... | Searches for quotation marks (both opening and closing) closest to
given location in sentence (given as word index *wid*);
If *fromRight == True* (default), searches from the right (all the
words having index greater than *wid*), otherwise, searches from the
left (all the wor... | [
"Searches",
"for",
"quotation",
"marks",
"(",
"both",
"opening",
"and",
"closing",
")",
"closest",
"to",
"given",
"location",
"in",
"sentence",
"(",
"given",
"as",
"word",
"index",
"*",
"wid",
"*",
")",
";",
"If",
"*",
"fromRight",
"==",
"True",
"*",
"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L915-L933 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | detect_sentence_ending_saying_verbs | def detect_sentence_ending_saying_verbs( edt_sent_text ):
''' Detects cases where a saying verb (potential root of the sentence) ends the sentence.
We use a simple heuristic: if the given sentence has multiple clauses, and the last main
verb in the sentence is preceded by ", but is not followed by... | python | def detect_sentence_ending_saying_verbs( edt_sent_text ):
''' Detects cases where a saying verb (potential root of the sentence) ends the sentence.
We use a simple heuristic: if the given sentence has multiple clauses, and the last main
verb in the sentence is preceded by ", but is not followed by... | [
"def",
"detect_sentence_ending_saying_verbs",
"(",
"edt_sent_text",
")",
":",
"from",
"estnltk",
".",
"mw_verbs",
".",
"utils",
"import",
"WordTemplate",
"if",
"not",
"edt_sent_text",
".",
"is_tagged",
"(",
"VERB_CHAINS",
")",
":",
"edt_sent_text",
".",
"tag_verb_ch... | Detects cases where a saying verb (potential root of the sentence) ends the sentence.
We use a simple heuristic: if the given sentence has multiple clauses, and the last main
verb in the sentence is preceded by ", but is not followed by ", then the main verb is
most likely a saying verb.
... | [
"Detects",
"cases",
"where",
"a",
"saying",
"verb",
"(",
"potential",
"root",
"of",
"the",
"sentence",
")",
"ends",
"the",
"sentence",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L936-L1002 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _loadKSubcatRelations | def _loadKSubcatRelations( inputFile ):
''' Laeb sisendfailist (inputFile) kaassõnade rektsiooniseoste mustrid.
Iga muster peab olema failis eraldi real, kujul:
(sõnalemma);(sõnaliik);(post|pre);(nõutud_käänete_regexp)
nt
ees;_K_;post;g
eest;_K_;post;g
enn... | python | def _loadKSubcatRelations( inputFile ):
''' Laeb sisendfailist (inputFile) kaassõnade rektsiooniseoste mustrid.
Iga muster peab olema failis eraldi real, kujul:
(sõnalemma);(sõnaliik);(post|pre);(nõutud_käänete_regexp)
nt
ees;_K_;post;g
eest;_K_;post;g
enn... | [
"def",
"_loadKSubcatRelations",
"(",
"inputFile",
")",
":",
"kSubCatRelations",
"=",
"dict",
"(",
")",
"in_f",
"=",
"codecs",
".",
"open",
"(",
"inputFile",
",",
"mode",
"=",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"for",
"line",
"in",
"in_f",
":",
... | Laeb sisendfailist (inputFile) kaassõnade rektsiooniseoste mustrid.
Iga muster peab olema failis eraldi real, kujul:
(sõnalemma);(sõnaliik);(post|pre);(nõutud_käänete_regexp)
nt
ees;_K_;post;g
eest;_K_;post;g
enne;_K_;pre;p
Tagastab laetud andmed sõnas... | [
"Laeb",
"sisendfailist",
"(",
"inputFile",
")",
"kaassõnade",
"rektsiooniseoste",
"mustrid",
".",
"Iga",
"muster",
"peab",
"olema",
"failis",
"eraldi",
"real",
"kujul",
":",
"(",
"sõnalemma",
")",
";",
"(",
"sõnaliik",
")",
";",
"(",
"post|pre",
")",
";",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L1008-L1041 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _detectKsubcatRelType | def _detectKsubcatRelType( sentence, i, kSubCatRelsLexicon ):
''' Given the adposition appearing in the sentence at the location i,
checks whether the adposition appears in the kSubCatRelsLexicon,
and if so, attempts to further detect whether the adposition is a
preposition or a postpositi... | python | def _detectKsubcatRelType( sentence, i, kSubCatRelsLexicon ):
''' Given the adposition appearing in the sentence at the location i,
checks whether the adposition appears in the kSubCatRelsLexicon,
and if so, attempts to further detect whether the adposition is a
preposition or a postpositi... | [
"def",
"_detectKsubcatRelType",
"(",
"sentence",
",",
"i",
",",
"kSubCatRelsLexicon",
")",
":",
"curToken",
"=",
"sentence",
"[",
"i",
"]",
"root",
"=",
"curToken",
"[",
"ANALYSIS",
"]",
"[",
"0",
"]",
"[",
"ROOT",
"]",
"if",
"root",
"in",
"kSubCatRelsLe... | Given the adposition appearing in the sentence at the location i,
checks whether the adposition appears in the kSubCatRelsLexicon,
and if so, attempts to further detect whether the adposition is a
preposition or a postposition;
Returns a tuple (string, int), where the first item indic... | [
"Given",
"the",
"adposition",
"appearing",
"in",
"the",
"sentence",
"at",
"the",
"location",
"i",
"checks",
"whether",
"the",
"adposition",
"appears",
"in",
"the",
"kSubCatRelsLexicon",
"and",
"if",
"so",
"attempts",
"to",
"further",
"detect",
"whether",
"the",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L1044-L1071 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _detectPossibleKsubcatRelsFromSent | def _detectPossibleKsubcatRelsFromSent( sentence, kSubCatRelsLexicon, reverseMapping = False ):
''' Attempts to detect all possible K subcategorization relations from
given sentence, using the heuristic method _detectKsubcatRelType();
Returns a dictionary of relations where the key correspo... | python | def _detectPossibleKsubcatRelsFromSent( sentence, kSubCatRelsLexicon, reverseMapping = False ):
''' Attempts to detect all possible K subcategorization relations from
given sentence, using the heuristic method _detectKsubcatRelType();
Returns a dictionary of relations where the key correspo... | [
"def",
"_detectPossibleKsubcatRelsFromSent",
"(",
"sentence",
",",
"kSubCatRelsLexicon",
",",
"reverseMapping",
"=",
"False",
")",
":",
"relationIndex",
"=",
"dict",
"(",
")",
"relationType",
"=",
"dict",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
... | Attempts to detect all possible K subcategorization relations from
given sentence, using the heuristic method _detectKsubcatRelType();
Returns a dictionary of relations where the key corresponds to the
index of its parent node (the K node) and the value corresponds to
index of ... | [
"Attempts",
"to",
"detect",
"all",
"possible",
"K",
"subcategorization",
"relations",
"from",
"given",
"sentence",
"using",
"the",
"heuristic",
"method",
"_detectKsubcatRelType",
"()",
";",
"Returns",
"a",
"dictionary",
"of",
"relations",
"where",
"the",
"key",
"c... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L1074-L1100 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | _findKsubcatFeatures | def _findKsubcatFeatures( sentence, kSubCatRelsLexicon, addFeaturesToK = True ):
''' Attempts to detect all possible K subcategorization relations from
given sentence, using the heuristic methods _detectKsubcatRelType()
and _detectPossibleKsubcatRelsFromSent();
Returns a dictionary... | python | def _findKsubcatFeatures( sentence, kSubCatRelsLexicon, addFeaturesToK = True ):
''' Attempts to detect all possible K subcategorization relations from
given sentence, using the heuristic methods _detectKsubcatRelType()
and _detectPossibleKsubcatRelsFromSent();
Returns a dictionary... | [
"def",
"_findKsubcatFeatures",
"(",
"sentence",
",",
"kSubCatRelsLexicon",
",",
"addFeaturesToK",
"=",
"True",
")",
":",
"features",
"=",
"dict",
"(",
")",
"# Add features to the K (adposition)",
"if",
"addFeaturesToK",
":",
"for",
"i",
"in",
"range",
"(",
"len",
... | Attempts to detect all possible K subcategorization relations from
given sentence, using the heuristic methods _detectKsubcatRelType()
and _detectPossibleKsubcatRelsFromSent();
Returns a dictionary where the keys correspond to token indices,
and values are grammatical features ... | [
"Attempts",
"to",
"detect",
"all",
"possible",
"K",
"subcategorization",
"relations",
"from",
"given",
"sentence",
"using",
"the",
"heuristic",
"methods",
"_detectKsubcatRelType",
"()",
"and",
"_detectPossibleKsubcatRelsFromSent",
"()",
";",
"Returns",
"a",
"dictionary"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L1103-L1132 |
estnltk/estnltk | estnltk/syntax/maltparser_support.py | CONLLFeatGenerator.generate_features | def generate_features( self, sentence_text, wid ):
''' Generates and returns a list of strings, containing tab-separated
features ID, FORM, LEMMA, CPOSTAG, POSTAG, FEATS of the word
(the word with index *wid* from the given *sentence_text*).
Parameters
----------... | python | def generate_features( self, sentence_text, wid ):
''' Generates and returns a list of strings, containing tab-separated
features ID, FORM, LEMMA, CPOSTAG, POSTAG, FEATS of the word
(the word with index *wid* from the given *sentence_text*).
Parameters
----------... | [
"def",
"generate_features",
"(",
"self",
",",
"sentence_text",
",",
"wid",
")",
":",
"assert",
"WORDS",
"in",
"sentence_text",
"and",
"len",
"(",
"sentence_text",
"[",
"WORDS",
"]",
")",
">",
"0",
",",
"\" (!) 'words' layer missing or empty in given Text!\"",
"sen... | Generates and returns a list of strings, containing tab-separated
features ID, FORM, LEMMA, CPOSTAG, POSTAG, FEATS of the word
(the word with index *wid* from the given *sentence_text*).
Parameters
-----------
sentence_text : estnltk.text.Text
... | [
"Generates",
"and",
"returns",
"a",
"list",
"of",
"strings",
"containing",
"tab",
"-",
"separated",
"features",
"ID",
"FORM",
"LEMMA",
"CPOSTAG",
"POSTAG",
"FEATS",
"of",
"the",
"word",
"(",
"the",
"word",
"with",
"index",
"*",
"wid",
"*",
"from",
"the",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/maltparser_support.py#L152-L258 |
estnltk/estnltk | estnltk/prettyprinter/rules.py | create_rules | def create_rules(aes, value):
"""Create a Rules instance for a single aesthetic value.
Parameter
---------
aes: str
The name of the aesthetic
value: str or list
The value associated with any aesthetic
"""
if isinstance(value, six.string_types):
return Rules(aes)
... | python | def create_rules(aes, value):
"""Create a Rules instance for a single aesthetic value.
Parameter
---------
aes: str
The name of the aesthetic
value: str or list
The value associated with any aesthetic
"""
if isinstance(value, six.string_types):
return Rules(aes)
... | [
"def",
"create_rules",
"(",
"aes",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"return",
"Rules",
"(",
"aes",
")",
"else",
":",
"rules",
"=",
"Rules",
"(",
")",
"for",
"idx",
",",
"(",
"patte... | Create a Rules instance for a single aesthetic value.
Parameter
---------
aes: str
The name of the aesthetic
value: str or list
The value associated with any aesthetic | [
"Create",
"a",
"Rules",
"instance",
"for",
"a",
"single",
"aesthetic",
"value",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/rules.py#L51-L67 |
estnltk/estnltk | estnltk/prettyprinter/rules.py | Rules.add_rule | def add_rule(self, pattern, css_class):
"""Add a new rule.
Parameters
----------
pattern: str
Pattern that is compiled to a regular expression.
css_class: str
The class that will corresponds to given pattern.
"""
#print('adding rule <{0}> ... | python | def add_rule(self, pattern, css_class):
"""Add a new rule.
Parameters
----------
pattern: str
Pattern that is compiled to a regular expression.
css_class: str
The class that will corresponds to given pattern.
"""
#print('adding rule <{0}> ... | [
"def",
"add_rule",
"(",
"self",
",",
"pattern",
",",
"css_class",
")",
":",
"#print('adding rule <{0}> <{1}>'.format(pattern, css_class))",
"self",
".",
"__patterns",
".",
"append",
"(",
"re",
".",
"compile",
"(",
"pattern",
",",
"flags",
"=",
"re",
".",
"U",
... | Add a new rule.
Parameters
----------
pattern: str
Pattern that is compiled to a regular expression.
css_class: str
The class that will corresponds to given pattern. | [
"Add",
"a",
"new",
"rule",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/rules.py#L25-L37 |
estnltk/estnltk | estnltk/prettyprinter/rules.py | Rules.get_css_class | def get_css_class(self, value):
"""Return the css class of first pattern that matches given value.
If no rules match, the default css class will be returned (see the constructor)
"""
#print ('get_css_class for {0}'.format(value))
for idx, pattern in enumerate(self.__patterns):
... | python | def get_css_class(self, value):
"""Return the css class of first pattern that matches given value.
If no rules match, the default css class will be returned (see the constructor)
"""
#print ('get_css_class for {0}'.format(value))
for idx, pattern in enumerate(self.__patterns):
... | [
"def",
"get_css_class",
"(",
"self",
",",
"value",
")",
":",
"#print ('get_css_class for {0}'.format(value))",
"for",
"idx",
",",
"pattern",
"in",
"enumerate",
"(",
"self",
".",
"__patterns",
")",
":",
"if",
"pattern",
".",
"match",
"(",
"value",
")",
"is",
... | Return the css class of first pattern that matches given value.
If no rules match, the default css class will be returned (see the constructor) | [
"Return",
"the",
"css",
"class",
"of",
"first",
"pattern",
"that",
"matches",
"given",
"value",
".",
"If",
"no",
"rules",
"match",
"the",
"default",
"css",
"class",
"will",
"be",
"returned",
"(",
"see",
"the",
"constructor",
")"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/rules.py#L39-L48 |
estnltk/estnltk | estnltk/database/elastic/__init__.py | create_index | def create_index(index_name, **kwargs):
"""
Parameters
----------
index_name : str
Name of the index to be created
**kwargs
Arguments to pass to Elasticsearch instance.
Returns
-------
Index
"""
es = elasticsearch.Elasticsearch(**kwargs)
es.indices.create(in... | python | def create_index(index_name, **kwargs):
"""
Parameters
----------
index_name : str
Name of the index to be created
**kwargs
Arguments to pass to Elasticsearch instance.
Returns
-------
Index
"""
es = elasticsearch.Elasticsearch(**kwargs)
es.indices.create(in... | [
"def",
"create_index",
"(",
"index_name",
",",
"*",
"*",
"kwargs",
")",
":",
"es",
"=",
"elasticsearch",
".",
"Elasticsearch",
"(",
"*",
"*",
"kwargs",
")",
"es",
".",
"indices",
".",
"create",
"(",
"index",
"=",
"index_name",
",",
"body",
"=",
"mappin... | Parameters
----------
index_name : str
Name of the index to be created
**kwargs
Arguments to pass to Elasticsearch instance.
Returns
-------
Index | [
"Parameters",
"----------",
"index_name",
":",
"str",
"Name",
"of",
"the",
"index",
"to",
"be",
"created",
"**",
"kwargs",
"Arguments",
"to",
"pass",
"to",
"Elasticsearch",
"instance",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/database/elastic/__init__.py#L16-L32 |
estnltk/estnltk | estnltk/database/elastic/__init__.py | Index._get_indexable_sentences | def _get_indexable_sentences(document):
"""
Parameters
----------
document : Text
Article, book, paragraph, chapter, etc. Anything that is considered a document on its own.
Yields
------
str
json representation of elasticsearch type sentence
... | python | def _get_indexable_sentences(document):
"""
Parameters
----------
document : Text
Article, book, paragraph, chapter, etc. Anything that is considered a document on its own.
Yields
------
str
json representation of elasticsearch type sentence
... | [
"def",
"_get_indexable_sentences",
"(",
"document",
")",
":",
"def",
"unroll_lists",
"(",
"list_of_lists",
")",
":",
"for",
"i",
"in",
"itertools",
".",
"product",
"(",
"*",
"[",
"set",
"(",
"j",
")",
"for",
"j",
"in",
"list_of_lists",
"]",
")",
":",
"... | Parameters
----------
document : Text
Article, book, paragraph, chapter, etc. Anything that is considered a document on its own.
Yields
------
str
json representation of elasticsearch type sentence | [
"Parameters",
"----------",
"document",
":",
"Text",
"Article",
"book",
"paragraph",
"chapter",
"etc",
".",
"Anything",
"that",
"is",
"considered",
"a",
"document",
"on",
"its",
"own",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/database/elastic/__init__.py#L91-L129 |
estnltk/estnltk | estnltk/estner/featureextraction.py | apply_templates | def apply_templates(toks, templates):
"""
Generate features for an item sequence by applying feature templates.
A feature template consists of a tuple of (name, offset) pairs,
where name and offset specify a field name and offset from which
the template extracts a feature value. Generated features a... | python | def apply_templates(toks, templates):
"""
Generate features for an item sequence by applying feature templates.
A feature template consists of a tuple of (name, offset) pairs,
where name and offset specify a field name and offset from which
the template extracts a feature value. Generated features a... | [
"def",
"apply_templates",
"(",
"toks",
",",
"templates",
")",
":",
"for",
"template",
"in",
"templates",
":",
"name",
"=",
"'|'",
".",
"join",
"(",
"[",
"'%s[%d]'",
"%",
"(",
"f",
",",
"o",
")",
"for",
"f",
",",
"o",
"in",
"template",
"]",
")",
"... | Generate features for an item sequence by applying feature templates.
A feature template consists of a tuple of (name, offset) pairs,
where name and offset specify a field name and offset from which
the template extracts a feature value. Generated features are stored
in the 'F' field of each item in the... | [
"Generate",
"features",
"for",
"an",
"item",
"sequence",
"by",
"applying",
"feature",
"templates",
".",
"A",
"feature",
"template",
"consists",
"of",
"a",
"tuple",
"of",
"(",
"name",
"offset",
")",
"pairs",
"where",
"name",
"and",
"offset",
"specify",
"a",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/estner/featureextraction.py#L505-L537 |
estnltk/estnltk | estnltk/ner.py | json_document_to_estner_document | def json_document_to_estner_document(jsondoc):
"""Convert an estnltk document to an estner document.
Parameters
----------
jsondoc: dict
Estnltk JSON-style document.
Returns
-------
estnltk.estner.ner.Document
A ner document.
"""
sentences = []
for json_sent in ... | python | def json_document_to_estner_document(jsondoc):
"""Convert an estnltk document to an estner document.
Parameters
----------
jsondoc: dict
Estnltk JSON-style document.
Returns
-------
estnltk.estner.ner.Document
A ner document.
"""
sentences = []
for json_sent in ... | [
"def",
"json_document_to_estner_document",
"(",
"jsondoc",
")",
":",
"sentences",
"=",
"[",
"]",
"for",
"json_sent",
"in",
"jsondoc",
".",
"split_by_sentences",
"(",
")",
":",
"snt",
"=",
"Sentence",
"(",
")",
"zipped",
"=",
"list",
"(",
"zip",
"(",
"json_... | Convert an estnltk document to an estner document.
Parameters
----------
jsondoc: dict
Estnltk JSON-style document.
Returns
-------
estnltk.estner.ner.Document
A ner document. | [
"Convert",
"an",
"estnltk",
"document",
"to",
"an",
"estner",
"document",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/ner.py#L64-L101 |
estnltk/estnltk | estnltk/ner.py | json_token_to_estner_token | def json_token_to_estner_token(json_token):
"""Convert a JSON-style word token to an estner token.
Parameters
----------
vabamorf_token: dict
Vabamorf token representing a single word.
label: str
The label string.
Returns
-------
estnltk.estner.ner.Token
"""
tok... | python | def json_token_to_estner_token(json_token):
"""Convert a JSON-style word token to an estner token.
Parameters
----------
vabamorf_token: dict
Vabamorf token representing a single word.
label: str
The label string.
Returns
-------
estnltk.estner.ner.Token
"""
tok... | [
"def",
"json_token_to_estner_token",
"(",
"json_token",
")",
":",
"token",
"=",
"Token",
"(",
")",
"word",
"=",
"json_token",
"[",
"TEXT",
"]",
"lemma",
"=",
"word",
"morph",
"=",
"''",
"label",
"=",
"'O'",
"ending",
"=",
"json_token",
"[",
"ENDING",
"]"... | Convert a JSON-style word token to an estner token.
Parameters
----------
vabamorf_token: dict
Vabamorf token representing a single word.
label: str
The label string.
Returns
-------
estnltk.estner.ner.Token | [
"Convert",
"a",
"JSON",
"-",
"style",
"word",
"token",
"to",
"an",
"estner",
"token",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/ner.py#L104-L134 |
estnltk/estnltk | estnltk/ner.py | ModelStorageUtil.makedir | def makedir(self):
""" Create model_dir directory """
try:
os.makedirs(self.model_dir)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise | python | def makedir(self):
""" Create model_dir directory """
try:
os.makedirs(self.model_dir)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise | [
"def",
"makedir",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"model_dir",
")",
"except",
"OSError",
"as",
"exception",
":",
"if",
"exception",
".",
"errno",
"!=",
"errno",
".",
"EEXIST",
":",
"raise"
] | Create model_dir directory | [
"Create",
"model_dir",
"directory"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/ner.py#L38-L44 |
estnltk/estnltk | estnltk/ner.py | ModelStorageUtil.copy_settings | def copy_settings(self, settings_module):
""" Copy settings module to the model_dir directory """
source = inspect.getsourcefile(settings_module)
dest = os.path.join(self.model_dir, 'settings.py')
shutil.copyfile(source, dest) | python | def copy_settings(self, settings_module):
""" Copy settings module to the model_dir directory """
source = inspect.getsourcefile(settings_module)
dest = os.path.join(self.model_dir, 'settings.py')
shutil.copyfile(source, dest) | [
"def",
"copy_settings",
"(",
"self",
",",
"settings_module",
")",
":",
"source",
"=",
"inspect",
".",
"getsourcefile",
"(",
"settings_module",
")",
"dest",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"model_dir",
",",
"'settings.py'",
")",
"shut... | Copy settings module to the model_dir directory | [
"Copy",
"settings",
"module",
"to",
"the",
"model_dir",
"directory"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/ner.py#L46-L50 |
estnltk/estnltk | estnltk/ner.py | ModelStorageUtil.load_settings | def load_settings(self):
"""Load settings module from the model_dir directory."""
mname = 'loaded_module'
if six.PY2:
import imp
return imp.load_source(mname, self.settings_filename)
else:
import importlib.machinery
loader = importlib.machi... | python | def load_settings(self):
"""Load settings module from the model_dir directory."""
mname = 'loaded_module'
if six.PY2:
import imp
return imp.load_source(mname, self.settings_filename)
else:
import importlib.machinery
loader = importlib.machi... | [
"def",
"load_settings",
"(",
"self",
")",
":",
"mname",
"=",
"'loaded_module'",
"if",
"six",
".",
"PY2",
":",
"import",
"imp",
"return",
"imp",
".",
"load_source",
"(",
"mname",
",",
"self",
".",
"settings_filename",
")",
"else",
":",
"import",
"importlib"... | Load settings module from the model_dir directory. | [
"Load",
"settings",
"module",
"from",
"the",
"model_dir",
"directory",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/ner.py#L52-L61 |
estnltk/estnltk | estnltk/ner.py | NerTrainer.train | def train(self, jsondocs, model_dir):
""" Train a NER model using given documents.
Each word in the documents must have a "label" attribute, which
denote the named entities in the documents.
Parameters
----------
jsondocs: list of JSON-style documents.
... | python | def train(self, jsondocs, model_dir):
""" Train a NER model using given documents.
Each word in the documents must have a "label" attribute, which
denote the named entities in the documents.
Parameters
----------
jsondocs: list of JSON-style documents.
... | [
"def",
"train",
"(",
"self",
",",
"jsondocs",
",",
"model_dir",
")",
":",
"modelUtil",
"=",
"ModelStorageUtil",
"(",
"model_dir",
")",
"modelUtil",
".",
"makedir",
"(",
")",
"modelUtil",
".",
"copy_settings",
"(",
"self",
".",
"settings",
")",
"# Convert jso... | Train a NER model using given documents.
Each word in the documents must have a "label" attribute, which
denote the named entities in the documents.
Parameters
----------
jsondocs: list of JSON-style documents.
The documents used for training the CRF... | [
"Train",
"a",
"NER",
"model",
"using",
"given",
"documents",
".",
"Each",
"word",
"in",
"the",
"documents",
"must",
"have",
"a",
"label",
"attribute",
"which",
"denote",
"the",
"named",
"entities",
"in",
"the",
"documents",
".",
"Parameters",
"----------",
"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/ner.py#L153-L177 |
estnltk/estnltk | estnltk/syntax/vislcg3_syntax.py | cleanup_lines | def cleanup_lines( lines, **kwargs ):
''' Cleans up annotation after syntactic pre-processing and processing:
-- Removes embedded clause boundaries "<{>" and "<}>";
-- Removes CLBC markings from analysis;
-- Removes additional information between < and > from analysis;
-- Removes add... | python | def cleanup_lines( lines, **kwargs ):
''' Cleans up annotation after syntactic pre-processing and processing:
-- Removes embedded clause boundaries "<{>" and "<}>";
-- Removes CLBC markings from analysis;
-- Removes additional information between < and > from analysis;
-- Removes add... | [
"def",
"cleanup_lines",
"(",
"lines",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"lines",
",",
"list",
")",
":",
"raise",
"Exception",
"(",
"'(!) Unexpected type of input argument! Expected a list of strings.'",
")",
"remove_caps",
"=",
"Fa... | Cleans up annotation after syntactic pre-processing and processing:
-- Removes embedded clause boundaries "<{>" and "<}>";
-- Removes CLBC markings from analysis;
-- Removes additional information between < and > from analysis;
-- Removes additional information between " and " from analy... | [
"Cleans",
"up",
"annotation",
"after",
"syntactic",
"pre",
"-",
"processing",
"and",
"processing",
":",
"--",
"Removes",
"embedded",
"clause",
"boundaries",
"<",
"{",
">",
"and",
"<",
"}",
">",
";",
"--",
"Removes",
"CLBC",
"markings",
"from",
"analysis",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/vislcg3_syntax.py#L312-L415 |
estnltk/estnltk | estnltk/syntax/vislcg3_syntax.py | align_cg3_with_Text | def align_cg3_with_Text( lines, text, **kwargs ):
''' Aligns VISLCG3's output (a list of strings) with given EstNLTK\'s Text object.
Basically, for each word position in the Text object, finds corresponding VISLCG3's
analyses;
Returns a list of dicts, where each dict has following attribute... | python | def align_cg3_with_Text( lines, text, **kwargs ):
''' Aligns VISLCG3's output (a list of strings) with given EstNLTK\'s Text object.
Basically, for each word position in the Text object, finds corresponding VISLCG3's
analyses;
Returns a list of dicts, where each dict has following attribute... | [
"def",
"align_cg3_with_Text",
"(",
"lines",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"estnltk",
".",
"text",
"import",
"Text",
"if",
"not",
"isinstance",
"(",
"text",
",",
"Text",
")",
":",
"raise",
"Exception",
"(",
"'(!) Unexpected type of... | Aligns VISLCG3's output (a list of strings) with given EstNLTK\'s Text object.
Basically, for each word position in the Text object, finds corresponding VISLCG3's
analyses;
Returns a list of dicts, where each dict has following attributes:
'start' -- start index of the word in Text;... | [
"Aligns",
"VISLCG3",
"s",
"output",
"(",
"a",
"list",
"of",
"strings",
")",
"with",
"given",
"EstNLTK",
"\\",
"s",
"Text",
"object",
".",
"Basically",
"for",
"each",
"word",
"position",
"in",
"the",
"Text",
"object",
"finds",
"corresponding",
"VISLCG3",
"s... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/vislcg3_syntax.py#L422-L537 |
estnltk/estnltk | estnltk/syntax/vislcg3_syntax.py | convert_cg3_to_conll | def convert_cg3_to_conll( lines, **kwargs ):
''' Converts the output of VISL_CG3 based syntactic parsing into CONLL format.
Expects that the output has been cleaned ( via method cleanup_lines() ).
Returns a list of CONLL format lines;
Parameters
-----------
lines : l... | python | def convert_cg3_to_conll( lines, **kwargs ):
''' Converts the output of VISL_CG3 based syntactic parsing into CONLL format.
Expects that the output has been cleaned ( via method cleanup_lines() ).
Returns a list of CONLL format lines;
Parameters
-----------
lines : l... | [
"def",
"convert_cg3_to_conll",
"(",
"lines",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"lines",
",",
"list",
")",
":",
"raise",
"Exception",
"(",
"'(!) Unexpected type of input argument! Expected a list of strings.'",
")",
"fix_selfrefs",
"=... | Converts the output of VISL_CG3 based syntactic parsing into CONLL format.
Expects that the output has been cleaned ( via method cleanup_lines() ).
Returns a list of CONLL format lines;
Parameters
-----------
lines : list of str
The input text for the pipelin... | [
"Converts",
"the",
"output",
"of",
"VISL_CG3",
"based",
"syntactic",
"parsing",
"into",
"CONLL",
"format",
".",
"Expects",
"that",
"the",
"output",
"has",
"been",
"cleaned",
"(",
"via",
"method",
"cleanup_lines",
"()",
")",
".",
"Returns",
"a",
"list",
"of",... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/vislcg3_syntax.py#L544-L747 |
estnltk/estnltk | estnltk/syntax/vislcg3_syntax.py | VISLCG3Pipeline.check_if_vislcg_is_in_path | def check_if_vislcg_is_in_path( self, vislcg_cmd1 ):
''' Checks whether given vislcg_cmd1 is in system's PATH. Returns True, there is
a file named vislcg_cmd1 in the path, otherwise returns False;
The idea borrows from: http://stackoverflow.com/a/377028
'''
for path ... | python | def check_if_vislcg_is_in_path( self, vislcg_cmd1 ):
''' Checks whether given vislcg_cmd1 is in system's PATH. Returns True, there is
a file named vislcg_cmd1 in the path, otherwise returns False;
The idea borrows from: http://stackoverflow.com/a/377028
'''
for path ... | [
"def",
"check_if_vislcg_is_in_path",
"(",
"self",
",",
"vislcg_cmd1",
")",
":",
"for",
"path",
"in",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
":",
"path1",
"=",
"path",
".",
"strip",
"(",
"'\"'",
")",
... | Checks whether given vislcg_cmd1 is in system's PATH. Returns True, there is
a file named vislcg_cmd1 in the path, otherwise returns False;
The idea borrows from: http://stackoverflow.com/a/377028 | [
"Checks",
"whether",
"given",
"vislcg_cmd1",
"is",
"in",
"system",
"s",
"PATH",
".",
"Returns",
"True",
"there",
"is",
"a",
"file",
"named",
"vislcg_cmd1",
"in",
"the",
"path",
"otherwise",
"returns",
"False",
";"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/vislcg3_syntax.py#L199-L210 |
estnltk/estnltk | estnltk/syntax/vislcg3_syntax.py | VISLCG3Pipeline.process_lines | def process_lines( self, input_lines, **kwargs ):
''' Executes the pipeline of subsequent VISL_CG3 commands. The first process
in pipeline gets input_lines as an input, and each subsequent process gets
the output of the previous process as an input.
The idea of h... | python | def process_lines( self, input_lines, **kwargs ):
''' Executes the pipeline of subsequent VISL_CG3 commands. The first process
in pipeline gets input_lines as an input, and each subsequent process gets
the output of the previous process as an input.
The idea of h... | [
"def",
"process_lines",
"(",
"self",
",",
"input_lines",
",",
"*",
"*",
"kwargs",
")",
":",
"split_result_lines",
"=",
"False",
"remove_info",
"=",
"True",
"for",
"argName",
",",
"argVal",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"argName",
"in... | Executes the pipeline of subsequent VISL_CG3 commands. The first process
in pipeline gets input_lines as an input, and each subsequent process gets
the output of the previous process as an input.
The idea of how to construct the pipeline borrows from:
https... | [
"Executes",
"the",
"pipeline",
"of",
"subsequent",
"VISL_CG3",
"commands",
".",
"The",
"first",
"process",
"in",
"pipeline",
"gets",
"input_lines",
"as",
"an",
"input",
"and",
"each",
"subsequent",
"process",
"gets",
"the",
"output",
"of",
"the",
"previous",
"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/vislcg3_syntax.py#L213-L302 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | copy_analysis_dict | def copy_analysis_dict( analysis ):
''' Creates a copy from given analysis dict. '''
assert isinstance(analysis, dict), "(!) Input 'analysis' should be a dict!"
new_dict = { POSTAG: analysis[POSTAG],\
ROOT: analysis[ROOT],\
FORM: analysis[FORM],\
CLITIC: an... | python | def copy_analysis_dict( analysis ):
''' Creates a copy from given analysis dict. '''
assert isinstance(analysis, dict), "(!) Input 'analysis' should be a dict!"
new_dict = { POSTAG: analysis[POSTAG],\
ROOT: analysis[ROOT],\
FORM: analysis[FORM],\
CLITIC: an... | [
"def",
"copy_analysis_dict",
"(",
"analysis",
")",
":",
"assert",
"isinstance",
"(",
"analysis",
",",
"dict",
")",
",",
"\"(!) Input 'analysis' should be a dict!\"",
"new_dict",
"=",
"{",
"POSTAG",
":",
"analysis",
"[",
"POSTAG",
"]",
",",
"ROOT",
":",
"analysis... | Creates a copy from given analysis dict. | [
"Creates",
"a",
"copy",
"from",
"given",
"analysis",
"dict",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L27-L39 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | get_unique_clause_indices | def get_unique_clause_indices( text ):
''' Returns a list of clause indices for the whole text. For each token in text,
the list contains index of the clause the word belongs to, and the indices
are unique over the whole text. '''
# Add clause boundary annotation (if missing)
if not text.is... | python | def get_unique_clause_indices( text ):
''' Returns a list of clause indices for the whole text. For each token in text,
the list contains index of the clause the word belongs to, and the indices
are unique over the whole text. '''
# Add clause boundary annotation (if missing)
if not text.is... | [
"def",
"get_unique_clause_indices",
"(",
"text",
")",
":",
"# Add clause boundary annotation (if missing)",
"if",
"not",
"text",
".",
"is_tagged",
"(",
"CLAUSES",
")",
":",
"text",
".",
"tag_clauses",
"(",
")",
"# Collect (unique) clause indices over the whole text",
"cla... | Returns a list of clause indices for the whole text. For each token in text,
the list contains index of the clause the word belongs to, and the indices
are unique over the whole text. | [
"Returns",
"a",
"list",
"of",
"clause",
"indices",
"for",
"the",
"whole",
"text",
".",
"For",
"each",
"token",
"in",
"text",
"the",
"list",
"contains",
"index",
"of",
"the",
"clause",
"the",
"word",
"belongs",
"to",
"and",
"the",
"indices",
"are",
"uniqu... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L42-L58 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | get_unique_sentence_indices | def get_unique_sentence_indices( text ):
''' Returns a list of sentence indices for the whole text. For each token in text,
the list contains index of the sentence the word belongs to, and the indices
are unique over the whole text. '''
# Add sentence annotation (if missing)
if not text.is_... | python | def get_unique_sentence_indices( text ):
''' Returns a list of sentence indices for the whole text. For each token in text,
the list contains index of the sentence the word belongs to, and the indices
are unique over the whole text. '''
# Add sentence annotation (if missing)
if not text.is_... | [
"def",
"get_unique_sentence_indices",
"(",
"text",
")",
":",
"# Add sentence annotation (if missing)",
"if",
"not",
"text",
".",
"is_tagged",
"(",
"SENTENCES",
")",
":",
"text",
".",
"tokenize_sentences",
"(",
")",
"# Collect (unique) sent indices over the whole text",
"s... | Returns a list of sentence indices for the whole text. For each token in text,
the list contains index of the sentence the word belongs to, and the indices
are unique over the whole text. | [
"Returns",
"a",
"list",
"of",
"sentence",
"indices",
"for",
"the",
"whole",
"text",
".",
"For",
"each",
"token",
"in",
"text",
"the",
"list",
"contains",
"index",
"of",
"the",
"sentence",
"the",
"word",
"belongs",
"to",
"and",
"the",
"indices",
"are",
"u... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L61-L76 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _convert_nominal_form | def _convert_nominal_form( analysis ):
''' Converts nominal categories of the input analysis.
Performs one-to-one conversions only. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
for idx, pattern_items in enumerate(_noun_conversion_rules):
pattern_str... | python | def _convert_nominal_form( analysis ):
''' Converts nominal categories of the input analysis.
Performs one-to-one conversions only. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
for idx, pattern_items in enumerate(_noun_conversion_rules):
pattern_str... | [
"def",
"_convert_nominal_form",
"(",
"analysis",
")",
":",
"assert",
"FORM",
"in",
"analysis",
",",
"'(!) The input analysis does not contain \"'",
"+",
"FORM",
"+",
"'\" key.'",
"for",
"idx",
",",
"pattern_items",
"in",
"enumerate",
"(",
"_noun_conversion_rules",
")"... | Converts nominal categories of the input analysis.
Performs one-to-one conversions only. | [
"Converts",
"nominal",
"categories",
"of",
"the",
"input",
"analysis",
".",
"Performs",
"one",
"-",
"to",
"-",
"one",
"conversions",
"only",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L115-L123 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _convert_amb_verbal_form | def _convert_amb_verbal_form( analysis ):
''' Converts ambiguous verbal categories of the input analysis.
Performs one-to-many conversions. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
results = []
for root_pat, pos, form_pat, replacements in _amb_verb_... | python | def _convert_amb_verbal_form( analysis ):
''' Converts ambiguous verbal categories of the input analysis.
Performs one-to-many conversions. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
results = []
for root_pat, pos, form_pat, replacements in _amb_verb_... | [
"def",
"_convert_amb_verbal_form",
"(",
"analysis",
")",
":",
"assert",
"FORM",
"in",
"analysis",
",",
"'(!) The input analysis does not contain \"'",
"+",
"FORM",
"+",
"'\" key.'",
"results",
"=",
"[",
"]",
"for",
"root_pat",
",",
"pos",
",",
"form_pat",
",",
"... | Converts ambiguous verbal categories of the input analysis.
Performs one-to-many conversions. | [
"Converts",
"ambiguous",
"verbal",
"categories",
"of",
"the",
"input",
"analysis",
".",
"Performs",
"one",
"-",
"to",
"-",
"many",
"conversions",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L152-L170 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _convert_verbal_form | def _convert_verbal_form( analysis ):
''' Converts ordinary verbal categories of the input analysis.
Performs one-to-one conversions. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
for form, replacement in _verb_conversion_rules:
# Exact match
... | python | def _convert_verbal_form( analysis ):
''' Converts ordinary verbal categories of the input analysis.
Performs one-to-one conversions. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
for form, replacement in _verb_conversion_rules:
# Exact match
... | [
"def",
"_convert_verbal_form",
"(",
"analysis",
")",
":",
"assert",
"FORM",
"in",
"analysis",
",",
"'(!) The input analysis does not contain \"'",
"+",
"FORM",
"+",
"'\" key.'",
"for",
"form",
",",
"replacement",
"in",
"_verb_conversion_rules",
":",
"# Exact match",
"... | Converts ordinary verbal categories of the input analysis.
Performs one-to-one conversions. | [
"Converts",
"ordinary",
"verbal",
"categories",
"of",
"the",
"input",
"analysis",
".",
"Performs",
"one",
"-",
"to",
"-",
"one",
"conversions",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L220-L235 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _make_postfixes_1 | def _make_postfixes_1( analysis ):
''' Provides some post-fixes. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
if 'neg' in analysis[FORM]:
analysis[FORM] = re.sub( '^\s*neg ([^,]*)$', '\\1 Neg', analysis[FORM] )
analysis[FORM] = re.sub( ' Neg Neg$', ' ... | python | def _make_postfixes_1( analysis ):
''' Provides some post-fixes. '''
assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
if 'neg' in analysis[FORM]:
analysis[FORM] = re.sub( '^\s*neg ([^,]*)$', '\\1 Neg', analysis[FORM] )
analysis[FORM] = re.sub( ' Neg Neg$', ' ... | [
"def",
"_make_postfixes_1",
"(",
"analysis",
")",
":",
"assert",
"FORM",
"in",
"analysis",
",",
"'(!) The input analysis does not contain \"'",
"+",
"FORM",
"+",
"'\" key.'",
"if",
"'neg'",
"in",
"analysis",
"[",
"FORM",
"]",
":",
"analysis",
"[",
"FORM",
"]",
... | Provides some post-fixes. | [
"Provides",
"some",
"post",
"-",
"fixes",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L241-L254 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _keep_analyses | def _keep_analyses( analyses, keep_forms, target_forms ):
''' Filters the given list of *analyses* by morphological forms:
deletes analyses that are listed in *target_forms*, but not in
*keep_forms*. '''
to_delete = []
for aid, analysis in enumerate(analyses):
delete = False
... | python | def _keep_analyses( analyses, keep_forms, target_forms ):
''' Filters the given list of *analyses* by morphological forms:
deletes analyses that are listed in *target_forms*, but not in
*keep_forms*. '''
to_delete = []
for aid, analysis in enumerate(analyses):
delete = False
... | [
"def",
"_keep_analyses",
"(",
"analyses",
",",
"keep_forms",
",",
"target_forms",
")",
":",
"to_delete",
"=",
"[",
"]",
"for",
"aid",
",",
"analysis",
"in",
"enumerate",
"(",
"analyses",
")",
":",
"delete",
"=",
"False",
"for",
"target",
"in",
"target_form... | Filters the given list of *analyses* by morphological forms:
deletes analyses that are listed in *target_forms*, but not in
*keep_forms*. | [
"Filters",
"the",
"given",
"list",
"of",
"*",
"analyses",
"*",
"by",
"morphological",
"forms",
":",
"deletes",
"analyses",
"that",
"are",
"listed",
"in",
"*",
"target_forms",
"*",
"but",
"not",
"in",
"*",
"keep_forms",
"*",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L260-L275 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _disambiguate_neg | def _disambiguate_neg( words_layer ):
''' Disambiguates forms ambiguous between multiword negation and some
other form;
'''
prev_word_lemma = ''
for word_dict in words_layer:
forms = [ a[FORM] for a in word_dict[ANALYSIS] ]
if ('Pers Prs Imprt Sg2' in forms and 'Pers Prs Ind Neg... | python | def _disambiguate_neg( words_layer ):
''' Disambiguates forms ambiguous between multiword negation and some
other form;
'''
prev_word_lemma = ''
for word_dict in words_layer:
forms = [ a[FORM] for a in word_dict[ANALYSIS] ]
if ('Pers Prs Imprt Sg2' in forms and 'Pers Prs Ind Neg... | [
"def",
"_disambiguate_neg",
"(",
"words_layer",
")",
":",
"prev_word_lemma",
"=",
"''",
"for",
"word_dict",
"in",
"words_layer",
":",
"forms",
"=",
"[",
"a",
"[",
"FORM",
"]",
"for",
"a",
"in",
"word_dict",
"[",
"ANALYSIS",
"]",
"]",
"if",
"(",
"'Pers Pr... | Disambiguates forms ambiguous between multiword negation and some
other form; | [
"Disambiguates",
"forms",
"ambiguous",
"between",
"multiword",
"negation",
"and",
"some",
"other",
"form",
";"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L277-L305 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _disambiguate_sid_ksid | def _disambiguate_sid_ksid( words_layer, text, scope=CLAUSES ):
''' Disambiguates verb forms based on existence of 2nd person pronoun ('sina') in given scope.
The scope could be either CLAUSES or SENTENCES.
'''
assert scope in [CLAUSES, SENTENCES], '(!) The scope should be either "clauses" or "sente... | python | def _disambiguate_sid_ksid( words_layer, text, scope=CLAUSES ):
''' Disambiguates verb forms based on existence of 2nd person pronoun ('sina') in given scope.
The scope could be either CLAUSES or SENTENCES.
'''
assert scope in [CLAUSES, SENTENCES], '(!) The scope should be either "clauses" or "sente... | [
"def",
"_disambiguate_sid_ksid",
"(",
"words_layer",
",",
"text",
",",
"scope",
"=",
"CLAUSES",
")",
":",
"assert",
"scope",
"in",
"[",
"CLAUSES",
",",
"SENTENCES",
"]",
",",
"'(!) The scope should be either \"clauses\" or \"sentences\".'",
"group_indices",
"=",
"get_... | Disambiguates verb forms based on existence of 2nd person pronoun ('sina') in given scope.
The scope could be either CLAUSES or SENTENCES. | [
"Disambiguates",
"verb",
"forms",
"based",
"on",
"existence",
"of",
"2nd",
"person",
"pronoun",
"(",
"sina",
")",
"in",
"given",
"scope",
".",
"The",
"scope",
"could",
"be",
"either",
"CLAUSES",
"or",
"SENTENCES",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L308-L350 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | _make_postfixes_2 | def _make_postfixes_2( words_layer ):
''' Provides some post-fixes after the disambiguation. '''
for word_dict in words_layer:
for analysis in word_dict[ANALYSIS]:
analysis[FORM] = re.sub( '(Sg|Pl)([123])', '\\1 \\2', analysis[FORM] )
return words_layer | python | def _make_postfixes_2( words_layer ):
''' Provides some post-fixes after the disambiguation. '''
for word_dict in words_layer:
for analysis in word_dict[ANALYSIS]:
analysis[FORM] = re.sub( '(Sg|Pl)([123])', '\\1 \\2', analysis[FORM] )
return words_layer | [
"def",
"_make_postfixes_2",
"(",
"words_layer",
")",
":",
"for",
"word_dict",
"in",
"words_layer",
":",
"for",
"analysis",
"in",
"word_dict",
"[",
"ANALYSIS",
"]",
":",
"analysis",
"[",
"FORM",
"]",
"=",
"re",
".",
"sub",
"(",
"'(Sg|Pl)([123])'",
",",
"'\\... | Provides some post-fixes after the disambiguation. | [
"Provides",
"some",
"post",
"-",
"fixes",
"after",
"the",
"disambiguation",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L356-L361 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | convert_analysis | def convert_analysis( analyses ):
''' Converts a list of analyses (list of dict objects) from FS's vabamorf format to
giellatekno (GT) format.
Due to one-to-many conversion rules, the number of analyses returned by this method
can be greater than the number of analyses in the input list.
... | python | def convert_analysis( analyses ):
''' Converts a list of analyses (list of dict objects) from FS's vabamorf format to
giellatekno (GT) format.
Due to one-to-many conversion rules, the number of analyses returned by this method
can be greater than the number of analyses in the input list.
... | [
"def",
"convert_analysis",
"(",
"analyses",
")",
":",
"resulting_analyses",
"=",
"[",
"]",
"for",
"analysis",
"in",
"analyses",
":",
"# Make a copy of the analysis",
"new_analyses",
"=",
"[",
"copy_analysis_dict",
"(",
"analysis",
")",
"]",
"# Convert noun categories"... | Converts a list of analyses (list of dict objects) from FS's vabamorf format to
giellatekno (GT) format.
Due to one-to-many conversion rules, the number of analyses returned by this method
can be greater than the number of analyses in the input list. | [
"Converts",
"a",
"list",
"of",
"analyses",
"(",
"list",
"of",
"dict",
"objects",
")",
"from",
"FS",
"s",
"vabamorf",
"format",
"to",
"giellatekno",
"(",
"GT",
")",
"format",
".",
"Due",
"to",
"one",
"-",
"to",
"-",
"many",
"conversion",
"rules",
"the",... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L368-L387 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | convert_to_gt | def convert_to_gt( text, layer_name=GT_WORDS ):
''' Converts all words in a morphologically analysed Text from FS format to
giellatekno (GT) format, and stores in a new layer named GT_WORDS.
If the keyword argument *layer_name=='words'* , overwrites the old 'words'
layer with the new laye... | python | def convert_to_gt( text, layer_name=GT_WORDS ):
''' Converts all words in a morphologically analysed Text from FS format to
giellatekno (GT) format, and stores in a new layer named GT_WORDS.
If the keyword argument *layer_name=='words'* , overwrites the old 'words'
layer with the new laye... | [
"def",
"convert_to_gt",
"(",
"text",
",",
"layer_name",
"=",
"GT_WORDS",
")",
":",
"assert",
"WORDS",
"in",
"text",
",",
"'(!) The input text should contain \"'",
"+",
"str",
"(",
"WORDS",
")",
"+",
"'\" layer.'",
"assert",
"len",
"(",
"text",
"[",
"WORDS",
... | Converts all words in a morphologically analysed Text from FS format to
giellatekno (GT) format, and stores in a new layer named GT_WORDS.
If the keyword argument *layer_name=='words'* , overwrites the old 'words'
layer with the new layer containing GT format annotations.
Parameters... | [
"Converts",
"all",
"words",
"in",
"a",
"morphologically",
"analysed",
"Text",
"from",
"FS",
"format",
"to",
"giellatekno",
"(",
"GT",
")",
"format",
"and",
"stores",
"in",
"a",
"new",
"layer",
"named",
"GT_WORDS",
".",
"If",
"the",
"keyword",
"argument",
"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L390-L431 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | get_analysis_dict | def get_analysis_dict( root, pos, form ):
''' Takes *root*, *pos* and *form* from Filosoft's mrf input and reformats as
EstNLTK's analysis dict:
{
"clitic": string,
"ending": string,
"form": string,
"partofspeech": string,
... | python | def get_analysis_dict( root, pos, form ):
''' Takes *root*, *pos* and *form* from Filosoft's mrf input and reformats as
EstNLTK's analysis dict:
{
"clitic": string,
"ending": string,
"form": string,
"partofspeech": string,
... | [
"def",
"get_analysis_dict",
"(",
"root",
",",
"pos",
",",
"form",
")",
":",
"import",
"sys",
"result",
"=",
"{",
"CLITIC",
":",
"\"\"",
",",
"ENDING",
":",
"\"\"",
",",
"FORM",
":",
"form",
",",
"POSTAG",
":",
"pos",
",",
"ROOT",
":",
"\"\"",
"}",
... | Takes *root*, *pos* and *form* from Filosoft's mrf input and reformats as
EstNLTK's analysis dict:
{
"clitic": string,
"ending": string,
"form": string,
"partofspeech": string,
"root": string
},
... | [
"Takes",
"*",
"root",
"*",
"*",
"pos",
"*",
"and",
"*",
"form",
"*",
"from",
"Filosoft",
"s",
"mrf",
"input",
"and",
"reformats",
"as",
"EstNLTK",
"s",
"analysis",
"dict",
":",
"{",
"clitic",
":",
"string",
"ending",
":",
"string",
"form",
":",
"stri... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L441-L477 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | read_text_from_idx_file | def read_text_from_idx_file( file_name, layer_name=WORDS, keep_init_lines=False ):
''' Reads IDX format morphological annotations from given file, and returns as a Text
object.
The Text object will be tokenized for paragraphs, sentences, words, and it will
contain morphological ann... | python | def read_text_from_idx_file( file_name, layer_name=WORDS, keep_init_lines=False ):
''' Reads IDX format morphological annotations from given file, and returns as a Text
object.
The Text object will be tokenized for paragraphs, sentences, words, and it will
contain morphological ann... | [
"def",
"read_text_from_idx_file",
"(",
"file_name",
",",
"layer_name",
"=",
"WORDS",
",",
"keep_init_lines",
"=",
"False",
")",
":",
"from",
"nltk",
".",
"tokenize",
".",
"simple",
"import",
"LineTokenizer",
"from",
"nltk",
".",
"tokenize",
".",
"regexp",
"imp... | Reads IDX format morphological annotations from given file, and returns as a Text
object.
The Text object will be tokenized for paragraphs, sentences, words, and it will
contain morphological annotations in the layer *layer_name* (by default: WORDS);
Parameters
... | [
"Reads",
"IDX",
"format",
"morphological",
"annotations",
"from",
"given",
"file",
"and",
"returns",
"as",
"a",
"Text",
"object",
".",
"The",
"Text",
"object",
"will",
"be",
"tokenized",
"for",
"paragraphs",
"sentences",
"words",
"and",
"it",
"will",
"contain"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L481-L609 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | get_original_vs_converted_diff | def get_original_vs_converted_diff( original ,converted ):
''' Compares the *original* text to *converted* text, and detects changes/differences in
morphological annotations.
The method constructs line-by-line comparison string, where lines are separated by
newline, and '***' at the beg... | python | def get_original_vs_converted_diff( original ,converted ):
''' Compares the *original* text to *converted* text, and detects changes/differences in
morphological annotations.
The method constructs line-by-line comparison string, where lines are separated by
newline, and '***' at the beg... | [
"def",
"get_original_vs_converted_diff",
"(",
"original",
",",
"converted",
")",
":",
"from",
"estnltk",
".",
"syntax",
".",
"syntax_preprocessing",
"import",
"convert_Text_to_mrf",
"old_layer_mrf",
"=",
"convert_Text_to_mrf",
"(",
"original",
")",
"new_layer_mrf",
"=",... | Compares the *original* text to *converted* text, and detects changes/differences in
morphological annotations.
The method constructs line-by-line comparison string, where lines are separated by
newline, and '***' at the beginning of the line indicates the difference.
Returns a pair... | [
"Compares",
"the",
"*",
"original",
"*",
"text",
"to",
"*",
"converted",
"*",
"text",
"and",
"detects",
"changes",
"/",
"differences",
"in",
"morphological",
"annotations",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L613-L669 |
estnltk/estnltk | estnltk/mw_verbs/verbchain_detector.py | removeRedundantVerbChains | def removeRedundantVerbChains( foundChains, removeOverlapping = True, removeSingleAraAndEi = False ):
''' Eemaldab yleliigsed verbiahelad: ahelad, mis katavad osaliselt v6i t2ielikult
teisi ahelaid (removeOverlapping == True), yhes6nalised 'ei' ja 'ära' ahelad (kui
removeSingleAraAndEi == True)... | python | def removeRedundantVerbChains( foundChains, removeOverlapping = True, removeSingleAraAndEi = False ):
''' Eemaldab yleliigsed verbiahelad: ahelad, mis katavad osaliselt v6i t2ielikult
teisi ahelaid (removeOverlapping == True), yhes6nalised 'ei' ja 'ära' ahelad (kui
removeSingleAraAndEi == True)... | [
"def",
"removeRedundantVerbChains",
"(",
"foundChains",
",",
"removeOverlapping",
"=",
"True",
",",
"removeSingleAraAndEi",
"=",
"False",
")",
":",
"toDelete",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"foundChains",
")",
")",
":",
"matchObj... | Eemaldab yleliigsed verbiahelad: ahelad, mis katavad osaliselt v6i t2ielikult
teisi ahelaid (removeOverlapping == True), yhes6nalised 'ei' ja 'ära' ahelad (kui
removeSingleAraAndEi == True);
Yldiselt on nii, et ylekattuvaid ei tohiks palju olla, kuna fraaside laiendamisel
... | [
"Eemaldab",
"yleliigsed",
"verbiahelad",
":",
"ahelad",
"mis",
"katavad",
"osaliselt",
"v6i",
"t2ielikult",
"teisi",
"ahelaid",
"(",
"removeOverlapping",
"==",
"True",
")",
"yhes6nalised",
"ei",
"ja",
"ära",
"ahelad",
"(",
"kui",
"removeSingleAraAndEi",
"==",
"Tru... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_detector.py#L37-L85 |
estnltk/estnltk | estnltk/mw_verbs/verbchain_detector.py | addGrammaticalFeatsAndRoots | def addGrammaticalFeatsAndRoots( sentence, foundChains ):
''' Täiendab leitud verbiahelaid, lisades iga ahela kylge selle s6nade lemmad (ROOT
v2ljad morf analyysist) ning morfoloogilised tunnused (POSTAG+FORM: eraldajaks
'_' ning kui on mitu varianti, siis tuuakse k6ik variandid, eraldajaks '/'... | python | def addGrammaticalFeatsAndRoots( sentence, foundChains ):
''' Täiendab leitud verbiahelaid, lisades iga ahela kylge selle s6nade lemmad (ROOT
v2ljad morf analyysist) ning morfoloogilised tunnused (POSTAG+FORM: eraldajaks
'_' ning kui on mitu varianti, siis tuuakse k6ik variandid, eraldajaks '/'... | [
"def",
"addGrammaticalFeatsAndRoots",
"(",
"sentence",
",",
"foundChains",
")",
":",
"_indicPresent",
"=",
"[",
"'n'",
",",
"'d'",
",",
"'b'",
",",
"'me'",
",",
"'te'",
",",
"'vad'",
"]",
"_indicImperfect",
"=",
"[",
"'sin'",
",",
"'sid'",
",",
"'s'",
",... | Täiendab leitud verbiahelaid, lisades iga ahela kylge selle s6nade lemmad (ROOT
v2ljad morf analyysist) ning morfoloogilised tunnused (POSTAG+FORM: eraldajaks
'_' ning kui on mitu varianti, siis tuuakse k6ik variandid, eraldajaks '/');
Atribuudid ROOTS ja MORPH sisaldavad tunnuste loetelusi... | [
"Täiendab",
"leitud",
"verbiahelaid",
"lisades",
"iga",
"ahela",
"kylge",
"selle",
"s6nade",
"lemmad",
"(",
"ROOT",
"v2ljad",
"morf",
"analyysist",
")",
"ning",
"morfoloogilised",
"tunnused",
"(",
"POSTAG",
"+",
"FORM",
":",
"eraldajaks",
"_",
"ning",
"kui",
"... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_detector.py#L88-L410 |
estnltk/estnltk | estnltk/mw_verbs/verbchain_detector.py | VerbChainDetector.detectVerbChainsFromSent | def detectVerbChainsFromSent( self, sentence, **kwargs):
''' Detect verb chains from given sentence.
Parameters
----------
sentence: list of dict
A list of sentence words, each word in form of a dictionary containing
morphological analysis and clause bou... | python | def detectVerbChainsFromSent( self, sentence, **kwargs):
''' Detect verb chains from given sentence.
Parameters
----------
sentence: list of dict
A list of sentence words, each word in form of a dictionary containing
morphological analysis and clause bou... | [
"def",
"detectVerbChainsFromSent",
"(",
"self",
",",
"sentence",
",",
"*",
"*",
"kwargs",
")",
":",
"# 0) Parse given arguments\r",
"expand2ndTime",
"=",
"False",
"removeOverlapping",
"=",
"True",
"removeSingleAraEi",
"=",
"True",
"breakOnPunctuation",
"=",
"False",
... | Detect verb chains from given sentence.
Parameters
----------
sentence: list of dict
A list of sentence words, each word in form of a dictionary containing
morphological analysis and clause boundary annotations (must have CLAUSE_IDX);
Keyword p... | [
"Detect",
"verb",
"chains",
"from",
"given",
"sentence",
".",
"Parameters",
"----------",
"sentence",
":",
"list",
"of",
"dict",
"A",
"list",
"of",
"sentence",
"words",
"each",
"word",
"in",
"form",
"of",
"a",
"dictionary",
"containing",
"morphological",
"anal... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_detector.py#L460-L595 |
estnltk/estnltk | estnltk/wiki/internalLink.py | findBalanced | def findBalanced(text, openDelim, closeDelim):
"""
Assuming that text contains a properly balanced expression
:param openDelim: as opening delimiters and
:param closeDelim: as closing delimiters.
:return: an iterator producing pairs (start, end) of start and end
positions in text containing a ba... | python | def findBalanced(text, openDelim, closeDelim):
"""
Assuming that text contains a properly balanced expression
:param openDelim: as opening delimiters and
:param closeDelim: as closing delimiters.
:return: an iterator producing pairs (start, end) of start and end
positions in text containing a ba... | [
"def",
"findBalanced",
"(",
"text",
",",
"openDelim",
",",
"closeDelim",
")",
":",
"openPat",
"=",
"'|'",
".",
"join",
"(",
"[",
"re",
".",
"escape",
"(",
"x",
")",
"for",
"x",
"in",
"openDelim",
"]",
")",
"# pattern for delimiters expected after each openin... | Assuming that text contains a properly balanced expression
:param openDelim: as opening delimiters and
:param closeDelim: as closing delimiters.
:return: an iterator producing pairs (start, end) of start and end
positions in text containing a balanced expression. | [
"Assuming",
"that",
"text",
"contains",
"a",
"properly",
"balanced",
"expression",
":",
"param",
"openDelim",
":",
"as",
"opening",
"delimiters",
"and",
":",
"param",
"closeDelim",
":",
"as",
"closing",
"delimiters",
".",
":",
"return",
":",
"an",
"iterator",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/internalLink.py#L31-L70 |
estnltk/estnltk | estnltk/core.py | as_unicode | def as_unicode(s, encoding='utf-8'):
"""Force conversion of given string to unicode type.
Unicode is ``str`` type for Python 3.x and ``unicode`` for Python 2.x .
If the string is already in unicode, then no conversion is done and the same string is returned.
Parameters
----------
s: str or byt... | python | def as_unicode(s, encoding='utf-8'):
"""Force conversion of given string to unicode type.
Unicode is ``str`` type for Python 3.x and ``unicode`` for Python 2.x .
If the string is already in unicode, then no conversion is done and the same string is returned.
Parameters
----------
s: str or byt... | [
"def",
"as_unicode",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"six",
".",
"text_type",
")",
":",
"return",
"s",
"elif",
"isinstance",
"(",
"s",
",",
"six",
".",
"binary_type",
")",
":",
"return",
"s",
... | Force conversion of given string to unicode type.
Unicode is ``str`` type for Python 3.x and ``unicode`` for Python 2.x .
If the string is already in unicode, then no conversion is done and the same string is returned.
Parameters
----------
s: str or bytes (Python3), str or unicode (Python2)
... | [
"Force",
"conversion",
"of",
"given",
"string",
"to",
"unicode",
"type",
".",
"Unicode",
"is",
"str",
"type",
"for",
"Python",
"3",
".",
"x",
"and",
"unicode",
"for",
"Python",
"2",
".",
"x",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/core.py#L141-L168 |
estnltk/estnltk | estnltk/core.py | as_binary | def as_binary(s, encoding='utf-8'):
"""Force conversion of given string to binary type.
Binary is ``bytes`` type for Python 3.x and ``str`` for Python 2.x .
If the string is already in binary, then no conversion is done and the same string is returned
and ``encoding`` argument is ignored.
Paramete... | python | def as_binary(s, encoding='utf-8'):
"""Force conversion of given string to binary type.
Binary is ``bytes`` type for Python 3.x and ``str`` for Python 2.x .
If the string is already in binary, then no conversion is done and the same string is returned
and ``encoding`` argument is ignored.
Paramete... | [
"def",
"as_binary",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"six",
".",
"text_type",
")",
":",
"return",
"s",
".",
"encode",
"(",
"encoding",
")",
"elif",
"isinstance",
"(",
"s",
",",
"six",
".",
"bin... | Force conversion of given string to binary type.
Binary is ``bytes`` type for Python 3.x and ``str`` for Python 2.x .
If the string is already in binary, then no conversion is done and the same string is returned
and ``encoding`` argument is ignored.
Parameters
----------
s: str or bytes (Pyth... | [
"Force",
"conversion",
"of",
"given",
"string",
"to",
"binary",
"type",
".",
"Binary",
"is",
"bytes",
"type",
"for",
"Python",
"3",
".",
"x",
"and",
"str",
"for",
"Python",
"2",
".",
"x",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/core.py#L171-L200 |
estnltk/estnltk | estnltk/core.py | get_filenames | def get_filenames(root, prefix=u'', suffix=u''):
"""Function for listing filenames with given prefix and suffix in the root directory.
Parameters
----------
prefix: str
The prefix of the required files.
suffix: str
The suffix of the required files
Returns
-... | python | def get_filenames(root, prefix=u'', suffix=u''):
"""Function for listing filenames with given prefix and suffix in the root directory.
Parameters
----------
prefix: str
The prefix of the required files.
suffix: str
The suffix of the required files
Returns
-... | [
"def",
"get_filenames",
"(",
"root",
",",
"prefix",
"=",
"u''",
",",
"suffix",
"=",
"u''",
")",
":",
"return",
"[",
"fnm",
"for",
"fnm",
"in",
"os",
".",
"listdir",
"(",
"root",
")",
"if",
"fnm",
".",
"startswith",
"(",
"prefix",
")",
"and",
"fnm",... | Function for listing filenames with given prefix and suffix in the root directory.
Parameters
----------
prefix: str
The prefix of the required files.
suffix: str
The suffix of the required files
Returns
-------
list of str
List of filenames matchin... | [
"Function",
"for",
"listing",
"filenames",
"with",
"given",
"prefix",
"and",
"suffix",
"in",
"the",
"root",
"directory",
".",
"Parameters",
"----------",
"prefix",
":",
"str",
"The",
"prefix",
"of",
"the",
"required",
"files",
".",
"suffix",
":",
"str",
"The... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/core.py#L203-L219 |
estnltk/estnltk | estnltk/taggers/event_tagger.py | KeywordTagger.tag | def tag(self, text):
"""Retrieves list of keywords in text.
Parameters
----------
text: Text
The text to search for events.
Returns
-------
list of vents sorted by start, end
"""
if self.search_method == 'ahocorasick':
eve... | python | def tag(self, text):
"""Retrieves list of keywords in text.
Parameters
----------
text: Text
The text to search for events.
Returns
-------
list of vents sorted by start, end
"""
if self.search_method == 'ahocorasick':
eve... | [
"def",
"tag",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"search_method",
"==",
"'ahocorasick'",
":",
"events",
"=",
"self",
".",
"_find_keywords_ahocorasick",
"(",
"text",
".",
"text",
")",
"elif",
"self",
".",
"search_method",
"==",
"'naive'"... | Retrieves list of keywords in text.
Parameters
----------
text: Text
The text to search for events.
Returns
-------
list of vents sorted by start, end | [
"Retrieves",
"list",
"of",
"keywords",
"in",
"text",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/taggers/event_tagger.py#L129-L156 |
estnltk/estnltk | estnltk/taggers/event_tagger.py | RegexTagger.tag | def tag(self, text):
"""Retrieves list of regex_matches in text.
Parameters
----------
text: Text
The estnltk text object to search for events.
Returns
-------
list of matches
"""
matches = self._match(text.text)
matches = sel... | python | def tag(self, text):
"""Retrieves list of regex_matches in text.
Parameters
----------
text: Text
The estnltk text object to search for events.
Returns
-------
list of matches
"""
matches = self._match(text.text)
matches = sel... | [
"def",
"tag",
"(",
"self",
",",
"text",
")",
":",
"matches",
"=",
"self",
".",
"_match",
"(",
"text",
".",
"text",
")",
"matches",
"=",
"self",
".",
"_resolve_conflicts",
"(",
"matches",
")",
"if",
"self",
".",
"return_layer",
":",
"return",
"matches",... | Retrieves list of regex_matches in text.
Parameters
----------
text: Text
The estnltk text object to search for events.
Returns
-------
list of matches | [
"Retrieves",
"list",
"of",
"regex_matches",
"in",
"text",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/taggers/event_tagger.py#L201-L219 |
estnltk/estnltk | estnltk/taggers/event_tagger.py | EventTagger.tag | def tag(self, text):
"""Retrieves list of events in the text.
Parameters
----------
text: Text
The text to search for events.
Returns
-------
list of events sorted by start, end
"""
if self.search_method == 'ahocor... | python | def tag(self, text):
"""Retrieves list of events in the text.
Parameters
----------
text: Text
The text to search for events.
Returns
-------
list of events sorted by start, end
"""
if self.search_method == 'ahocor... | [
"def",
"tag",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"search_method",
"==",
"'ahocorasick'",
":",
"events",
"=",
"self",
".",
"_find_events_ahocorasick",
"(",
"text",
".",
"text",
")",
"elif",
"self",
".",
"search_method",
"==",
"'naive'",
... | Retrieves list of events in the text.
Parameters
----------
text: Text
The text to search for events.
Returns
-------
list of events sorted by start, end | [
"Retrieves",
"list",
"of",
"events",
"in",
"the",
"text",
".",
"Parameters",
"----------",
"text",
":",
"Text",
"The",
"text",
"to",
"search",
"for",
"events",
".",
"Returns",
"-------",
"list",
"of",
"events",
"sorted",
"by",
"start",
"end"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/taggers/event_tagger.py#L433-L457 |
estnltk/estnltk | estnltk/taggers/adjective_phrase_tagger/adj_phrase_tagger.py | AdjectivePhraseTagger.__extract_lemmas | def __extract_lemmas(self, doc, m, phrase):
"""
:param sent: sentence from which the match was found
:param m: the found match
:phrase: name of the phrase
:return: tuple of the lemmas in the match
"""
ph_start = m['start']
ph_end = m['end']
start_... | python | def __extract_lemmas(self, doc, m, phrase):
"""
:param sent: sentence from which the match was found
:param m: the found match
:phrase: name of the phrase
:return: tuple of the lemmas in the match
"""
ph_start = m['start']
ph_end = m['end']
start_... | [
"def",
"__extract_lemmas",
"(",
"self",
",",
"doc",
",",
"m",
",",
"phrase",
")",
":",
"ph_start",
"=",
"m",
"[",
"'start'",
"]",
"ph_end",
"=",
"m",
"[",
"'end'",
"]",
"start_index",
"=",
"None",
"for",
"ind",
",",
"word",
"in",
"enumerate",
"(",
... | :param sent: sentence from which the match was found
:param m: the found match
:phrase: name of the phrase
:return: tuple of the lemmas in the match | [
":",
"param",
"sent",
":",
"sentence",
"from",
"which",
"the",
"match",
"was",
"found",
":",
"param",
"m",
":",
"the",
"found",
"match",
":",
"phrase",
":",
"name",
"of",
"the",
"phrase",
":",
"return",
":",
"tuple",
"of",
"the",
"lemmas",
"in",
"the... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/taggers/adjective_phrase_tagger/adj_phrase_tagger.py#L23-L58 |
estnltk/estnltk | estnltk/corpus.py | yield_json_corpus | def yield_json_corpus(fnm):
"""Function to read a JSON corpus from a file.
A JSON corpus contains one document per line, encoded in JSON.
Each line is yielded after it is read.
Parameters
----------
fnm: str
The filename of the corpus.
Returns
-------
generator of Text
... | python | def yield_json_corpus(fnm):
"""Function to read a JSON corpus from a file.
A JSON corpus contains one document per line, encoded in JSON.
Each line is yielded after it is read.
Parameters
----------
fnm: str
The filename of the corpus.
Returns
-------
generator of Text
... | [
"def",
"yield_json_corpus",
"(",
"fnm",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"fnm",
",",
"'rb'",
",",
"'ascii'",
")",
"as",
"f",
":",
"line",
"=",
"f",
".",
"readline",
"(",
")",
"while",
"line",
"!=",
"''",
":",
"yield",
"Text",
"(",
"j... | Function to read a JSON corpus from a file.
A JSON corpus contains one document per line, encoded in JSON.
Each line is yielded after it is read.
Parameters
----------
fnm: str
The filename of the corpus.
Returns
-------
generator of Text | [
"Function",
"to",
"read",
"a",
"JSON",
"corpus",
"from",
"a",
"file",
".",
"A",
"JSON",
"corpus",
"contains",
"one",
"document",
"per",
"line",
"encoded",
"in",
"JSON",
".",
"Each",
"line",
"is",
"yielded",
"after",
"it",
"is",
"read",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/corpus.py#L10-L28 |
estnltk/estnltk | estnltk/corpus.py | write_json_corpus | def write_json_corpus(documents, fnm):
"""Write a lisst of Text instances as JSON corpus on disk.
A JSON corpus contains one document per line, encoded in JSON.
Parameters
----------
documents: iterable of estnltk.text.Text
The documents of the corpus
fnm: str
The path to save t... | python | def write_json_corpus(documents, fnm):
"""Write a lisst of Text instances as JSON corpus on disk.
A JSON corpus contains one document per line, encoded in JSON.
Parameters
----------
documents: iterable of estnltk.text.Text
The documents of the corpus
fnm: str
The path to save t... | [
"def",
"write_json_corpus",
"(",
"documents",
",",
"fnm",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"fnm",
",",
"'wb'",
",",
"'ascii'",
")",
"as",
"f",
":",
"for",
"document",
"in",
"documents",
":",
"f",
".",
"write",
"(",
"json",
".",
"dumps",
... | Write a lisst of Text instances as JSON corpus on disk.
A JSON corpus contains one document per line, encoded in JSON.
Parameters
----------
documents: iterable of estnltk.text.Text
The documents of the corpus
fnm: str
The path to save the corpus. | [
"Write",
"a",
"lisst",
"of",
"Text",
"instances",
"as",
"JSON",
"corpus",
"on",
"disk",
".",
"A",
"JSON",
"corpus",
"contains",
"one",
"document",
"per",
"line",
"encoded",
"in",
"JSON",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/corpus.py#L47-L61 |
estnltk/estnltk | estnltk/corpus.py | read_document | def read_document(fnm):
"""Read a document that is stored in a text file as JSON.
Parameters
----------
fnm: str
The path of the document.
Returns
-------
Text
"""
with codecs.open(fnm, 'rb', 'ascii') as f:
return Text(json.loads(f.read())) | python | def read_document(fnm):
"""Read a document that is stored in a text file as JSON.
Parameters
----------
fnm: str
The path of the document.
Returns
-------
Text
"""
with codecs.open(fnm, 'rb', 'ascii') as f:
return Text(json.loads(f.read())) | [
"def",
"read_document",
"(",
"fnm",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"fnm",
",",
"'rb'",
",",
"'ascii'",
")",
"as",
"f",
":",
"return",
"Text",
"(",
"json",
".",
"loads",
"(",
"f",
".",
"read",
"(",
")",
")",
")"
] | Read a document that is stored in a text file as JSON.
Parameters
----------
fnm: str
The path of the document.
Returns
-------
Text | [
"Read",
"a",
"document",
"that",
"is",
"stored",
"in",
"a",
"text",
"file",
"as",
"JSON",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/corpus.py#L64-L77 |
estnltk/estnltk | estnltk/corpus.py | write_document | def write_document(doc, fnm):
"""Write a Text document to file.
Parameters
----------
doc: Text
The document to save.
fnm: str
The filename to save the document
"""
with codecs.open(fnm, 'wb', 'ascii') as f:
f.write(json.dumps(doc, indent=2)) | python | def write_document(doc, fnm):
"""Write a Text document to file.
Parameters
----------
doc: Text
The document to save.
fnm: str
The filename to save the document
"""
with codecs.open(fnm, 'wb', 'ascii') as f:
f.write(json.dumps(doc, indent=2)) | [
"def",
"write_document",
"(",
"doc",
",",
"fnm",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"fnm",
",",
"'wb'",
",",
"'ascii'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"json",
".",
"dumps",
"(",
"doc",
",",
"indent",
"=",
"2",
")",
")"
... | Write a Text document to file.
Parameters
----------
doc: Text
The document to save.
fnm: str
The filename to save the document | [
"Write",
"a",
"Text",
"document",
"to",
"file",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/corpus.py#L80-L91 |
estnltk/estnltk | estnltk/wordnet/eurown.py | addRelation | def addRelation(sourceSynset,relationName,targetSynset):
"""
Adds relation with name <relationName> to
<targetSynset>.
"""
if not isinstance(sourceSynset, Synset):
raise TypeError("sourceSynset not Synset instance")
elif not isinstance(targetSynset, Synset):
raise TypeError("tar... | python | def addRelation(sourceSynset,relationName,targetSynset):
"""
Adds relation with name <relationName> to
<targetSynset>.
"""
if not isinstance(sourceSynset, Synset):
raise TypeError("sourceSynset not Synset instance")
elif not isinstance(targetSynset, Synset):
raise TypeError("tar... | [
"def",
"addRelation",
"(",
"sourceSynset",
",",
"relationName",
",",
"targetSynset",
")",
":",
"if",
"not",
"isinstance",
"(",
"sourceSynset",
",",
"Synset",
")",
":",
"raise",
"TypeError",
"(",
"\"sourceSynset not Synset instance\"",
")",
"elif",
"not",
"isinstan... | Adds relation with name <relationName> to
<targetSynset>. | [
"Adds",
"relation",
"with",
"name",
"<relationName",
">",
"to",
"<targetSynset",
">",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2399-L2415 |
estnltk/estnltk | estnltk/wordnet/eurown.py | _TypedList.polarisText | def polarisText():
"""polarisText part of _TypedList objects
"""
def fget(self):
_out = ''
_n = '\n'
if len(self):
if self.parent:
_out = '%s%s%s' % (_out, PolarisText(
*self.parent).out,_n)
... | python | def polarisText():
"""polarisText part of _TypedList objects
"""
def fget(self):
_out = ''
_n = '\n'
if len(self):
if self.parent:
_out = '%s%s%s' % (_out, PolarisText(
*self.parent).out,_n)
... | [
"def",
"polarisText",
"(",
")",
":",
"def",
"fget",
"(",
"self",
")",
":",
"_out",
"=",
"''",
"_n",
"=",
"'\\n'",
"if",
"len",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
":",
"_out",
"=",
"'%s%s%s'",
"%",
"(",
"_out",
",",
"PolarisText",... | polarisText part of _TypedList objects | [
"polarisText",
"part",
"of",
"_TypedList",
"objects"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L97-L115 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Relation.addFeature | def addFeature(self, feature):
'''Appends Feature'''
if isinstance(feature, Feature):
self.features.append(feature)
else:
raise TypeError(
'feature Type should be Feature, not %s' % type(feature)) | python | def addFeature(self, feature):
'''Appends Feature'''
if isinstance(feature, Feature):
self.features.append(feature)
else:
raise TypeError(
'feature Type should be Feature, not %s' % type(feature)) | [
"def",
"addFeature",
"(",
"self",
",",
"feature",
")",
":",
"if",
"isinstance",
"(",
"feature",
",",
"Feature",
")",
":",
"self",
".",
"features",
".",
"append",
"(",
"feature",
")",
"else",
":",
"raise",
"TypeError",
"(",
"'feature Type should be Feature, n... | Appends Feature | [
"Appends",
"Feature"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L231-L238 |
estnltk/estnltk | estnltk/wordnet/eurown.py | External_Info.addSourceId | def addSourceId(self, value):
'''Adds SourceId to External_Info
'''
if isinstance(value, Source_Id):
self.source_ids.append(value)
else:
raise (TypeError,
'source_id Type should be Source_Id, not %s' % type(source_id)) | python | def addSourceId(self, value):
'''Adds SourceId to External_Info
'''
if isinstance(value, Source_Id):
self.source_ids.append(value)
else:
raise (TypeError,
'source_id Type should be Source_Id, not %s' % type(source_id)) | [
"def",
"addSourceId",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Source_Id",
")",
":",
"self",
".",
"source_ids",
".",
"append",
"(",
"value",
")",
"else",
":",
"raise",
"(",
"TypeError",
",",
"'source_id Type should be So... | Adds SourceId to External_Info | [
"Adds",
"SourceId",
"to",
"External_Info"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L815-L822 |
estnltk/estnltk | estnltk/wordnet/eurown.py | External_Info.addCorpusId | def addCorpusId(self, value):
'''Adds SourceId to External_Info
'''
if isinstance(value, Corpus_Id):
self.corpus_ids.append(value)
else:
raise (TypeError,
'source_id Type should be Source_Id, not %s' % type(source_id)) | python | def addCorpusId(self, value):
'''Adds SourceId to External_Info
'''
if isinstance(value, Corpus_Id):
self.corpus_ids.append(value)
else:
raise (TypeError,
'source_id Type should be Source_Id, not %s' % type(source_id)) | [
"def",
"addCorpusId",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Corpus_Id",
")",
":",
"self",
".",
"corpus_ids",
".",
"append",
"(",
"value",
")",
"else",
":",
"raise",
"(",
"TypeError",
",",
"'source_id Type should be So... | Adds SourceId to External_Info | [
"Adds",
"SourceId",
"to",
"External_Info"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L823-L830 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Parser.parse_line | def parse_line(self,iStr):
"""Parses ewn file line
"""
self.levelNumber = None
self.DRN = None
self.fieldTag = None
self.fieldValue = None
self.noQuotes = None
if iStr and not(iStr.strip().startswith('#')):
iList = iStr.strip().split(' ')
... | python | def parse_line(self,iStr):
"""Parses ewn file line
"""
self.levelNumber = None
self.DRN = None
self.fieldTag = None
self.fieldValue = None
self.noQuotes = None
if iStr and not(iStr.strip().startswith('#')):
iList = iStr.strip().split(' ')
... | [
"def",
"parse_line",
"(",
"self",
",",
"iStr",
")",
":",
"self",
".",
"levelNumber",
"=",
"None",
"self",
".",
"DRN",
"=",
"None",
"self",
".",
"fieldTag",
"=",
"None",
"self",
".",
"fieldValue",
"=",
"None",
"self",
".",
"noQuotes",
"=",
"None",
"if... | Parses ewn file line | [
"Parses",
"ewn",
"file",
"line"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1126-L1156 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Parser.parse_synset | def parse_synset(self, offset=None, debug=False):
"""Parses Synset from file
"""
if False:
pass
else:
# WORD_INSTANCE
def _word_instance():
_synset(True)
# WORD_MEANING
def _synset(pn=False):
if ... | python | def parse_synset(self, offset=None, debug=False):
"""Parses Synset from file
"""
if False:
pass
else:
# WORD_INSTANCE
def _word_instance():
_synset(True)
# WORD_MEANING
def _synset(pn=False):
if ... | [
"def",
"parse_synset",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"if",
"False",
":",
"pass",
"else",
":",
"# WORD_INSTANCE",
"def",
"_word_instance",
"(",
")",
":",
"_synset",
"(",
"True",
")",
"# WORD_MEANING",
"def"... | Parses Synset from file | [
"Parses",
"Synset",
"from",
"file"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1158-L1479 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Parser.parse_wordnet | def parse_wordnet(self,debug=False):
'''Parses wordnet from
<self.file>
'''
synList = []
self.milestone = 0 # to start from beginning of file
while self.milestone < os.path.getsize(self.fileName) - 5:
if debug:
print ('self.milestone', self.mi... | python | def parse_wordnet(self,debug=False):
'''Parses wordnet from
<self.file>
'''
synList = []
self.milestone = 0 # to start from beginning of file
while self.milestone < os.path.getsize(self.fileName) - 5:
if debug:
print ('self.milestone', self.mi... | [
"def",
"parse_wordnet",
"(",
"self",
",",
"debug",
"=",
"False",
")",
":",
"synList",
"=",
"[",
"]",
"self",
".",
"milestone",
"=",
"0",
"# to start from beginning of file",
"while",
"self",
".",
"milestone",
"<",
"os",
".",
"path",
".",
"getsize",
"(",
... | Parses wordnet from
<self.file> | [
"Parses",
"wordnet",
"from",
"<self",
".",
"file",
">"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1481-L1493 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Variant.addTranslation | def addTranslation(self,translation):
'''Appends one Translation to translations
'''
if isinstance(translation, Translation):
self.translations.append(translation)
else:
raise(TranslationError,
'translation Type should be Translation, not %s' % ... | python | def addTranslation(self,translation):
'''Appends one Translation to translations
'''
if isinstance(translation, Translation):
self.translations.append(translation)
else:
raise(TranslationError,
'translation Type should be Translation, not %s' % ... | [
"def",
"addTranslation",
"(",
"self",
",",
"translation",
")",
":",
"if",
"isinstance",
"(",
"translation",
",",
"Translation",
")",
":",
"self",
".",
"translations",
".",
"append",
"(",
"translation",
")",
"else",
":",
"raise",
"(",
"TranslationError",
",",... | Appends one Translation to translations | [
"Appends",
"one",
"Translation",
"to",
"translations"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1717-L1726 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Variant.addVariantFeature | def addVariantFeature(self,variantFeature):
'''Appends one VariantFeature to variantFeatures
'''
if isinstance(variantFeature, Feature):
self.features.append(variantFeature)
else:
raise(TypeError,
'variantFeature Type should be Feature, not %s' %... | python | def addVariantFeature(self,variantFeature):
'''Appends one VariantFeature to variantFeatures
'''
if isinstance(variantFeature, Feature):
self.features.append(variantFeature)
else:
raise(TypeError,
'variantFeature Type should be Feature, not %s' %... | [
"def",
"addVariantFeature",
"(",
"self",
",",
"variantFeature",
")",
":",
"if",
"isinstance",
"(",
"variantFeature",
",",
"Feature",
")",
":",
"self",
".",
"features",
".",
"append",
"(",
"variantFeature",
")",
"else",
":",
"raise",
"(",
"TypeError",
",",
... | Appends one VariantFeature to variantFeatures | [
"Appends",
"one",
"VariantFeature",
"to",
"variantFeatures"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1728-L1737 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Variant.addUsage_Label | def addUsage_Label(self,usage_label):
'''Appends one Usage_Label to usage_labels
'''
if isinstance(usage_label, Usage_Label):
self.usage_labels.append(usage_label)
else:
raise (Usage_LabelError,
'usage_label Type should be Usage_Label, not %s' %... | python | def addUsage_Label(self,usage_label):
'''Appends one Usage_Label to usage_labels
'''
if isinstance(usage_label, Usage_Label):
self.usage_labels.append(usage_label)
else:
raise (Usage_LabelError,
'usage_label Type should be Usage_Label, not %s' %... | [
"def",
"addUsage_Label",
"(",
"self",
",",
"usage_label",
")",
":",
"if",
"isinstance",
"(",
"usage_label",
",",
"Usage_Label",
")",
":",
"self",
".",
"usage_labels",
".",
"append",
"(",
"usage_label",
")",
"else",
":",
"raise",
"(",
"Usage_LabelError",
",",... | Appends one Usage_Label to usage_labels | [
"Appends",
"one",
"Usage_Label",
"to",
"usage_labels"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1739-L1748 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Variant.addExample | def addExample(self,example):
'''Appends one Example to examples
'''
if isinstance(example, Example):
self.examples.append(example)
else:
raise (ExampleError,
'example Type should be Example, not %s' % type(example)
) | python | def addExample(self,example):
'''Appends one Example to examples
'''
if isinstance(example, Example):
self.examples.append(example)
else:
raise (ExampleError,
'example Type should be Example, not %s' % type(example)
) | [
"def",
"addExample",
"(",
"self",
",",
"example",
")",
":",
"if",
"isinstance",
"(",
"example",
",",
"Example",
")",
":",
"self",
".",
"examples",
".",
"append",
"(",
"example",
")",
"else",
":",
"raise",
"(",
"ExampleError",
",",
"'example Type should be ... | Appends one Example to examples | [
"Appends",
"one",
"Example",
"to",
"examples"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1750-L1758 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.firstVariant | def firstVariant():
"""first variant of Variants
Read-only
"""
def fget(self):
if self.variants:
return self.variants[0]
else:
variant = Variant()
return variant
return locals() | python | def firstVariant():
"""first variant of Variants
Read-only
"""
def fget(self):
if self.variants:
return self.variants[0]
else:
variant = Variant()
return variant
return locals() | [
"def",
"firstVariant",
"(",
")",
":",
"def",
"fget",
"(",
"self",
")",
":",
"if",
"self",
".",
"variants",
":",
"return",
"self",
".",
"variants",
"[",
"0",
"]",
"else",
":",
"variant",
"=",
"Variant",
"(",
")",
"return",
"variant",
"return",
"locals... | first variant of Variants
Read-only | [
"first",
"variant",
"of",
"Variants",
"Read",
"-",
"only"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1978-L1990 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.literals | def literals():
'''Returns a list of literals
in the Synset
read-only
'''
def fget(self):
if self.variants:
return map(lambda x: x.literal,
self.variants)
else:
return None
return locals(... | python | def literals():
'''Returns a list of literals
in the Synset
read-only
'''
def fget(self):
if self.variants:
return map(lambda x: x.literal,
self.variants)
else:
return None
return locals(... | [
"def",
"literals",
"(",
")",
":",
"def",
"fget",
"(",
"self",
")",
":",
"if",
"self",
".",
"variants",
":",
"return",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"literal",
",",
"self",
".",
"variants",
")",
"else",
":",
"return",
"None",
"return",
... | Returns a list of literals
in the Synset
read-only | [
"Returns",
"a",
"list",
"of",
"literals",
"in",
"the",
"Synset",
"read",
"-",
"only"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1994-L2006 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.addVariantOld | def addVariantOld(self,
literal='',
sense=0,
gloss='',
examples=[]):
'''Appends variant
sth to do that it would be possible
to add Variant object
'''
var = Variant(literal=literal,
... | python | def addVariantOld(self,
literal='',
sense=0,
gloss='',
examples=[]):
'''Appends variant
sth to do that it would be possible
to add Variant object
'''
var = Variant(literal=literal,
... | [
"def",
"addVariantOld",
"(",
"self",
",",
"literal",
"=",
"''",
",",
"sense",
"=",
"0",
",",
"gloss",
"=",
"''",
",",
"examples",
"=",
"[",
"]",
")",
":",
"var",
"=",
"Variant",
"(",
"literal",
"=",
"literal",
",",
"sense",
"=",
"sense",
",",
"gl... | Appends variant
sth to do that it would be possible
to add Variant object | [
"Appends",
"variant",
"sth",
"to",
"do",
"that",
"it",
"would",
"be",
"possible",
"to",
"add",
"Variant",
"object"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2010-L2024 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.addVariant | def addVariant(self,variant):
'''Appends one Variant to variants
'''
if isinstance(variant, Variant):
self.variants.append(variant)
else:
raise (VariantError,
'variant Type should be Variant, not %s' % type(variant)) | python | def addVariant(self,variant):
'''Appends one Variant to variants
'''
if isinstance(variant, Variant):
self.variants.append(variant)
else:
raise (VariantError,
'variant Type should be Variant, not %s' % type(variant)) | [
"def",
"addVariant",
"(",
"self",
",",
"variant",
")",
":",
"if",
"isinstance",
"(",
"variant",
",",
"Variant",
")",
":",
"self",
".",
"variants",
".",
"append",
"(",
"variant",
")",
"else",
":",
"raise",
"(",
"VariantError",
",",
"'variant Type should be ... | Appends one Variant to variants | [
"Appends",
"one",
"Variant",
"to",
"variants"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2026-L2034 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.addInternalLink | def addInternalLink(self, link):
'''Appends InternalLink
'''
if isinstance(link, InternalLink):
self.internalLinks.append(link)
else:
raise InternalLinkError(
'link Type should be InternalLink, not %s' % type(link)) | python | def addInternalLink(self, link):
'''Appends InternalLink
'''
if isinstance(link, InternalLink):
self.internalLinks.append(link)
else:
raise InternalLinkError(
'link Type should be InternalLink, not %s' % type(link)) | [
"def",
"addInternalLink",
"(",
"self",
",",
"link",
")",
":",
"if",
"isinstance",
"(",
"link",
",",
"InternalLink",
")",
":",
"self",
".",
"internalLinks",
".",
"append",
"(",
"link",
")",
"else",
":",
"raise",
"InternalLinkError",
"(",
"'link Type should be... | Appends InternalLink | [
"Appends",
"InternalLink"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2037-L2045 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.addRelation | def addRelation(self, link):
'''Appends Relation
'''
if isinstance(link, Relation):
self.internalLinks.append(link)
else:
raise TypeError(
'link Type should be InternalLink, not %s' % type(link)) | python | def addRelation(self, link):
'''Appends Relation
'''
if isinstance(link, Relation):
self.internalLinks.append(link)
else:
raise TypeError(
'link Type should be InternalLink, not %s' % type(link)) | [
"def",
"addRelation",
"(",
"self",
",",
"link",
")",
":",
"if",
"isinstance",
"(",
"link",
",",
"Relation",
")",
":",
"self",
".",
"internalLinks",
".",
"append",
"(",
"link",
")",
"else",
":",
"raise",
"TypeError",
"(",
"'link Type should be InternalLink, n... | Appends Relation | [
"Appends",
"Relation"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2047-L2055 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.addEqLink | def addEqLink(self, link):
'''Appends EqLink
'''
if isinstance(link, EqLink):
self.eqLinks.append(link)
else:
raise TypeError(
'link Type should be InternalLink, not %s' % type(link)) | python | def addEqLink(self, link):
'''Appends EqLink
'''
if isinstance(link, EqLink):
self.eqLinks.append(link)
else:
raise TypeError(
'link Type should be InternalLink, not %s' % type(link)) | [
"def",
"addEqLink",
"(",
"self",
",",
"link",
")",
":",
"if",
"isinstance",
"(",
"link",
",",
"EqLink",
")",
":",
"self",
".",
"eqLinks",
".",
"append",
"(",
"link",
")",
"else",
":",
"raise",
"TypeError",
"(",
"'link Type should be InternalLink, not %s'",
... | Appends EqLink | [
"Appends",
"EqLink"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2058-L2066 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.named_relations | def named_relations(self, name, neg=False):
'''Returns list of named Relations.
<name> may be string or list.
'''
if self.internalLinks and not neg:
if isinstance(name, six.string_types):
return filter(lambda x: x.name == name,
... | python | def named_relations(self, name, neg=False):
'''Returns list of named Relations.
<name> may be string or list.
'''
if self.internalLinks and not neg:
if isinstance(name, six.string_types):
return filter(lambda x: x.name == name,
... | [
"def",
"named_relations",
"(",
"self",
",",
"name",
",",
"neg",
"=",
"False",
")",
":",
"if",
"self",
".",
"internalLinks",
"and",
"not",
"neg",
":",
"if",
"isinstance",
"(",
"name",
",",
"six",
".",
"string_types",
")",
":",
"return",
"filter",
"(",
... | Returns list of named Relations.
<name> may be string or list. | [
"Returns",
"list",
"of",
"named",
"Relations",
".",
"<name",
">",
"may",
"be",
"string",
"or",
"list",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2069-L2099 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.named_eq_relations | def named_eq_relations(self, name, neg=False):
'''Returns list of named eqLinks.
<name> may be string or list.
'''
if self.eqLinks and not neg:
if isinstance(name, six.string_types):
return filter(lambda x: x.relation.name == name,
... | python | def named_eq_relations(self, name, neg=False):
'''Returns list of named eqLinks.
<name> may be string or list.
'''
if self.eqLinks and not neg:
if isinstance(name, six.string_types):
return filter(lambda x: x.relation.name == name,
... | [
"def",
"named_eq_relations",
"(",
"self",
",",
"name",
",",
"neg",
"=",
"False",
")",
":",
"if",
"self",
".",
"eqLinks",
"and",
"not",
"neg",
":",
"if",
"isinstance",
"(",
"name",
",",
"six",
".",
"string_types",
")",
":",
"return",
"filter",
"(",
"l... | Returns list of named eqLinks.
<name> may be string or list. | [
"Returns",
"list",
"of",
"named",
"eqLinks",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2102-L2131 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.parse | def parse(self,fileName,offset):
'''Parses synset from file <fileName>
from offset <offset>
'''
p = Parser()
p.file = open(fileName, 'rb')
a = p.parse_synset(offset=offset)
p.file.close()
self.__dict__.update(a.__dict__) | python | def parse(self,fileName,offset):
'''Parses synset from file <fileName>
from offset <offset>
'''
p = Parser()
p.file = open(fileName, 'rb')
a = p.parse_synset(offset=offset)
p.file.close()
self.__dict__.update(a.__dict__) | [
"def",
"parse",
"(",
"self",
",",
"fileName",
",",
"offset",
")",
":",
"p",
"=",
"Parser",
"(",
")",
"p",
".",
"file",
"=",
"open",
"(",
"fileName",
",",
"'rb'",
")",
"a",
"=",
"p",
".",
"parse_synset",
"(",
"offset",
"=",
"offset",
")",
"p",
"... | Parses synset from file <fileName>
from offset <offset> | [
"Parses",
"synset",
"from",
"file",
"<fileName",
">",
"from",
"offset",
"<offset",
">"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2177-L2185 |
estnltk/estnltk | estnltk/wordnet/eurown.py | Synset.write | def write(self,fileName):
'''Appends synset to Polaris IO file <fileName>
'''
f = open(fileName, 'ab')
f.write('%s%s' % (self.polarisText,
Synset.linebreak)
)
f.close() | python | def write(self,fileName):
'''Appends synset to Polaris IO file <fileName>
'''
f = open(fileName, 'ab')
f.write('%s%s' % (self.polarisText,
Synset.linebreak)
)
f.close() | [
"def",
"write",
"(",
"self",
",",
"fileName",
")",
":",
"f",
"=",
"open",
"(",
"fileName",
",",
"'ab'",
")",
"f",
".",
"write",
"(",
"'%s%s'",
"%",
"(",
"self",
".",
"polarisText",
",",
"Synset",
".",
"linebreak",
")",
")",
"f",
".",
"close",
"("... | Appends synset to Polaris IO file <fileName> | [
"Appends",
"synset",
"to",
"Polaris",
"IO",
"file",
"<fileName",
">"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2188-L2195 |
estnltk/estnltk | estnltk/syntax/utils.py | _fix_out_of_sentence_links | def _fix_out_of_sentence_links( alignments, sent_start, sent_end ):
''' Fixes out-of-the-sentence links in the given sentence.
The sentence is a sublist of *alignments*, starting from
*sent_start* and ending one token before *sent_end*;
'''
sent_len = sent_end - sent_start
j = sent_sta... | python | def _fix_out_of_sentence_links( alignments, sent_start, sent_end ):
''' Fixes out-of-the-sentence links in the given sentence.
The sentence is a sublist of *alignments*, starting from
*sent_start* and ending one token before *sent_end*;
'''
sent_len = sent_end - sent_start
j = sent_sta... | [
"def",
"_fix_out_of_sentence_links",
"(",
"alignments",
",",
"sent_start",
",",
"sent_end",
")",
":",
"sent_len",
"=",
"sent_end",
"-",
"sent_start",
"j",
"=",
"sent_start",
"while",
"j",
"<",
"sent_start",
"+",
"sent_len",
":",
"for",
"rel_id",
",",
"rel",
... | Fixes out-of-the-sentence links in the given sentence.
The sentence is a sublist of *alignments*, starting from
*sent_start* and ending one token before *sent_end*; | [
"Fixes",
"out",
"-",
"of",
"-",
"the",
"-",
"sentence",
"links",
"in",
"the",
"given",
"sentence",
".",
"The",
"sentence",
"is",
"a",
"sublist",
"of",
"*",
"alignments",
"*",
"starting",
"from",
"*",
"sent_start",
"*",
"and",
"ending",
"one",
"token",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L47-L71 |
estnltk/estnltk | estnltk/syntax/utils.py | normalise_alignments | def normalise_alignments( alignments, data_type=VISLCG3_DATA, **kwargs ):
''' Normalises dependency syntactic information in the given list of alignments.
*) Translates tree node indices from the syntax format (indices starting
from 1), to EstNLTK format (indices starting from 0);
*) Rem... | python | def normalise_alignments( alignments, data_type=VISLCG3_DATA, **kwargs ):
''' Normalises dependency syntactic information in the given list of alignments.
*) Translates tree node indices from the syntax format (indices starting
from 1), to EstNLTK format (indices starting from 0);
*) Rem... | [
"def",
"normalise_alignments",
"(",
"alignments",
",",
"data_type",
"=",
"VISLCG3_DATA",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"alignments",
",",
"list",
")",
":",
"raise",
"Exception",
"(",
"'(!) Unexpected type of input argument! Exp... | Normalises dependency syntactic information in the given list of alignments.
*) Translates tree node indices from the syntax format (indices starting
from 1), to EstNLTK format (indices starting from 0);
*) Removes redundant information (morphological analyses) and keeps only
syn... | [
"Normalises",
"dependency",
"syntactic",
"information",
"in",
"the",
"given",
"list",
"of",
"alignments",
".",
"*",
")",
"Translates",
"tree",
"node",
"indices",
"from",
"the",
"syntax",
"format",
"(",
"indices",
"starting",
"from",
"1",
")",
"to",
"EstNLTK",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L74-L288 |
estnltk/estnltk | estnltk/syntax/utils.py | read_text_from_cg3_file | def read_text_from_cg3_file( file_name, layer_name=LAYER_VISLCG3, **kwargs ):
''' Reads the output of VISLCG3 syntactic analysis from given file, and
returns as a Text object.
The Text object has been tokenized for paragraphs, sentences, words, and it
contains syntactic analyses a... | python | def read_text_from_cg3_file( file_name, layer_name=LAYER_VISLCG3, **kwargs ):
''' Reads the output of VISLCG3 syntactic analysis from given file, and
returns as a Text object.
The Text object has been tokenized for paragraphs, sentences, words, and it
contains syntactic analyses a... | [
"def",
"read_text_from_cg3_file",
"(",
"file_name",
",",
"layer_name",
"=",
"LAYER_VISLCG3",
",",
"*",
"*",
"kwargs",
")",
":",
"clean_up",
"=",
"False",
"for",
"argName",
",",
"argVal",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"argName",
"in",
... | Reads the output of VISLCG3 syntactic analysis from given file, and
returns as a Text object.
The Text object has been tokenized for paragraphs, sentences, words, and it
contains syntactic analyses aligned with word spans, in the layer *layer_name*
(by default: LAYER_VISLCG3)... | [
"Reads",
"the",
"output",
"of",
"VISLCG3",
"syntactic",
"analysis",
"from",
"given",
"file",
"and",
"returns",
"as",
"a",
"Text",
"object",
".",
"The",
"Text",
"object",
"has",
"been",
"tokenized",
"for",
"paragraphs",
"sentences",
"words",
"and",
"it",
"con... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L300-L403 |
estnltk/estnltk | estnltk/syntax/utils.py | read_text_from_conll_file | def read_text_from_conll_file( file_name, layer_name=LAYER_CONLL, **kwargs ):
''' Reads the CONLL format syntactic analysis from given file, and returns as
a Text object.
The Text object has been tokenized for paragraphs, sentences, words, and it
contains syntactic analyses aligne... | python | def read_text_from_conll_file( file_name, layer_name=LAYER_CONLL, **kwargs ):
''' Reads the CONLL format syntactic analysis from given file, and returns as
a Text object.
The Text object has been tokenized for paragraphs, sentences, words, and it
contains syntactic analyses aligne... | [
"def",
"read_text_from_conll_file",
"(",
"file_name",
",",
"layer_name",
"=",
"LAYER_CONLL",
",",
"*",
"*",
"kwargs",
")",
":",
"# 1) Load conll analysed text from file",
"conll_lines",
"=",
"[",
"]",
"in_f",
"=",
"codecs",
".",
"open",
"(",
"file_name",
",",
"m... | Reads the CONLL format syntactic analysis from given file, and returns as
a Text object.
The Text object has been tokenized for paragraphs, sentences, words, and it
contains syntactic analyses aligned with word spans, in the layer *layer_name*
(by default: LAYER_CONLL);
... | [
"Reads",
"the",
"CONLL",
"format",
"syntactic",
"analysis",
"from",
"given",
"file",
"and",
"returns",
"as",
"a",
"Text",
"object",
".",
"The",
"Text",
"object",
"has",
"been",
"tokenized",
"for",
"paragraphs",
"sentences",
"words",
"and",
"it",
"contains",
... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L406-L484 |
estnltk/estnltk | estnltk/syntax/utils.py | build_trees_from_sentence | def build_trees_from_sentence( sentence, syntactic_relations, layer=LAYER_VISLCG3, \
sentence_id=0, **kwargs ):
''' Given a sentence ( a list of EstNLTK's word tokens ), and a list of
dependency syntactic relations ( output of normalise_alignments() ),
builds trees ( ... | python | def build_trees_from_sentence( sentence, syntactic_relations, layer=LAYER_VISLCG3, \
sentence_id=0, **kwargs ):
''' Given a sentence ( a list of EstNLTK's word tokens ), and a list of
dependency syntactic relations ( output of normalise_alignments() ),
builds trees ( ... | [
"def",
"build_trees_from_sentence",
"(",
"sentence",
",",
"syntactic_relations",
",",
"layer",
"=",
"LAYER_VISLCG3",
",",
"sentence_id",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"trees_of_sentence",
"=",
"[",
"]",
"nodes",
"=",
"[",
"-",
"1",
"]",
"whi... | Given a sentence ( a list of EstNLTK's word tokens ), and a list of
dependency syntactic relations ( output of normalise_alignments() ),
builds trees ( estnltk.syntax.utils.Tree objects ) from the sentence,
and returns as a list of Trees (roots of trees).
Note that there is ... | [
"Given",
"a",
"sentence",
"(",
"a",
"list",
"of",
"EstNLTK",
"s",
"word",
"tokens",
")",
"and",
"a",
"list",
"of",
"dependency",
"syntactic",
"relations",
"(",
"output",
"of",
"normalise_alignments",
"()",
")",
"builds",
"trees",
"(",
"estnltk",
".",
"synt... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L874-L916 |
estnltk/estnltk | estnltk/syntax/utils.py | build_trees_from_text | def build_trees_from_text( text, layer, **kwargs ):
''' Given a text object and the name of the layer where dependency syntactic
relations are stored, builds trees ( estnltk.syntax.utils.Tree objects )
from all the sentences of the text and returns as a list of Trees.
Uses the meth... | python | def build_trees_from_text( text, layer, **kwargs ):
''' Given a text object and the name of the layer where dependency syntactic
relations are stored, builds trees ( estnltk.syntax.utils.Tree objects )
from all the sentences of the text and returns as a list of Trees.
Uses the meth... | [
"def",
"build_trees_from_text",
"(",
"text",
",",
"layer",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"estnltk",
".",
"text",
"import",
"Text",
"assert",
"isinstance",
"(",
"text",
",",
"Text",
")",
",",
"'(!) Unexpected text argument! Should be Estnltk\\'s Text o... | Given a text object and the name of the layer where dependency syntactic
relations are stored, builds trees ( estnltk.syntax.utils.Tree objects )
from all the sentences of the text and returns as a list of Trees.
Uses the method build_trees_from_sentence() for acquiring trees of each... | [
"Given",
"a",
"text",
"object",
"and",
"the",
"name",
"of",
"the",
"layer",
"where",
"dependency",
"syntactic",
"relations",
"are",
"stored",
"builds",
"trees",
"(",
"estnltk",
".",
"syntax",
".",
"utils",
".",
"Tree",
"objects",
")",
"from",
"all",
"the",... | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L920-L979 |
estnltk/estnltk | estnltk/syntax/utils.py | Tree.add_child_to_self | def add_child_to_self( self, tree ):
''' Adds given *tree* as a child of the current tree. '''
assert isinstance(tree, Tree), \
'(!) Unexpected type of argument for '+argName+'! Should be Tree.'
if (not self.children):
self.children = []
tree.parent = self
... | python | def add_child_to_self( self, tree ):
''' Adds given *tree* as a child of the current tree. '''
assert isinstance(tree, Tree), \
'(!) Unexpected type of argument for '+argName+'! Should be Tree.'
if (not self.children):
self.children = []
tree.parent = self
... | [
"def",
"add_child_to_self",
"(",
"self",
",",
"tree",
")",
":",
"assert",
"isinstance",
"(",
"tree",
",",
"Tree",
")",
",",
"'(!) Unexpected type of argument for '",
"+",
"argName",
"+",
"'! Should be Tree.'",
"if",
"(",
"not",
"self",
".",
"children",
")",
":... | Adds given *tree* as a child of the current tree. | [
"Adds",
"given",
"*",
"tree",
"*",
"as",
"a",
"child",
"of",
"the",
"current",
"tree",
"."
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L573-L580 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.