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/mw_verbs/basic_verbchain_detection.py
_suitableVerbExpansion
def _suitableVerbExpansion( foundSubcatChain ): ''' V6tab etteantud jadast osa, mis sobib: *) kui liikmeid on 3, keskmine on konjuktsioon ning esimene ja viimane klapivad, tagastab selle kolmiku; Nt. ei_0 saa_0 lihtsalt välja astuda_? ja_? uttu tõmmata_? ...
python
def _suitableVerbExpansion( foundSubcatChain ): ''' V6tab etteantud jadast osa, mis sobib: *) kui liikmeid on 3, keskmine on konjuktsioon ning esimene ja viimane klapivad, tagastab selle kolmiku; Nt. ei_0 saa_0 lihtsalt välja astuda_? ja_? uttu tõmmata_? ...
[ "def", "_suitableVerbExpansion", "(", "foundSubcatChain", ")", ":", "markings", "=", "[", "]", "tokens", "=", "[", "]", "nonConjTokens", "=", "[", "]", "for", "(", "marking", ",", "token", ")", "in", "foundSubcatChain", ":", "markings", ".", "append", "(",...
V6tab etteantud jadast osa, mis sobib: *) kui liikmeid on 3, keskmine on konjuktsioon ning esimene ja viimane klapivad, tagastab selle kolmiku; Nt. ei_0 saa_0 lihtsalt välja astuda_? ja_? uttu tõmmata_? => astuda ja tõmmata *) kui liikmeid on roh...
[ "V6tab", "etteantud", "jadast", "osa", "mis", "sobib", ":", "*", ")", "kui", "liikmeid", "on", "3", "keskmine", "on", "konjuktsioon", "ning", "esimene", "ja", "viimane", "klapivad", "tagastab", "selle", "kolmiku", ";", "Nt", ".", "ei_0", "saa_0", "lihtsalt",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1052-L1080
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_expandSaamaWithTud
def _expandSaamaWithTud( clauseTokens, clauseID, foundChains ): ''' Meetod, mis määrab spetsiifilised rektsiooniseosed: täiendab 'saama'-verbiga lõppevaid verbijadasid, lisades (v6imalusel) nende l6ppu 'tud'-infiniitverbi (nt. sai tehtud, sai käidud ujumas); Vastavalt leitu...
python
def _expandSaamaWithTud( clauseTokens, clauseID, foundChains ): ''' Meetod, mis määrab spetsiifilised rektsiooniseosed: täiendab 'saama'-verbiga lõppevaid verbijadasid, lisades (v6imalusel) nende l6ppu 'tud'-infiniitverbi (nt. sai tehtud, sai käidud ujumas); Vastavalt leitu...
[ "def", "_expandSaamaWithTud", "(", "clauseTokens", ",", "clauseID", ",", "foundChains", ")", ":", "verbTud", "=", "WordTemplate", "(", "{", "POSTAG", ":", "'V'", ",", "FORM", ":", "'^(tud|dud)$'", "}", ")", "verb", "=", "WordTemplate", "(", "{", "POSTAG", ...
Meetod, mis määrab spetsiifilised rektsiooniseosed: täiendab 'saama'-verbiga lõppevaid verbijadasid, lisades (v6imalusel) nende l6ppu 'tud'-infiniitverbi (nt. sai tehtud, sai käidud ujumas); Vastavalt leitud laiendustele t2iendab andmeid sisendlistis foundChains;
[ "Meetod", "mis", "määrab", "spetsiifilised", "rektsiooniseosed", ":", "täiendab", "saama", "-", "verbiga", "lõppevaid", "verbijadasid", "lisades", "(", "v6imalusel", ")", "nende", "l6ppu", "tud", "-", "infiniitverbi", "(", "nt", ".", "sai", "tehtud", "sai", "käi...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1082-L1130
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_expandVerbChainsBySubcat
def _expandVerbChainsBySubcat( clauseTokens, clauseID, foundChains, verbSubcat, \ skipQuestionable=False, \ breakOnPunctuation=True ): ''' Meetod, mis proovib laiendada (mitte-'olema') verbid...
python
def _expandVerbChainsBySubcat( clauseTokens, clauseID, foundChains, verbSubcat, \ skipQuestionable=False, \ breakOnPunctuation=True ): ''' Meetod, mis proovib laiendada (mitte-'olema') verbid...
[ "def", "_expandVerbChainsBySubcat", "(", "clauseTokens", ",", "clauseID", ",", "foundChains", ",", "verbSubcat", ",", "skipQuestionable", "=", "False", ",", "breakOnPunctuation", "=", "True", ")", ":", "global", "_breakerJaNingEgaVoi", ",", "_breakerKomaLopus", ",", ...
Meetod, mis proovib laiendada (mitte-'olema') verbidega l6ppevaid predikaadifraase, lisades nende lõppu rektsiooniseoste järgi uusi infiniitverbe, nt "kutsub" + "langetama" "püütakse" + "keelustada" "või" "takistada" "ei julgenud" + "arvata", "ei hakka" + "tülita...
[ "Meetod", "mis", "proovib", "laiendada", "(", "mitte", "-", "olema", ")", "verbidega", "l6ppevaid", "predikaadifraase", "lisades", "nende", "lõppu", "rektsiooniseoste", "järgi", "uusi", "infiniitverbe", "nt", "kutsub", "+", "langetama", "püütakse", "+", "keelustada"...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1134-L1282
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_extractEgaNegFromSent
def _extractEgaNegFromSent( sentTokens, clausesDict, foundChains ): ''' Meetod, mis tuvastab antud lausest 'ega'-predikaadiga seotud eituse(d): ega + sobiv verb. *) Juhtudel kui 'ega'-le j2rgneb juba tuvastatud, positiivse polaarsusega verbiahel (nt ahel mille alguses on käskivas kõneviisis v...
python
def _extractEgaNegFromSent( sentTokens, clausesDict, foundChains ): ''' Meetod, mis tuvastab antud lausest 'ega'-predikaadiga seotud eituse(d): ega + sobiv verb. *) Juhtudel kui 'ega'-le j2rgneb juba tuvastatud, positiivse polaarsusega verbiahel (nt ahel mille alguses on käskivas kõneviisis v...
[ "def", "_extractEgaNegFromSent", "(", "sentTokens", ",", "clausesDict", ",", "foundChains", ")", ":", "sonaEga", "=", "WordTemplate", "(", "{", "ROOT", ":", "'^ega$'", ",", "POSTAG", ":", "'[DJ]'", "}", ")", "verbEiJarel", "=", "WordTemplate", "(", "{", "POS...
Meetod, mis tuvastab antud lausest 'ega'-predikaadiga seotud eituse(d): ega + sobiv verb. *) Juhtudel kui 'ega'-le j2rgneb juba tuvastatud, positiivse polaarsusega verbiahel (nt ahel mille alguses on käskivas kõneviisis verb), liidetakse 'ega' olemasoleva ahela ette ning muudetakse ahe...
[ "Meetod", "mis", "tuvastab", "antud", "lausest", "ega", "-", "predikaadiga", "seotud", "eituse", "(", "d", ")", ":", "ega", "+", "sobiv", "verb", ".", "*", ")", "Juhtudel", "kui", "ega", "-", "le", "j2rgneb", "juba", "tuvastatud", "positiivse", "polaarsuse...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1340-L1557
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_determineVerbChainContextualAmbiguity
def _determineVerbChainContextualAmbiguity( clauseTokens, clauseID, foundChains ): ''' Meetod, mis püüab otsustada iga leitud verbiahela (foundChains liikme) puhul, kas osalauses leidub veel vabu verbe, millega verbiahelat oleks võimalik täiendada; Kui vabu verbe ei leidu, muudab verb...
python
def _determineVerbChainContextualAmbiguity( clauseTokens, clauseID, foundChains ): ''' Meetod, mis püüab otsustada iga leitud verbiahela (foundChains liikme) puhul, kas osalauses leidub veel vabu verbe, millega verbiahelat oleks võimalik täiendada; Kui vabu verbe ei leidu, muudab verb...
[ "def", "_determineVerbChainContextualAmbiguity", "(", "clauseTokens", ",", "clauseID", ",", "foundChains", ")", ":", "verb", "=", "WordTemplate", "(", "{", "POSTAG", ":", "'V'", "}", ")", "verbOlema", "=", "WordTemplate", "(", "{", "POSTAG", ":", "'V'", ",", ...
Meetod, mis püüab otsustada iga leitud verbiahela (foundChains liikme) puhul, kas osalauses leidub veel vabu verbe, millega verbiahelat oleks võimalik täiendada; Kui vabu verbe ei leidu, muudab verbiahela OTHER_VERBS väärtuse negatiivseks, vastasel juhul ei tee midagi. Sisend 'cl...
[ "Meetod", "mis", "püüab", "otsustada", "iga", "leitud", "verbiahela", "(", "foundChains", "liikme", ")", "puhul", "kas", "osalauses", "leidub", "veel", "vabu", "verbe", "millega", "verbiahelat", "oleks", "võimalik", "täiendada", ";", "Kui", "vabu", "verbe", "ei"...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1560-L1653
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_getMatchingAnalysisIDs
def _getMatchingAnalysisIDs( tokenJson, requiredWordTemplate, discardAnalyses = None ): ''' Tagastab listi tokenJson'i analyysidest, mis sobivad etteantud yksiku sõnamalli või sõnamallide listi mõne elemendiga (requiredWordTemplate võib olla üks WordTemplate või list WordTemplate elementide...
python
def _getMatchingAnalysisIDs( tokenJson, requiredWordTemplate, discardAnalyses = None ): ''' Tagastab listi tokenJson'i analyysidest, mis sobivad etteantud yksiku sõnamalli või sõnamallide listi mõne elemendiga (requiredWordTemplate võib olla üks WordTemplate või list WordTemplate elementide...
[ "def", "_getMatchingAnalysisIDs", "(", "tokenJson", ",", "requiredWordTemplate", ",", "discardAnalyses", "=", "None", ")", ":", "final_ids", "=", "set", "(", ")", "if", "isinstance", "(", "requiredWordTemplate", ",", "list", ")", ":", "for", "wt", "in", "requi...
Tagastab listi tokenJson'i analyysidest, mis sobivad etteantud yksiku sõnamalli või sõnamallide listi mõne elemendiga (requiredWordTemplate võib olla üks WordTemplate või list WordTemplate elementidega); Kui discardAnalyses on defineeritud (ning on WordTemplate), visatakse mi...
[ "Tagastab", "listi", "tokenJson", "i", "analyysidest", "mis", "sobivad", "etteantud", "yksiku", "sõnamalli", "või", "sõnamallide", "listi", "mõne", "elemendiga", "(", "requiredWordTemplate", "võib", "olla", "üks", "WordTemplate", "või", "list", "WordTemplate", "elemen...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1665-L1691
estnltk/estnltk
estnltk/grammar/common.py
is_valid_regex
def is_valid_regex(regex): """Function for checking a valid regex.""" if len(regex) == 0: return False try: re.compile(regex) return True except sre_constants.error: return False
python
def is_valid_regex(regex): """Function for checking a valid regex.""" if len(regex) == 0: return False try: re.compile(regex) return True except sre_constants.error: return False
[ "def", "is_valid_regex", "(", "regex", ")", ":", "if", "len", "(", "regex", ")", "==", "0", ":", "return", "False", "try", ":", "re", ".", "compile", "(", "regex", ")", "return", "True", "except", "sre_constants", ".", "error", ":", "return", "False" ]
Function for checking a valid regex.
[ "Function", "for", "checking", "a", "valid", "regex", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/grammar/common.py#L29-L37
estnltk/estnltk
estnltk/single_layer_operations/layer_positions.py
delete_left
def delete_left(elem1, elem2): """ xxxxx yyyyy --------- xxx yyyyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_right(elem1, elem2): elem1['end'] = elem2['start'] return elem1, elem2
python
def delete_left(elem1, elem2): """ xxxxx yyyyy --------- xxx yyyyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_right(elem1, elem2): elem1['end'] = elem2['start'] return elem1, elem2
[ "def", "delete_left", "(", "elem1", ",", "elem2", ")", ":", "# assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements'", "if", "overlapping_right", "(", "elem1", ",", "elem2", ")", ":", "elem1", "[", "'end'", "]", "=", "elem2"...
xxxxx yyyyy --------- xxx yyyyy
[ "xxxxx", "yyyyy", "---------", "xxx", "yyyyy" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/single_layer_operations/layer_positions.py#L105-L116
estnltk/estnltk
estnltk/single_layer_operations/layer_positions.py
delete_right
def delete_right(elem1, elem2): """ xxxxx yyyyy --------- xxxxx yyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_left(elem1, elem2): elem2['start'] = elem1['end'] return elem1, elem2
python
def delete_right(elem1, elem2): """ xxxxx yyyyy --------- xxxxx yyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_left(elem1, elem2): elem2['start'] = elem1['end'] return elem1, elem2
[ "def", "delete_right", "(", "elem1", ",", "elem2", ")", ":", "# assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements'", "if", "overlapping_left", "(", "elem1", ",", "elem2", ")", ":", "elem2", "[", "'start'", "]", "=", "elem...
xxxxx yyyyy --------- xxxxx yyy
[ "xxxxx", "yyyyy", "---------", "xxxxx", "yyy" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/single_layer_operations/layer_positions.py#L119-L130
estnltk/estnltk
estnltk/single_layer_operations/layer_positions.py
iterate_intersecting_pairs
def iterate_intersecting_pairs(layer): """ Given a layer of estntltk objects, yields pairwise intersecting elements. Breaks when the layer is changed or deleted after initializing the iterator. """ yielded = set() ri = layer[:] # Shallow copy the layer for i1, elem1 in enumerate(ri): ...
python
def iterate_intersecting_pairs(layer): """ Given a layer of estntltk objects, yields pairwise intersecting elements. Breaks when the layer is changed or deleted after initializing the iterator. """ yielded = set() ri = layer[:] # Shallow copy the layer for i1, elem1 in enumerate(ri): ...
[ "def", "iterate_intersecting_pairs", "(", "layer", ")", ":", "yielded", "=", "set", "(", ")", "ri", "=", "layer", "[", ":", "]", "# Shallow copy the layer", "for", "i1", ",", "elem1", "in", "enumerate", "(", "ri", ")", ":", "for", "i2", ",", "elem2", "...
Given a layer of estntltk objects, yields pairwise intersecting elements. Breaks when the layer is changed or deleted after initializing the iterator.
[ "Given", "a", "layer", "of", "estntltk", "objects", "yields", "pairwise", "intersecting", "elements", ".", "Breaks", "when", "the", "layer", "is", "changed", "or", "deleted", "after", "initializing", "the", "iterator", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/single_layer_operations/layer_positions.py#L153-L166
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.analyze_text
def analyze_text( self, text, **kwargs ): ''' Analyzes given Text for noun phrase chunks. As result of analysis, a layer NOUN_CHUNKS will be attached to the input Text object, containing a noun phrases detected from the Text; Note: for preprocessing the Text,...
python
def analyze_text( self, text, **kwargs ): ''' Analyzes given Text for noun phrase chunks. As result of analysis, a layer NOUN_CHUNKS will be attached to the input Text object, containing a noun phrases detected from the Text; Note: for preprocessing the Text,...
[ "def", "analyze_text", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "# 0) Parse given arguments\r", "#\r", "# Output specifics\r", "all_return_types", "=", "[", "\"text\"", ",", "\"labels\"", ",", "\"tokens\"", ",", "\"strings\"", "]", "return_type...
Analyzes given Text for noun phrase chunks. As result of analysis, a layer NOUN_CHUNKS will be attached to the input Text object, containing a noun phrases detected from the Text; Note: for preprocessing the Text, MaltParser is used by default. In order to obtain a de...
[ "Analyzes", "given", "Text", "for", "noun", "phrase", "chunks", ".", "As", "result", "of", "analysis", "a", "layer", "NOUN_CHUNKS", "will", "be", "attached", "to", "the", "input", "Text", "object", "containing", "a", "noun", "phrases", "detected", "from", "t...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L50-L184
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._getPOS
def _getPOS( self, token, onlyFirst = True ): ''' Returns POS of the current token. ''' if onlyFirst: return token[ANALYSIS][0][POSTAG] else: return [ a[POSTAG] for a in token[ANALYSIS] ]
python
def _getPOS( self, token, onlyFirst = True ): ''' Returns POS of the current token. ''' if onlyFirst: return token[ANALYSIS][0][POSTAG] else: return [ a[POSTAG] for a in token[ANALYSIS] ]
[ "def", "_getPOS", "(", "self", ",", "token", ",", "onlyFirst", "=", "True", ")", ":", "if", "onlyFirst", ":", "return", "token", "[", "ANALYSIS", "]", "[", "0", "]", "[", "POSTAG", "]", "else", ":", "return", "[", "a", "[", "POSTAG", "]", "for", ...
Returns POS of the current token.
[ "Returns", "POS", "of", "the", "current", "token", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L201-L207
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._getPhrase
def _getPhrase( self, i, sentence, NPlabels ): ''' Fetches the full length phrase from the position i based on the existing NP phrase annotations (from NPlabels); Returns list of sentence tokens in the phrase, and indices of the phrase; ''' ...
python
def _getPhrase( self, i, sentence, NPlabels ): ''' Fetches the full length phrase from the position i based on the existing NP phrase annotations (from NPlabels); Returns list of sentence tokens in the phrase, and indices of the phrase; ''' ...
[ "def", "_getPhrase", "(", "self", ",", "i", ",", "sentence", ",", "NPlabels", ")", ":", "phrase", "=", "[", "]", "indices", "=", "[", "]", "if", "0", "<=", "i", "and", "i", "<", "len", "(", "sentence", ")", "and", "NPlabels", "[", "i", "]", "==...
Fetches the full length phrase from the position i based on the existing NP phrase annotations (from NPlabels); Returns list of sentence tokens in the phrase, and indices of the phrase;
[ "Fetches", "the", "full", "length", "phrase", "from", "the", "position", "i", "based", "on", "the", "existing", "NP", "phrase", "annotations", "(", "from", "NPlabels", ")", ";", "Returns", "list", "of", "sentence", "tokens", "in", "the", "phrase", "and", "...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L209-L229
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._getCaseAgreement
def _getCaseAgreement(self, token1, token2): ''' Detects whether there is a morphological case agreement between two consecutive nominals (token1 and token2), and returns the common case, or None if no agreement exists; Applies a special set of rules for detecting agr...
python
def _getCaseAgreement(self, token1, token2): ''' Detects whether there is a morphological case agreement between two consecutive nominals (token1 and token2), and returns the common case, or None if no agreement exists; Applies a special set of rules for detecting agr...
[ "def", "_getCaseAgreement", "(", "self", ",", "token1", ",", "token2", ")", ":", "forms1", "=", "set", "(", "[", "a", "[", "FORM", "]", "for", "a", "in", "token1", "[", "ANALYSIS", "]", "]", ")", "forms2", "=", "set", "(", "[", "a", "[", "FORM", ...
Detects whether there is a morphological case agreement between two consecutive nominals (token1 and token2), and returns the common case, or None if no agreement exists; Applies a special set of rules for detecting agreement on the word in genitive followed by the...
[ "Detects", "whether", "there", "is", "a", "morphological", "case", "agreement", "between", "two", "consecutive", "nominals", "(", "token1", "and", "token2", ")", "and", "returns", "the", "common", "case", "or", "None", "if", "no", "agreement", "exists", ";", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L231-L263
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._find_phrases
def _find_phrases( self, sentence, syntax_layer, cutPhrases, cutMaxThreshold ): ''' Detects NP phrases by relying on local dependency relations: 1) Identifies potential heads of NP phrases; 2) Identifies consecutive words that can form an NP phrase: 2.1) pote...
python
def _find_phrases( self, sentence, syntax_layer, cutPhrases, cutMaxThreshold ): ''' Detects NP phrases by relying on local dependency relations: 1) Identifies potential heads of NP phrases; 2) Identifies consecutive words that can form an NP phrase: 2.1) pote...
[ "def", "_find_phrases", "(", "self", ",", "sentence", ",", "syntax_layer", ",", "cutPhrases", ",", "cutMaxThreshold", ")", ":", "NPattribPos", "=", "[", "'Y'", ",", "'S'", ",", "'A'", ",", "'C'", ",", "'G'", ",", "'H'", ",", "'N'", ",", "'O'", ",", "...
Detects NP phrases by relying on local dependency relations: 1) Identifies potential heads of NP phrases; 2) Identifies consecutive words that can form an NP phrase: 2.1) potential attribute + potential head; 2.2) quantity word or phrase + nominal; ...
[ "Detects", "NP", "phrases", "by", "relying", "on", "local", "dependency", "relations", ":", "1", ")", "Identifies", "potential", "heads", "of", "NP", "phrases", ";", "2", ")", "Identifies", "consecutive", "words", "that", "can", "form", "an", "NP", "phrase",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L270-L647
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._apply_post_fixes
def _apply_post_fixes( self, sentence, NPlabels, cutPhrases, cutMaxThreshold ): ''' Fraasituvastaja j2relparandused: *) Tekstis6renduste eemaldamine (s6rendatud tekst ei pruugi olla fraas, v6ib olla nt terve lause); *) Problemaatiliste kesks6nade eemaldamine fraasia...
python
def _apply_post_fixes( self, sentence, NPlabels, cutPhrases, cutMaxThreshold ): ''' Fraasituvastaja j2relparandused: *) Tekstis6renduste eemaldamine (s6rendatud tekst ei pruugi olla fraas, v6ib olla nt terve lause); *) Problemaatiliste kesks6nade eemaldamine fraasia...
[ "def", "_apply_post_fixes", "(", "self", ",", "sentence", ",", "NPlabels", ",", "cutPhrases", ",", "cutMaxThreshold", ")", ":", "for", "i", "in", "range", "(", "len", "(", "sentence", ")", ")", ":", "if", "NPlabels", "[", "i", "]", "==", "'B'", ":", ...
Fraasituvastaja j2relparandused: *) Tekstis6renduste eemaldamine (s6rendatud tekst ei pruugi olla fraas, v6ib olla nt terve lause); *) Problemaatiliste kesks6nade eemaldamine fraasialgusest; *) Ainult arvs6nadest koosnevate fraaside eemaldamine; *) ....
[ "Fraasituvastaja", "j2relparandused", ":", "*", ")", "Tekstis6renduste", "eemaldamine", "(", "s6rendatud", "tekst", "ei", "pruugi", "olla", "fraas", "v6ib", "olla", "nt", "terve", "lause", ")", ";", "*", ")", "Problemaatiliste", "kesks6nade", "eemaldamine", "fraas...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L653-L799
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.get_phrases
def get_phrases(self, text, np_labels): ''' Given a Text and a BIO labels (one label for each word in Text) , extracts phrases and returns as a list of phrases, where each phrase is a list of word tokens belonging to the phrase; Parameters ---...
python
def get_phrases(self, text, np_labels): ''' Given a Text and a BIO labels (one label for each word in Text) , extracts phrases and returns as a list of phrases, where each phrase is a list of word tokens belonging to the phrase; Parameters ---...
[ "def", "get_phrases", "(", "self", ",", "text", ",", "np_labels", ")", ":", "# 1) Take different inputs to common list of words format:\r", "input_words", "=", "[", "]", "if", "isinstance", "(", "text", ",", "Text", ")", ":", "# input is Text\r", "input_words", "=",...
Given a Text and a BIO labels (one label for each word in Text) , extracts phrases and returns as a list of phrases, where each phrase is a list of word tokens belonging to the phrase; Parameters ---------- text: estnltk.text.Text ...
[ "Given", "a", "Text", "and", "a", "BIO", "labels", "(", "one", "label", "for", "each", "word", "in", "Text", ")", "extracts", "phrases", "and", "returns", "as", "a", "list", "of", "phrases", "where", "each", "phrase", "is", "a", "list", "of", "word", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L807-L852
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.get_phrase_texts
def get_phrase_texts(self, text, np_labels): ''' Given a Text, and a list describing text annotations in the B-I-O format (*np_label*), extracts phrases and returns as a list of phrase texts; Assumes that the input is same as the input acceptable for ...
python
def get_phrase_texts(self, text, np_labels): ''' Given a Text, and a list describing text annotations in the B-I-O format (*np_label*), extracts phrases and returns as a list of phrase texts; Assumes that the input is same as the input acceptable for ...
[ "def", "get_phrase_texts", "(", "self", ",", "text", ",", "np_labels", ")", ":", "phrases", "=", "self", ".", "get_phrases", "(", "text", ",", "np_labels", ")", "texts", "=", "[", "]", "for", "phrase", "in", "phrases", ":", "phrase_str", "=", "' '", "....
Given a Text, and a list describing text annotations in the B-I-O format (*np_label*), extracts phrases and returns as a list of phrase texts; Assumes that the input is same as the input acceptable for the method NounPhraseChunker.get_phrases(); ...
[ "Given", "a", "Text", "and", "a", "list", "describing", "text", "annotations", "in", "the", "B", "-", "I", "-", "O", "format", "(", "*", "np_label", "*", ")", "extracts", "phrases", "and", "returns", "as", "a", "list", "of", "phrase", "texts", ";", "...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L855-L873
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.annotateText
def annotateText(self, text, layer, np_labels = None): ''' Applies this chunker on given Text, and adds results of the chunking as a new annotation layer to the text. If the NP annotations are provided (via the input list *np_labels*), uses the given NP annotations, oth...
python
def annotateText(self, text, layer, np_labels = None): ''' Applies this chunker on given Text, and adds results of the chunking as a new annotation layer to the text. If the NP annotations are provided (via the input list *np_labels*), uses the given NP annotations, oth...
[ "def", "annotateText", "(", "self", ",", "text", ",", "layer", ",", "np_labels", "=", "None", ")", ":", "input_words", "=", "None", "if", "isinstance", "(", "text", ",", "Text", ")", ":", "# input is Text\r", "input_words", "=", "text", ".", "words", "el...
Applies this chunker on given Text, and adds results of the chunking as a new annotation layer to the text. If the NP annotations are provided (via the input list *np_labels*), uses the given NP annotations, otherwise produces new NP_LABEL annotations via the metho...
[ "Applies", "this", "chunker", "on", "given", "Text", "and", "adds", "results", "of", "the", "chunking", "as", "a", "new", "annotation", "layer", "to", "the", "text", ".", "If", "the", "NP", "annotations", "are", "provided", "(", "via", "the", "input", "l...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L879-L931
estnltk/estnltk
estnltk/dividing.py
divide
def divide(elements, by, translate=False, sep=' '): """Divide lists `elements` and `by`. All elements are grouped into N bins, where N denotes the elements in `by` list. Parameters ---------- elements: list of dict Elements to be grouped into bins. by: list of dict Elements defi...
python
def divide(elements, by, translate=False, sep=' '): """Divide lists `elements` and `by`. All elements are grouped into N bins, where N denotes the elements in `by` list. Parameters ---------- elements: list of dict Elements to be grouped into bins. by: list of dict Elements defi...
[ "def", "divide", "(", "elements", ",", "by", ",", "translate", "=", "False", ",", "sep", "=", "' '", ")", ":", "outer_spans", "=", "[", "spans", "(", "elem", ")", "for", "elem", "in", "by", "]", "return", "divide_by_spans", "(", "elements", ",", "out...
Divide lists `elements` and `by`. All elements are grouped into N bins, where N denotes the elements in `by` list. Parameters ---------- elements: list of dict Elements to be grouped into bins. by: list of dict Elements defining the bins. translate: bool (default: False) ...
[ "Divide", "lists", "elements", "and", "by", ".", "All", "elements", "are", "grouped", "into", "N", "bins", "where", "N", "denotes", "the", "elements", "in", "by", "list", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/dividing.py#L338-L355
estnltk/estnltk
estnltk/wiki/cleaner.py
dropNested
def dropNested(text, openDelim, closeDelim): """ A matching function for nested expressions, e.g. namespaces and tables. """ openRE = re.compile(openDelim) closeRE = re.compile(closeDelim) # partition text in separate blocks { } { } spans = [] # pairs (s, e) for each partition...
python
def dropNested(text, openDelim, closeDelim): """ A matching function for nested expressions, e.g. namespaces and tables. """ openRE = re.compile(openDelim) closeRE = re.compile(closeDelim) # partition text in separate blocks { } { } spans = [] # pairs (s, e) for each partition...
[ "def", "dropNested", "(", "text", ",", "openDelim", ",", "closeDelim", ")", ":", "openRE", "=", "re", ".", "compile", "(", "openDelim", ")", "closeRE", "=", "re", ".", "compile", "(", "closeDelim", ")", "# partition text in separate blocks { } { }", "spans", "...
A matching function for nested expressions, e.g. namespaces and tables.
[ "A", "matching", "function", "for", "nested", "expressions", "e", ".", "g", ".", "namespaces", "and", "tables", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/cleaner.py#L72-L122
estnltk/estnltk
estnltk/wiki/cleaner.py
dropSpans
def dropSpans(spans, text): """ Drop from text the blocks identified in :param spans:, possibly nested. """ spans.sort() res = '' offset = 0 for s, e in spans: if offset <= s: # handle nesting if offset < s: res += text[offset:s] offse...
python
def dropSpans(spans, text): """ Drop from text the blocks identified in :param spans:, possibly nested. """ spans.sort() res = '' offset = 0 for s, e in spans: if offset <= s: # handle nesting if offset < s: res += text[offset:s] offse...
[ "def", "dropSpans", "(", "spans", ",", "text", ")", ":", "spans", ".", "sort", "(", ")", "res", "=", "''", "offset", "=", "0", "for", "s", ",", "e", "in", "spans", ":", "if", "offset", "<=", "s", ":", "# handle nesting", "if", "offset", "<", "s",...
Drop from text the blocks identified in :param spans:, possibly nested.
[ "Drop", "from", "text", "the", "blocks", "identified", "in", ":", "param", "spans", ":", "possibly", "nested", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/cleaner.py#L124-L137
estnltk/estnltk
estnltk/wiki/cleaner.py
clean
def clean(text): """ Transforms wiki markup. @see https://www.mediawiki.org/wiki/Help:Formatting """ text = bold_italic.sub(r'\1', text) text = bold.sub(r'\1', text) text = italic_quote.sub(r'"\1"', text) text = italic.sub(r'"\1"', text) text = quote_quote.sub(r'"\1"', text) #...
python
def clean(text): """ Transforms wiki markup. @see https://www.mediawiki.org/wiki/Help:Formatting """ text = bold_italic.sub(r'\1', text) text = bold.sub(r'\1', text) text = italic_quote.sub(r'"\1"', text) text = italic.sub(r'"\1"', text) text = quote_quote.sub(r'"\1"', text) #...
[ "def", "clean", "(", "text", ")", ":", "text", "=", "bold_italic", ".", "sub", "(", "r'\\1'", ",", "text", ")", "text", "=", "bold", ".", "sub", "(", "r'\\1'", ",", "text", ")", "text", "=", "italic_quote", ".", "sub", "(", "r'\"\\1\"'", ",", "text...
Transforms wiki markup. @see https://www.mediawiki.org/wiki/Help:Formatting
[ "Transforms", "wiki", "markup", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/cleaner.py#L139-L203
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.disambiguate
def disambiguate(self, docs, **kwargs): """ Performs morphological analysis along with different morphological disambiguation steps (pre-disambiguation, vabamorf's disambiguation and post-disambiguation) in the input document collection `docs`. Note ---- ...
python
def disambiguate(self, docs, **kwargs): """ Performs morphological analysis along with different morphological disambiguation steps (pre-disambiguation, vabamorf's disambiguation and post-disambiguation) in the input document collection `docs`. Note ---- ...
[ "def", "disambiguate", "(", "self", ",", "docs", ",", "*", "*", "kwargs", ")", ":", "# For testing purposes, morph analysis and morph disambiguation can both", "# be switched off:", "use_vabamorf", "=", "kwargs", ".", "get", "(", "'vabamorf'", ",", "True", ")", "use_v...
Performs morphological analysis along with different morphological disambiguation steps (pre-disambiguation, vabamorf's disambiguation and post-disambiguation) in the input document collection `docs`. Note ---- It is assumed that the documents in the input ...
[ "Performs", "morphological", "analysis", "along", "with", "different", "morphological", "disambiguation", "steps", "(", "pre", "-", "disambiguation", "vabamorf", "s", "disambiguation", "and", "post", "-", "disambiguation", ")", "in", "the", "input", "document", "col...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L26-L121
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__isListOfTexts
def __isListOfTexts(self, docs): """ Checks whether the input is a list of strings or Text-s; """ return isinstance(docs, list) and \ all(isinstance(d, (basestring, Text)) for d in docs)
python
def __isListOfTexts(self, docs): """ Checks whether the input is a list of strings or Text-s; """ return isinstance(docs, list) and \ all(isinstance(d, (basestring, Text)) for d in docs)
[ "def", "__isListOfTexts", "(", "self", ",", "docs", ")", ":", "return", "isinstance", "(", "docs", ",", "list", ")", "and", "all", "(", "isinstance", "(", "d", ",", "(", "basestring", ",", "Text", ")", ")", "for", "d", "in", "docs", ")" ]
Checks whether the input is a list of strings or Text-s;
[ "Checks", "whether", "the", "input", "is", "a", "list", "of", "strings", "or", "Text", "-", "s", ";" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L135-L139
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__isListOfLists
def __isListOfLists(self, docs): """ Checks whether the input is a list of list of strings/Text-s; """ return isinstance(docs, list) and \ all(self.__isListOfTexts(ds) for ds in docs)
python
def __isListOfLists(self, docs): """ Checks whether the input is a list of list of strings/Text-s; """ return isinstance(docs, list) and \ all(self.__isListOfTexts(ds) for ds in docs)
[ "def", "__isListOfLists", "(", "self", ",", "docs", ")", ":", "return", "isinstance", "(", "docs", ",", "list", ")", "and", "all", "(", "self", ".", "__isListOfTexts", "(", "ds", ")", "for", "ds", "in", "docs", ")" ]
Checks whether the input is a list of list of strings/Text-s;
[ "Checks", "whether", "the", "input", "is", "a", "list", "of", "list", "of", "strings", "/", "Text", "-", "s", ";" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L142-L146
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__create_proper_names_lexicon
def __create_proper_names_lexicon(self, docs): """ Moodustab dokumendikollektsiooni põhjal pärisnimede sagedussõnastiku (mis kirjeldab, mitu korda iga pärisnimelemma esines); """ lemmaFreq = dict() for doc in docs: for word in doc[WORDS]: # 1) Leia...
python
def __create_proper_names_lexicon(self, docs): """ Moodustab dokumendikollektsiooni põhjal pärisnimede sagedussõnastiku (mis kirjeldab, mitu korda iga pärisnimelemma esines); """ lemmaFreq = dict() for doc in docs: for word in doc[WORDS]: # 1) Leia...
[ "def", "__create_proper_names_lexicon", "(", "self", ",", "docs", ")", ":", "lemmaFreq", "=", "dict", "(", ")", "for", "doc", "in", "docs", ":", "for", "word", "in", "doc", "[", "WORDS", "]", ":", "# 1) Leiame k6ik s6naga seotud unikaalsed pärisnimelemmad ", "# ...
Moodustab dokumendikollektsiooni põhjal pärisnimede sagedussõnastiku (mis kirjeldab, mitu korda iga pärisnimelemma esines);
[ "Moodustab", "dokumendikollektsiooni", "põhjal", "pärisnimede", "sagedussõnastiku", "(", "mis", "kirjeldab", "mitu", "korda", "iga", "pärisnimelemma", "esines", ")", ";" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L159-L178
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__disambiguate_proper_names_1
def __disambiguate_proper_names_1(self, docs, lexicon): """ Teeme esmase yleliigsete analyyside kustutamise: kui sõnal on mitu erineva sagedusega pärisnimeanalüüsi, siis jätame alles vaid suurima sagedusega analyysi(d) ... """ for doc in docs: for word in doc...
python
def __disambiguate_proper_names_1(self, docs, lexicon): """ Teeme esmase yleliigsete analyyside kustutamise: kui sõnal on mitu erineva sagedusega pärisnimeanalüüsi, siis jätame alles vaid suurima sagedusega analyysi(d) ... """ for doc in docs: for word in doc...
[ "def", "__disambiguate_proper_names_1", "(", "self", ",", "docs", ",", "lexicon", ")", ":", "for", "doc", "in", "docs", ":", "for", "word", "in", "doc", "[", "WORDS", "]", ":", "# Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys:", "if", "len", "(", ...
Teeme esmase yleliigsete analyyside kustutamise: kui sõnal on mitu erineva sagedusega pärisnimeanalüüsi, siis jätame alles vaid suurima sagedusega analyysi(d) ...
[ "Teeme", "esmase", "yleliigsete", "analyyside", "kustutamise", ":", "kui", "sõnal", "on", "mitu", "erineva", "sagedusega", "pärisnimeanalüüsi", "siis", "jätame", "alles", "vaid", "suurima", "sagedusega", "analyysi", "(", "d", ")", "..." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L181-L210
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__find_certain_proper_names
def __find_certain_proper_names(self, docs): """ Moodustame kindlate pärisnimede loendi: vaatame sõnu, millel ongi ainult pärisnimeanalüüsid ning võtame sealt loendisse unikaalsed pärisnimed; """ certainNames = set() for doc in docs: for word in doc[W...
python
def __find_certain_proper_names(self, docs): """ Moodustame kindlate pärisnimede loendi: vaatame sõnu, millel ongi ainult pärisnimeanalüüsid ning võtame sealt loendisse unikaalsed pärisnimed; """ certainNames = set() for doc in docs: for word in doc[W...
[ "def", "__find_certain_proper_names", "(", "self", ",", "docs", ")", ":", "certainNames", "=", "set", "(", ")", "for", "doc", "in", "docs", ":", "for", "word", "in", "doc", "[", "WORDS", "]", ":", "# Vaatame vaid pärisnimeanalüüsidest koosnevaid sõnu", "if", "...
Moodustame kindlate pärisnimede loendi: vaatame sõnu, millel ongi ainult pärisnimeanalüüsid ning võtame sealt loendisse unikaalsed pärisnimed;
[ "Moodustame", "kindlate", "pärisnimede", "loendi", ":", "vaatame", "sõnu", "millel", "ongi", "ainult", "pärisnimeanalüüsid", "ning", "võtame", "sealt", "loendisse", "unikaalsed", "pärisnimed", ";" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L213-L226
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__find_sentence_initial_proper_names
def __find_sentence_initial_proper_names(self, docs): """ Moodustame lausealguliste pärisnimede loendi: vaatame sõnu, millel nii pärisnimeanalüüs(id) kui ka mittepärisnimeanalüüs(id) ning mis esinevad lause või nummerdatud loendi alguses - jäädvustame selliste sõnade unikaa...
python
def __find_sentence_initial_proper_names(self, docs): """ Moodustame lausealguliste pärisnimede loendi: vaatame sõnu, millel nii pärisnimeanalüüs(id) kui ka mittepärisnimeanalüüs(id) ning mis esinevad lause või nummerdatud loendi alguses - jäädvustame selliste sõnade unikaa...
[ "def", "__find_sentence_initial_proper_names", "(", "self", ",", "docs", ")", ":", "sentInitialNames", "=", "set", "(", ")", "for", "doc", "in", "docs", ":", "for", "sentence", "in", "doc", ".", "divide", "(", "layer", "=", "WORDS", ",", "by", "=", "SENT...
Moodustame lausealguliste pärisnimede loendi: vaatame sõnu, millel nii pärisnimeanalüüs(id) kui ka mittepärisnimeanalüüs(id) ning mis esinevad lause või nummerdatud loendi alguses - jäädvustame selliste sõnade unikaalsed lemmad;
[ "Moodustame", "lausealguliste", "pärisnimede", "loendi", ":", "vaatame", "sõnu", "millel", "nii", "pärisnimeanalüüs", "(", "id", ")", "kui", "ka", "mittepärisnimeanalüüs", "(", "id", ")", "ning", "mis", "esinevad", "lause", "või", "nummerdatud", "loendi", "alguses...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L229-L266
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__remove_redundant_proper_names
def __remove_redundant_proper_names(self, docs, lemma_set): """ Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade loendi (hulga) põhjal; """ for doc in docs: for word in doc[WORDS]: # Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys...
python
def __remove_redundant_proper_names(self, docs, lemma_set): """ Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade loendi (hulga) põhjal; """ for doc in docs: for word in doc[WORDS]: # Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys...
[ "def", "__remove_redundant_proper_names", "(", "self", ",", "docs", ",", "lemma_set", ")", ":", "for", "doc", "in", "docs", ":", "for", "word", "in", "doc", "[", "WORDS", "]", ":", "# Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys:", "if", "len", "("...
Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade loendi (hulga) põhjal;
[ "Eemaldame", "yleliigsed", "pärisnimeanalüüsid", "etteantud", "sõnalemmade", "loendi", "(", "hulga", ")", "põhjal", ";" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L306-L322
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__disambiguate_proper_names_2
def __disambiguate_proper_names_2(self, docs, lexicon): """ Kustutame üleliigsed mitte-pärisnimeanalüüsid: -- kui lause keskel on pärisnimeanalüüsiga sõna, jätamegi alles vaid pärisnimeanalyys(id); -- kui lause alguses on pärisnimeanalüüsiga s6na, ning pärisnimelemma ...
python
def __disambiguate_proper_names_2(self, docs, lexicon): """ Kustutame üleliigsed mitte-pärisnimeanalüüsid: -- kui lause keskel on pärisnimeanalüüsiga sõna, jätamegi alles vaid pärisnimeanalyys(id); -- kui lause alguses on pärisnimeanalüüsiga s6na, ning pärisnimelemma ...
[ "def", "__disambiguate_proper_names_2", "(", "self", ",", "docs", ",", "lexicon", ")", ":", "for", "doc", "in", "docs", ":", "for", "sentence", "in", "doc", ".", "divide", "(", "layer", "=", "WORDS", ",", "by", "=", "SENTENCES", ")", ":", "sentencePos", ...
Kustutame üleliigsed mitte-pärisnimeanalüüsid: -- kui lause keskel on pärisnimeanalüüsiga sõna, jätamegi alles vaid pärisnimeanalyys(id); -- kui lause alguses on pärisnimeanalüüsiga s6na, ning pärisnimelemma esineb korpuses suurema sagedusega kui 1, jätamegi alles ...
[ "Kustutame", "üleliigsed", "mitte", "-", "pärisnimeanalüüsid", ":", "--", "kui", "lause", "keskel", "on", "pärisnimeanalüüsiga", "sõna", "jätamegi", "alles", "vaid", "pärisnimeanalyys", "(", "id", ")", ";", "--", "kui", "lause", "alguses", "on", "pärisnimeanalüüsi...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L325-L378
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.pre_disambiguate
def pre_disambiguate(self, docs): """ Teostab pärisnimede eelühestamine. Üldiseks eesmärgiks on vähendada mitmesust suurtähega algavate sonade morf analüüsil, nt eemaldada pärisnime analüüs, kui suurtäht tähistab tõenäoliselt lausealgust. """ # 1) Leiame pärisnimelemm...
python
def pre_disambiguate(self, docs): """ Teostab pärisnimede eelühestamine. Üldiseks eesmärgiks on vähendada mitmesust suurtähega algavate sonade morf analüüsil, nt eemaldada pärisnime analüüs, kui suurtäht tähistab tõenäoliselt lausealgust. """ # 1) Leiame pärisnimelemm...
[ "def", "pre_disambiguate", "(", "self", ",", "docs", ")", ":", "# 1) Leiame pärisnimelemmade sagedusleksikoni", "lexicon", "=", "self", ".", "__create_proper_names_lexicon", "(", "docs", ")", "# 2) Teeme esialgse kustutamise: kui sõnal on mitu erineva korpuse-", "# sagedusega ...
Teostab pärisnimede eelühestamine. Üldiseks eesmärgiks on vähendada mitmesust suurtähega algavate sonade morf analüüsil, nt eemaldada pärisnime analüüs, kui suurtäht tähistab tõenäoliselt lausealgust.
[ "Teostab", "pärisnimede", "eelühestamine", ".", "Üldiseks", "eesmärgiks", "on", "vähendada", "mitmesust", "suurtähega", "algavate", "sonade", "morf", "analüüsil", "nt", "eemaldada", "pärisnime", "analüüs", "kui", "suurtäht", "tähistab", "tõenäoliselt", "lausealgust", "....
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L381-L421
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__analyses_match
def __analyses_match(self, analysisA, analysisB): """ Leiame, kas tegu on duplikaatidega ehk täpselt üht ja sama morfoloogilist infot sisaldavate analüüsidega. """ return POSTAG in analysisA and POSTAG in analysisB and \ analysisA[POSTAG]==analysisB[POSTAG] and \ ...
python
def __analyses_match(self, analysisA, analysisB): """ Leiame, kas tegu on duplikaatidega ehk täpselt üht ja sama morfoloogilist infot sisaldavate analüüsidega. """ return POSTAG in analysisA and POSTAG in analysisB and \ analysisA[POSTAG]==analysisB[POSTAG] and \ ...
[ "def", "__analyses_match", "(", "self", ",", "analysisA", ",", "analysisB", ")", ":", "return", "POSTAG", "in", "analysisA", "and", "POSTAG", "in", "analysisB", "and", "analysisA", "[", "POSTAG", "]", "==", "analysisB", "[", "POSTAG", "]", "and", "ROOT", "...
Leiame, kas tegu on duplikaatidega ehk täpselt üht ja sama morfoloogilist infot sisaldavate analüüsidega.
[ "Leiame", "kas", "tegu", "on", "duplikaatidega", "ehk", "täpselt", "üht", "ja", "sama", "morfoloogilist", "infot", "sisaldavate", "analüüsidega", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L434-L446
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__remove_duplicate_and_problematic_analyses
def __remove_duplicate_and_problematic_analyses(self, docs): """ 1) Eemaldab sisendkorpuse kõigi sõnade morf analüüsidest duplikaadid ehk siis korduvad analüüsid; Nt sõna 'palk' saab kaks analyysi: 'palk' (mis käändub 'palk\palgi') ja 'palk' (mis käändub 'palk\palga'), ...
python
def __remove_duplicate_and_problematic_analyses(self, docs): """ 1) Eemaldab sisendkorpuse kõigi sõnade morf analüüsidest duplikaadid ehk siis korduvad analüüsid; Nt sõna 'palk' saab kaks analyysi: 'palk' (mis käändub 'palk\palgi') ja 'palk' (mis käändub 'palk\palga'), ...
[ "def", "__remove_duplicate_and_problematic_analyses", "(", "self", ",", "docs", ")", ":", "for", "doc", "in", "docs", ":", "for", "word", "in", "doc", "[", "WORDS", "]", ":", "# 1) Leiame k6ik analyysi-duplikaadid (kui neid on)", "toDelete", "=", "[", "]", "for", ...
1) Eemaldab sisendkorpuse kõigi sõnade morf analüüsidest duplikaadid ehk siis korduvad analüüsid; Nt sõna 'palk' saab kaks analyysi: 'palk' (mis käändub 'palk\palgi') ja 'palk' (mis käändub 'palk\palga'), aga pärast duplikaatide eemaldamist jääb alles vaid üks; ...
[ "1", ")", "Eemaldab", "sisendkorpuse", "kõigi", "sõnade", "morf", "analüüsidest", "duplikaadid", "ehk", "siis", "korduvad", "analüüsid", ";", "Nt", "sõna", "palk", "saab", "kaks", "analyysi", ":", "palk", "(", "mis", "käändub", "palk", "\\", "palgi", ")", "j...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L449-L488
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__find_hidden_analyses
def __find_hidden_analyses(self, docs): """ Jätab meelde, millised analüüsid on nn peidetud ehk siis mida ei tule arvestada lemmade järelühestamisel: *) kesksõnade nud, dud, tud mitmesused; *) muutumatute sõnade sõnaliigi mitmesus; *) oleviku 'olema' mitmesus...
python
def __find_hidden_analyses(self, docs): """ Jätab meelde, millised analüüsid on nn peidetud ehk siis mida ei tule arvestada lemmade järelühestamisel: *) kesksõnade nud, dud, tud mitmesused; *) muutumatute sõnade sõnaliigi mitmesus; *) oleviku 'olema' mitmesus...
[ "def", "__find_hidden_analyses", "(", "self", ",", "docs", ")", ":", "hidden", "=", "dict", "(", ")", "nudTudLopud", "=", "re", ".", "compile", "(", "'^.*[ntd]ud$'", ")", "for", "d", "in", "range", "(", "len", "(", "docs", ")", ")", ":", "for", "w", ...
Jätab meelde, millised analüüsid on nn peidetud ehk siis mida ei tule arvestada lemmade järelühestamisel: *) kesksõnade nud, dud, tud mitmesused; *) muutumatute sõnade sõnaliigi mitmesus; *) oleviku 'olema' mitmesus ('nad on' vs 'ta on'); *) asesõnade ai...
[ "Jätab", "meelde", "millised", "analüüsid", "on", "nn", "peidetud", "ehk", "siis", "mida", "ei", "tule", "arvestada", "lemmade", "järelühestamisel", ":", "*", ")", "kesksõnade", "nud", "dud", "tud", "mitmesused", ";", "*", ")", "muutumatute", "sõnade", "sõnali...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L491-L545
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__supplement_lemma_frequency_lexicon
def __supplement_lemma_frequency_lexicon(self, docs, hiddenWords, lexicon, amb_lexicon): """ Täiendab etteantud sagedusleksikone antud korpuse (docs) põhjal: *) yldist sagedusleksikoni, kus on k6ik lemmad, v.a. lemmad, mis kuuluvad nn peidetud sõnade hulka (hiddenWords); ...
python
def __supplement_lemma_frequency_lexicon(self, docs, hiddenWords, lexicon, amb_lexicon): """ Täiendab etteantud sagedusleksikone antud korpuse (docs) põhjal: *) yldist sagedusleksikoni, kus on k6ik lemmad, v.a. lemmad, mis kuuluvad nn peidetud sõnade hulka (hiddenWords); ...
[ "def", "__supplement_lemma_frequency_lexicon", "(", "self", ",", "docs", ",", "hiddenWords", ",", "lexicon", ",", "amb_lexicon", ")", ":", "for", "d", "in", "range", "(", "len", "(", "docs", ")", ")", ":", "for", "w", "in", "range", "(", "len", "(", "d...
Täiendab etteantud sagedusleksikone antud korpuse (docs) põhjal: *) yldist sagedusleksikoni, kus on k6ik lemmad, v.a. lemmad, mis kuuluvad nn peidetud sõnade hulka (hiddenWords); *) mitmeste sagedusleksikoni, kus on vaid mitmeste analyysidega s6nades esinenud lemm...
[ "Täiendab", "etteantud", "sagedusleksikone", "antud", "korpuse", "(", "docs", ")", "põhjal", ":", "*", ")", "yldist", "sagedusleksikoni", "kus", "on", "k6ik", "lemmad", "v", ".", "a", ".", "lemmad", "mis", "kuuluvad", "nn", "peidetud", "sõnade", "hulka", "("...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L548-L577
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__disambiguate_with_lexicon
def __disambiguate_with_lexicon(self, docs, lexicon, hiddenWords): """ Teostab lemmade leksikoni järgi mitmeste morf analüüside ühestamise - eemaldab üleliigsed analüüsid; Toetub ideele "üks tähendus teksti kohta": kui mitmeseks jäänud lemma esineb tekstis/korpuses ka mujal...
python
def __disambiguate_with_lexicon(self, docs, lexicon, hiddenWords): """ Teostab lemmade leksikoni järgi mitmeste morf analüüside ühestamise - eemaldab üleliigsed analüüsid; Toetub ideele "üks tähendus teksti kohta": kui mitmeseks jäänud lemma esineb tekstis/korpuses ka mujal...
[ "def", "__disambiguate_with_lexicon", "(", "self", ",", "docs", ",", "lexicon", ",", "hiddenWords", ")", ":", "for", "d", "in", "range", "(", "len", "(", "docs", ")", ")", ":", "for", "w", "in", "range", "(", "len", "(", "docs", "[", "d", "]", "[",...
Teostab lemmade leksikoni järgi mitmeste morf analüüside ühestamise - eemaldab üleliigsed analüüsid; Toetub ideele "üks tähendus teksti kohta": kui mitmeseks jäänud lemma esineb tekstis/korpuses ka mujal ning lõppkokkuvõttes esineb sagedamini kui alternatiivsed analüüs...
[ "Teostab", "lemmade", "leksikoni", "järgi", "mitmeste", "morf", "analüüside", "ühestamise", "-", "eemaldab", "üleliigsed", "analüüsid", ";", "Toetub", "ideele", "üks", "tähendus", "teksti", "kohta", ":", "kui", "mitmeseks", "jäänud", "lemma", "esineb", "tekstis", ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L580-L612
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.post_disambiguate
def post_disambiguate(self, collections): """ Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1 dokumend...
python
def post_disambiguate(self, collections): """ Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1 dokumend...
[ "def", "post_disambiguate", "(", "self", ",", "collections", ")", ":", "#", "# I etapp: ühestame ühe dokumendikollektsiooni piires ", "# (nt üle kõigi samal päeval ilmunud ajaleheartiklite);", "#", "for", "docs", "in", "collections", ":", "# 1) Eemaldame analüüside seast...
Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1 dokumendikollektsioon); Sisuliselt kasutatakse ühe...
[ "Teostab", "mitmeste", "analüüside", "lemma", "-", "põhise", "järelühestamise", ".", "Järelühestamine", "toimub", "kahes", "etapis", ":", "kõigepealt", "ühe", "dokumendikollektsiooni", "piires", "ning", "seejärel", "üle", "kõigi", "dokumendikollektsioonide", "(", "kui",...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L615-L667
estnltk/estnltk
estnltk/wordnet_tagger.py
WordnetTagger.tag_text
def tag_text(self, text, **kwargs): """Annotates `analysis` entries in `corpus` with a list of lemmas` synsets and queried WordNet data in a 'wordnet' entry. Note ---- Annotates every `analysis` entry with a `wordnet`:{`synsets`:[..]}. Parameters ---------- te...
python
def tag_text(self, text, **kwargs): """Annotates `analysis` entries in `corpus` with a list of lemmas` synsets and queried WordNet data in a 'wordnet' entry. Note ---- Annotates every `analysis` entry with a `wordnet`:{`synsets`:[..]}. Parameters ---------- te...
[ "def", "tag_text", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "for", "analysis_match", "in", "text", ".", "analysis", ":", "for", "candidate", "in", "analysis_match", ":", "if", "candidate", "[", "'partofspeech'", "]", "in", "PYVABAMORF_T...
Annotates `analysis` entries in `corpus` with a list of lemmas` synsets and queried WordNet data in a 'wordnet' entry. Note ---- Annotates every `analysis` entry with a `wordnet`:{`synsets`:[..]}. Parameters ---------- text: estnltk.text.Text Representation ...
[ "Annotates", "analysis", "entries", "in", "corpus", "with", "a", "list", "of", "lemmas", "synsets", "and", "queried", "WordNet", "data", "in", "a", "wordnet", "entry", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet_tagger.py#L22-L67
estnltk/estnltk
estnltk/tools/cnllconverter.py
get_texts_and_labels
def get_texts_and_labels(sentence_chunk): """Given a sentence chunk, extract original texts and labels.""" words = sentence_chunk.split('\n') texts = [] labels = [] for word in words: word = word.strip() if len(word) > 0: toks = word.split('\t') texts.append(t...
python
def get_texts_and_labels(sentence_chunk): """Given a sentence chunk, extract original texts and labels.""" words = sentence_chunk.split('\n') texts = [] labels = [] for word in words: word = word.strip() if len(word) > 0: toks = word.split('\t') texts.append(t...
[ "def", "get_texts_and_labels", "(", "sentence_chunk", ")", ":", "words", "=", "sentence_chunk", ".", "split", "(", "'\\n'", ")", "texts", "=", "[", "]", "labels", "=", "[", "]", "for", "word", "in", "words", ":", "word", "=", "word", ".", "strip", "(",...
Given a sentence chunk, extract original texts and labels.
[ "Given", "a", "sentence", "chunk", "extract", "original", "texts", "and", "labels", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/tools/cnllconverter.py#L12-L23
estnltk/estnltk
estnltk/tools/cnllconverter.py
parse_doc
def parse_doc(doc): """Exract list of sentences containing (text, label) pairs.""" word_spans = [] sentence_spans = [] sentence_chunks = doc.split('\n\n') sentences = [] for chunk in sentence_chunks: sent_texts, sent_labels = get_texts_and_labels(chunk.strip()) sentences.append(l...
python
def parse_doc(doc): """Exract list of sentences containing (text, label) pairs.""" word_spans = [] sentence_spans = [] sentence_chunks = doc.split('\n\n') sentences = [] for chunk in sentence_chunks: sent_texts, sent_labels = get_texts_and_labels(chunk.strip()) sentences.append(l...
[ "def", "parse_doc", "(", "doc", ")", ":", "word_spans", "=", "[", "]", "sentence_spans", "=", "[", "]", "sentence_chunks", "=", "doc", ".", "split", "(", "'\\n\\n'", ")", "sentences", "=", "[", "]", "for", "chunk", "in", "sentence_chunks", ":", "sent_tex...
Exract list of sentences containing (text, label) pairs.
[ "Exract", "list", "of", "sentences", "containing", "(", "text", "label", ")", "pairs", "." ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/tools/cnllconverter.py#L25-L34
estnltk/estnltk
estnltk/tools/cnllconverter.py
convert
def convert(document): """Convert a document to a Text object""" raw_tokens = [] curpos = 0 text_spans = [] all_labels = [] sent_spans = [] word_texts = [] for sentence in document: startpos = curpos for idx, (text, label) in enumerate(sentence): raw_tokens.ap...
python
def convert(document): """Convert a document to a Text object""" raw_tokens = [] curpos = 0 text_spans = [] all_labels = [] sent_spans = [] word_texts = [] for sentence in document: startpos = curpos for idx, (text, label) in enumerate(sentence): raw_tokens.ap...
[ "def", "convert", "(", "document", ")", ":", "raw_tokens", "=", "[", "]", "curpos", "=", "0", "text_spans", "=", "[", "]", "all_labels", "=", "[", "]", "sent_spans", "=", "[", "]", "word_texts", "=", "[", "]", "for", "sentence", "in", "document", ":"...
Convert a document to a Text object
[ "Convert", "a", "document", "to", "a", "Text", "object" ]
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/tools/cnllconverter.py#L36-L62
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass._cleanup
def _cleanup(self): ''' Cleanup all the local data. ''' self._select_cb = None self._commit_cb = None self._rollback_cb = None super(TransactionClass, self)._cleanup()
python
def _cleanup(self): ''' Cleanup all the local data. ''' self._select_cb = None self._commit_cb = None self._rollback_cb = None super(TransactionClass, self)._cleanup()
[ "def", "_cleanup", "(", "self", ")", ":", "self", ".", "_select_cb", "=", "None", "self", ".", "_commit_cb", "=", "None", "self", ".", "_rollback_cb", "=", "None", "super", "(", "TransactionClass", ",", "self", ")", ".", "_cleanup", "(", ")" ]
Cleanup all the local data.
[ "Cleanup", "all", "the", "local", "data", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L45-L52
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass.select
def select(self, cb=None): ''' Set this channel to use transactions. ''' if not self._enabled: self._enabled = True self.send_frame(MethodFrame(self.channel_id, 90, 10)) self._select_cb.append(cb) self.channel.add_synchronous_cb(self._recv_...
python
def select(self, cb=None): ''' Set this channel to use transactions. ''' if not self._enabled: self._enabled = True self.send_frame(MethodFrame(self.channel_id, 90, 10)) self._select_cb.append(cb) self.channel.add_synchronous_cb(self._recv_...
[ "def", "select", "(", "self", ",", "cb", "=", "None", ")", ":", "if", "not", "self", ".", "_enabled", ":", "self", ".", "_enabled", "=", "True", "self", ".", "send_frame", "(", "MethodFrame", "(", "self", ".", "channel_id", ",", "90", ",", "10", ")...
Set this channel to use transactions.
[ "Set", "this", "channel", "to", "use", "transactions", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L54-L62
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass.commit
def commit(self, cb=None): ''' Commit the current transaction. Caller can specify a callback to use when the transaction is committed. ''' # Could call select() but spec 1.9.2.3 says to raise an exception if not self.enabled: raise self.TransactionsNotEnabled...
python
def commit(self, cb=None): ''' Commit the current transaction. Caller can specify a callback to use when the transaction is committed. ''' # Could call select() but spec 1.9.2.3 says to raise an exception if not self.enabled: raise self.TransactionsNotEnabled...
[ "def", "commit", "(", "self", ",", "cb", "=", "None", ")", ":", "# Could call select() but spec 1.9.2.3 says to raise an exception", "if", "not", "self", ".", "enabled", ":", "raise", "self", ".", "TransactionsNotEnabled", "(", ")", "self", ".", "send_frame", "(",...
Commit the current transaction. Caller can specify a callback to use when the transaction is committed.
[ "Commit", "the", "current", "transaction", ".", "Caller", "can", "specify", "a", "callback", "to", "use", "when", "the", "transaction", "is", "committed", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L69-L80
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass.rollback
def rollback(self, cb=None): ''' Abandon all message publications and acks in the current transaction. Caller can specify a callback to use when the transaction has been aborted. ''' # Could call select() but spec 1.9.2.5 says to raise an exception if not self.ena...
python
def rollback(self, cb=None): ''' Abandon all message publications and acks in the current transaction. Caller can specify a callback to use when the transaction has been aborted. ''' # Could call select() but spec 1.9.2.5 says to raise an exception if not self.ena...
[ "def", "rollback", "(", "self", ",", "cb", "=", "None", ")", ":", "# Could call select() but spec 1.9.2.5 says to raise an exception", "if", "not", "self", ".", "enabled", ":", "raise", "self", ".", "TransactionsNotEnabled", "(", ")", "self", ".", "send_frame", "(...
Abandon all message publications and acks in the current transaction. Caller can specify a callback to use when the transaction has been aborted.
[ "Abandon", "all", "message", "publications", "and", "acks", "in", "the", "current", "transaction", ".", "Caller", "can", "specify", "a", "callback", "to", "use", "when", "the", "transaction", "has", "been", "aborted", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L87-L99
agoragames/haigha
haigha/connection.py
Connection.synchronous
def synchronous(self): ''' True if transport is synchronous or the connection has been forced into synchronous mode, False otherwise. ''' if self._transport is None: if self._close_info and len(self._close_info['reply_text']) > 0: raise ConnectionClose...
python
def synchronous(self): ''' True if transport is synchronous or the connection has been forced into synchronous mode, False otherwise. ''' if self._transport is None: if self._close_info and len(self._close_info['reply_text']) > 0: raise ConnectionClose...
[ "def", "synchronous", "(", "self", ")", ":", "if", "self", ".", "_transport", "is", "None", ":", "if", "self", ".", "_close_info", "and", "len", "(", "self", ".", "_close_info", "[", "'reply_text'", "]", ")", ">", "0", ":", "raise", "ConnectionClosed", ...
True if transport is synchronous or the connection has been forced into synchronous mode, False otherwise.
[ "True", "if", "transport", "is", "synchronous", "or", "the", "connection", "has", "been", "forced", "into", "synchronous", "mode", "False", "otherwise", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L191-L202
agoragames/haigha
haigha/connection.py
Connection.connect
def connect(self, host, port): ''' Connect to a host and port. ''' # Clear the connect state immediately since we're no longer connected # at this point. self._connected = False # Only after the socket has connected do we clear this state; closed # must b...
python
def connect(self, host, port): ''' Connect to a host and port. ''' # Clear the connect state immediately since we're no longer connected # at this point. self._connected = False # Only after the socket has connected do we clear this state; closed # must b...
[ "def", "connect", "(", "self", ",", "host", ",", "port", ")", ":", "# Clear the connect state immediately since we're no longer connected", "# at this point.", "self", ".", "_connected", "=", "False", "# Only after the socket has connected do we clear this state; closed", "# must...
Connect to a host and port.
[ "Connect", "to", "a", "host", "and", "port", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L204-L252
agoragames/haigha
haigha/connection.py
Connection.disconnect
def disconnect(self): ''' Disconnect from the current host, but do not update the closed state. After the transport is disconnected, the closed state will be True if this is called after a protocol shutdown, or False if the disconnect was in error. TODO: do we really nee...
python
def disconnect(self): ''' Disconnect from the current host, but do not update the closed state. After the transport is disconnected, the closed state will be True if this is called after a protocol shutdown, or False if the disconnect was in error. TODO: do we really nee...
[ "def", "disconnect", "(", "self", ")", ":", "self", ".", "_connected", "=", "False", "if", "self", ".", "_transport", "is", "not", "None", ":", "try", ":", "self", ".", "_transport", ".", "disconnect", "(", ")", "except", "Exception", ":", "self", ".",...
Disconnect from the current host, but do not update the closed state. After the transport is disconnected, the closed state will be True if this is called after a protocol shutdown, or False if the disconnect was in error. TODO: do we really need closed vs. connected states? this only a...
[ "Disconnect", "from", "the", "current", "host", "but", "do", "not", "update", "the", "closed", "state", ".", "After", "the", "transport", "is", "disconnected", "the", "closed", "state", "will", "be", "True", "if", "this", "is", "called", "after", "a", "pro...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L254-L274
agoragames/haigha
haigha/connection.py
Connection.transport_closed
def transport_closed(self, **kwargs): """ Called by Transports when they close unexpectedly, not as a result of Connection.disconnect(). TODO: document args """ msg = 'unknown cause' self.logger.warning('transport to %s closed : %s' % ...
python
def transport_closed(self, **kwargs): """ Called by Transports when they close unexpectedly, not as a result of Connection.disconnect(). TODO: document args """ msg = 'unknown cause' self.logger.warning('transport to %s closed : %s' % ...
[ "def", "transport_closed", "(", "self", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "'unknown cause'", "self", ".", "logger", ".", "warning", "(", "'transport to %s closed : %s'", "%", "(", "self", ".", "_host", ",", "kwargs", ".", "get", "(", "'msg'", ...
Called by Transports when they close unexpectedly, not as a result of Connection.disconnect(). TODO: document args
[ "Called", "by", "Transports", "when", "they", "close", "unexpectedly", "not", "as", "a", "result", "of", "Connection", ".", "disconnect", "()", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L279-L302
agoragames/haigha
haigha/connection.py
Connection._next_channel_id
def _next_channel_id(self): '''Return the next possible channel id. Is a circular enumeration.''' self._channel_counter += 1 if self._channel_counter >= self._channel_max: self._channel_counter = 1 return self._channel_counter
python
def _next_channel_id(self): '''Return the next possible channel id. Is a circular enumeration.''' self._channel_counter += 1 if self._channel_counter >= self._channel_max: self._channel_counter = 1 return self._channel_counter
[ "def", "_next_channel_id", "(", "self", ")", ":", "self", ".", "_channel_counter", "+=", "1", "if", "self", ".", "_channel_counter", ">=", "self", ".", "_channel_max", ":", "self", ".", "_channel_counter", "=", "1", "return", "self", ".", "_channel_counter" ]
Return the next possible channel id. Is a circular enumeration.
[ "Return", "the", "next", "possible", "channel", "id", ".", "Is", "a", "circular", "enumeration", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L307-L312
agoragames/haigha
haigha/connection.py
Connection.channel
def channel(self, channel_id=None, synchronous=False): """ Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. If channel_id is not None but no channel exists for that id, will raise InvalidChannel. If there are alread...
python
def channel(self, channel_id=None, synchronous=False): """ Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. If channel_id is not None but no channel exists for that id, will raise InvalidChannel. If there are alread...
[ "def", "channel", "(", "self", ",", "channel_id", "=", "None", ",", "synchronous", "=", "False", ")", ":", "if", "channel_id", "is", "None", ":", "# adjust for channel 0", "if", "len", "(", "self", ".", "_channels", ")", "-", "1", ">=", "self", ".", "_...
Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. If channel_id is not None but no channel exists for that id, will raise InvalidChannel. If there are already too many channels open, will raise TooManyChannels. If synchrono...
[ "Fetch", "a", "Channel", "object", "identified", "by", "the", "numeric", "channel_id", "or", "create", "that", "object", "if", "it", "doesn", "t", "already", "exist", ".", "If", "channel_id", "is", "not", "None", "but", "no", "channel", "exists", "for", "t...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L314-L348
agoragames/haigha
haigha/connection.py
Connection.close
def close(self, reply_code=0, reply_text='', class_id=0, method_id=0, disconnect=False): ''' Close this connection. ''' self._close_info = { 'reply_code': reply_code, 'reply_text': reply_text, 'class_id': class_id, 'method_id'...
python
def close(self, reply_code=0, reply_text='', class_id=0, method_id=0, disconnect=False): ''' Close this connection. ''' self._close_info = { 'reply_code': reply_code, 'reply_text': reply_text, 'class_id': class_id, 'method_id'...
[ "def", "close", "(", "self", ",", "reply_code", "=", "0", ",", "reply_text", "=", "''", ",", "class_id", "=", "0", ",", "method_id", "=", "0", ",", "disconnect", "=", "False", ")", ":", "self", ".", "_close_info", "=", "{", "'reply_code'", ":", "repl...
Close this connection.
[ "Close", "this", "connection", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L359-L375
agoragames/haigha
haigha/connection.py
Connection.read_frames
def read_frames(self): ''' Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on. ''' # It's possible in a concurrent environment that our transport handle # has gone away, so handle that cl...
python
def read_frames(self): ''' Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on. ''' # It's possible in a concurrent environment that our transport handle # has gone away, so handle that cl...
[ "def", "read_frames", "(", "self", ")", ":", "# It's possible in a concurrent environment that our transport handle", "# has gone away, so handle that cleanly.", "# TODO: Consider moving this block into Translator base class. In many", "# ways it belongs there. One of the problems though is that t...
Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on.
[ "Read", "frames", "from", "the", "transport", "and", "process", "them", ".", "Some", "transports", "may", "choose", "to", "do", "this", "in", "the", "background", "in", "several", "threads", "and", "so", "on", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L393-L458
agoragames/haigha
haigha/connection.py
Connection._flush_buffered_frames
def _flush_buffered_frames(self): ''' Callback when protocol has been initialized on channel 0 and we're ready to send out frames to set up any channels that have been created. ''' # In the rare case (a bug) where this is called but send_frame thinks # they should...
python
def _flush_buffered_frames(self): ''' Callback when protocol has been initialized on channel 0 and we're ready to send out frames to set up any channels that have been created. ''' # In the rare case (a bug) where this is called but send_frame thinks # they should...
[ "def", "_flush_buffered_frames", "(", "self", ")", ":", "# In the rare case (a bug) where this is called but send_frame thinks", "# they should be buffered, don't clobber.", "frames", "=", "self", ".", "_output_frame_buffer", "self", ".", "_output_frame_buffer", "=", "[", "]", ...
Callback when protocol has been initialized on channel 0 and we're ready to send out frames to set up any channels that have been created.
[ "Callback", "when", "protocol", "has", "been", "initialized", "on", "channel", "0", "and", "we", "re", "ready", "to", "send", "out", "frames", "to", "set", "up", "any", "channels", "that", "have", "been", "created", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L460-L471
agoragames/haigha
haigha/connection.py
Connection.send_frame
def send_frame(self, frame): ''' Send a single frame. If there is no transport or we're not connected yet, append to the output buffer, else send immediately to the socket. This is called from within the MethodFrames. ''' if self._closed: if self._close_info a...
python
def send_frame(self, frame): ''' Send a single frame. If there is no transport or we're not connected yet, append to the output buffer, else send immediately to the socket. This is called from within the MethodFrames. ''' if self._closed: if self._close_info a...
[ "def", "send_frame", "(", "self", ",", "frame", ")", ":", "if", "self", ".", "_closed", ":", "if", "self", ".", "_close_info", "and", "len", "(", "self", ".", "_close_info", "[", "'reply_text'", "]", ")", ">", "0", ":", "raise", "ConnectionClosed", "("...
Send a single frame. If there is no transport or we're not connected yet, append to the output buffer, else send immediately to the socket. This is called from within the MethodFrames.
[ "Send", "a", "single", "frame", ".", "If", "there", "is", "no", "transport", "or", "we", "re", "not", "connected", "yet", "append", "to", "the", "output", "buffer", "else", "send", "immediately", "to", "the", "socket", ".", "This", "is", "called", "from"...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L473-L508
agoragames/haigha
haigha/connection.py
ConnectionChannel.dispatch
def dispatch(self, frame): ''' Override the default dispatch since we don't need the rest of the stack. ''' if frame.type() == HeartbeatFrame.type(): self.send_heartbeat() elif frame.type() == MethodFrame.type(): if frame.class_id == 10: ...
python
def dispatch(self, frame): ''' Override the default dispatch since we don't need the rest of the stack. ''' if frame.type() == HeartbeatFrame.type(): self.send_heartbeat() elif frame.type() == MethodFrame.type(): if frame.class_id == 10: ...
[ "def", "dispatch", "(", "self", ",", "frame", ")", ":", "if", "frame", ".", "type", "(", ")", "==", "HeartbeatFrame", ".", "type", "(", ")", ":", "self", ".", "send_heartbeat", "(", ")", "elif", "frame", ".", "type", "(", ")", "==", "MethodFrame", ...
Override the default dispatch since we don't need the rest of the stack.
[ "Override", "the", "default", "dispatch", "since", "we", "don", "t", "need", "the", "rest", "of", "the", "stack", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L534-L560
agoragames/haigha
haigha/connection.py
ConnectionChannel.send_heartbeat
def send_heartbeat(self): ''' Send a heartbeat if needed. Tracks last heartbeat send time. ''' # Note that this does not take into account the time that we last # sent a frame. Hearbeats are so small the effect should be quite # limited. Also note that we're looking for s...
python
def send_heartbeat(self): ''' Send a heartbeat if needed. Tracks last heartbeat send time. ''' # Note that this does not take into account the time that we last # sent a frame. Hearbeats are so small the effect should be quite # limited. Also note that we're looking for s...
[ "def", "send_heartbeat", "(", "self", ")", ":", "# Note that this does not take into account the time that we last", "# sent a frame. Hearbeats are so small the effect should be quite", "# limited. Also note that we're looking for something near to our", "# scheduled interval, because if this is e...
Send a heartbeat if needed. Tracks last heartbeat send time.
[ "Send", "a", "heartbeat", "if", "needed", ".", "Tracks", "last", "heartbeat", "send", "time", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L568-L583
agoragames/haigha
haigha/connection.py
ConnectionChannel._send_start_ok
def _send_start_ok(self): '''Send the start_ok message.''' args = Writer() args.write_table(self.connection._properties) args.write_shortstr(self.connection._login_method) args.write_longstr(self.connection._login_response) args.write_shortstr(self.connection._locale) ...
python
def _send_start_ok(self): '''Send the start_ok message.''' args = Writer() args.write_table(self.connection._properties) args.write_shortstr(self.connection._login_method) args.write_longstr(self.connection._login_response) args.write_shortstr(self.connection._locale) ...
[ "def", "_send_start_ok", "(", "self", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_table", "(", "self", ".", "connection", ".", "_properties", ")", "args", ".", "write_shortstr", "(", "self", ".", "connection", ".", "_login_method", ")", ...
Send the start_ok message.
[ "Send", "the", "start_ok", "message", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L589-L598
agoragames/haigha
haigha/classes/exchange_class.py
ExchangeClass._cleanup
def _cleanup(self): ''' Cleanup local data. ''' self._declare_cb = None self._delete_cb = None super(ExchangeClass, self)._cleanup()
python
def _cleanup(self): ''' Cleanup local data. ''' self._declare_cb = None self._delete_cb = None super(ExchangeClass, self)._cleanup()
[ "def", "_cleanup", "(", "self", ")", ":", "self", ".", "_declare_cb", "=", "None", "self", ".", "_delete_cb", "=", "None", "super", "(", "ExchangeClass", ",", "self", ")", ".", "_cleanup", "(", ")" ]
Cleanup local data.
[ "Cleanup", "local", "data", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/exchange_class.py#L34-L40
agoragames/haigha
haigha/classes/exchange_class.py
ExchangeClass.declare
def declare(self, exchange, type, passive=False, durable=False, nowait=True, arguments=None, ticket=None, cb=None): """ Declare the exchange. exchange - The name of the exchange to declare type - One of """ nowait = nowait and self.allow_nowait() and not ...
python
def declare(self, exchange, type, passive=False, durable=False, nowait=True, arguments=None, ticket=None, cb=None): """ Declare the exchange. exchange - The name of the exchange to declare type - One of """ nowait = nowait and self.allow_nowait() and not ...
[ "def", "declare", "(", "self", ",", "exchange", ",", "type", ",", "passive", "=", "False", ",", "durable", "=", "False", ",", "nowait", "=", "True", ",", "arguments", "=", "None", ",", "ticket", "=", "None", ",", "cb", "=", "None", ")", ":", "nowai...
Declare the exchange. exchange - The name of the exchange to declare type - One of
[ "Declare", "the", "exchange", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/exchange_class.py#L42-L62
agoragames/haigha
haigha/classes/exchange_class.py
ExchangeClass.delete
def delete(self, exchange, if_unused=False, nowait=True, ticket=None, cb=None): ''' Delete an exchange. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exch...
python
def delete(self, exchange, if_unused=False, nowait=True, ticket=None, cb=None): ''' Delete an exchange. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exch...
[ "def", "delete", "(", "self", ",", "exchange", ",", "if_unused", "=", "False", ",", "nowait", "=", "True", ",", "ticket", "=", "None", ",", "cb", "=", "None", ")", ":", "nowait", "=", "nowait", "and", "self", ".", "allow_nowait", "(", ")", "and", "...
Delete an exchange.
[ "Delete", "an", "exchange", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/exchange_class.py#L72-L87
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.connect
def connect(self, (host, port), klass=socket.socket): '''Connect assuming a host and port tuple. :param tuple: A tuple containing host and port for a connection. :param klass: A implementation of socket.socket. :raises socket.gaierror: If no address can be resolved. :raises sock...
python
def connect(self, (host, port), klass=socket.socket): '''Connect assuming a host and port tuple. :param tuple: A tuple containing host and port for a connection. :param klass: A implementation of socket.socket. :raises socket.gaierror: If no address can be resolved. :raises sock...
[ "def", "connect", "(", "self", ",", "(", "host", ",", "port", ")", ",", "klass", "=", "socket", ".", "socket", ")", ":", "self", ".", "_host", "=", "\"%s:%s\"", "%", "(", "host", ",", "port", ")", "for", "info", "in", "socket", ".", "getaddrinfo", ...
Connect assuming a host and port tuple. :param tuple: A tuple containing host and port for a connection. :param klass: A implementation of socket.socket. :raises socket.gaierror: If no address can be resolved. :raises socket.error: If no connection can be made.
[ "Connect", "assuming", "a", "host", "and", "port", "tuple", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L27-L64
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.read
def read(self, timeout=None): ''' Read from the transport. If timeout>0, will only block for `timeout` seconds. ''' e = None if not hasattr(self, '_sock'): return None try: # Note that we ignore both None and 0, i.e. we either block with a...
python
def read(self, timeout=None): ''' Read from the transport. If timeout>0, will only block for `timeout` seconds. ''' e = None if not hasattr(self, '_sock'): return None try: # Note that we ignore both None and 0, i.e. we either block with a...
[ "def", "read", "(", "self", ",", "timeout", "=", "None", ")", ":", "e", "=", "None", "if", "not", "hasattr", "(", "self", ",", "'_sock'", ")", ":", "return", "None", "try", ":", "# Note that we ignore both None and 0, i.e. we either block with a", "# timeout or ...
Read from the transport. If timeout>0, will only block for `timeout` seconds.
[ "Read", "from", "the", "transport", ".", "If", "timeout", ">", "0", "will", "only", "block", "for", "timeout", "seconds", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L66-L115
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.buffer
def buffer(self, data): ''' Buffer unused bytes from the input stream. ''' if not hasattr(self, '_sock'): return None # data will always be a byte array if len(self._buffer): self._buffer.extend(data) else: self._buffer = bytea...
python
def buffer(self, data): ''' Buffer unused bytes from the input stream. ''' if not hasattr(self, '_sock'): return None # data will always be a byte array if len(self._buffer): self._buffer.extend(data) else: self._buffer = bytea...
[ "def", "buffer", "(", "self", ",", "data", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_sock'", ")", ":", "return", "None", "# data will always be a byte array", "if", "len", "(", "self", ".", "_buffer", ")", ":", "self", ".", "_buffer", ".", ...
Buffer unused bytes from the input stream.
[ "Buffer", "unused", "bytes", "from", "the", "input", "stream", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L117-L128
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.write
def write(self, data): ''' Write some bytes to the transport. ''' if not hasattr(self, '_sock'): return None try: self._sock.sendall(data) if self.connection.debug > 1: self.connection.logger.debug( 'sent %...
python
def write(self, data): ''' Write some bytes to the transport. ''' if not hasattr(self, '_sock'): return None try: self._sock.sendall(data) if self.connection.debug > 1: self.connection.logger.debug( 'sent %...
[ "def", "write", "(", "self", ",", "data", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_sock'", ")", ":", "return", "None", "try", ":", "self", ".", "_sock", ".", "sendall", "(", "data", ")", "if", "self", ".", "connection", ".", "debug", ...
Write some bytes to the transport.
[ "Write", "some", "bytes", "to", "the", "transport", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L130-L156
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._cleanup
def _cleanup(self): ''' Cleanup all the local data. ''' self._pending_consumers = None self._consumer_cb = None self._get_cb = None self._recover_cb = None self._cancel_cb = None self._return_listener = None super(BasicClass, self)._cleanup...
python
def _cleanup(self): ''' Cleanup all the local data. ''' self._pending_consumers = None self._consumer_cb = None self._get_cb = None self._recover_cb = None self._cancel_cb = None self._return_listener = None super(BasicClass, self)._cleanup...
[ "def", "_cleanup", "(", "self", ")", ":", "self", ".", "_pending_consumers", "=", "None", "self", ".", "_consumer_cb", "=", "None", "self", ".", "_get_cb", "=", "None", "self", ".", "_recover_cb", "=", "None", "self", ".", "_cancel_cb", "=", "None", "sel...
Cleanup all the local data.
[ "Cleanup", "all", "the", "local", "data", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L48-L58
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.set_return_listener
def set_return_listener(self, cb): ''' Set a callback for basic.return listening. Will be called with a single Message argument. The return_info attribute of the Message will have the following properties: 'channel': Channel instance 'reply_code': reply c...
python
def set_return_listener(self, cb): ''' Set a callback for basic.return listening. Will be called with a single Message argument. The return_info attribute of the Message will have the following properties: 'channel': Channel instance 'reply_code': reply c...
[ "def", "set_return_listener", "(", "self", ",", "cb", ")", ":", "if", "cb", "is", "not", "None", "and", "not", "callable", "(", "cb", ")", ":", "raise", "ValueError", "(", "'return_listener callback must either be None or '", "'a callable, but got: %r'", "%", "(",...
Set a callback for basic.return listening. Will be called with a single Message argument. The return_info attribute of the Message will have the following properties: 'channel': Channel instance 'reply_code': reply code (int) 'reply_text': reply text ...
[ "Set", "a", "callback", "for", "basic", ".", "return", "listening", ".", "Will", "be", "called", "with", "a", "single", "Message", "argument", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L60-L82
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.qos
def qos(self, prefetch_size=0, prefetch_count=0, is_global=False): ''' Set QoS on this channel. ''' args = Writer() args.write_long(prefetch_size).\ write_short(prefetch_count).\ write_bit(is_global) self.send_frame(MethodFrame(self.channel_id, 60,...
python
def qos(self, prefetch_size=0, prefetch_count=0, is_global=False): ''' Set QoS on this channel. ''' args = Writer() args.write_long(prefetch_size).\ write_short(prefetch_count).\ write_bit(is_global) self.send_frame(MethodFrame(self.channel_id, 60,...
[ "def", "qos", "(", "self", ",", "prefetch_size", "=", "0", ",", "prefetch_count", "=", "0", ",", "is_global", "=", "False", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_long", "(", "prefetch_size", ")", ".", "write_short", "(", "prefe...
Set QoS on this channel.
[ "Set", "QoS", "on", "this", "channel", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L96-L106
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.consume
def consume(self, queue, consumer, consumer_tag='', no_local=False, no_ack=True, exclusive=False, nowait=True, ticket=None, cb=None): ''' Start a queue consumer. If `cb` is supplied, will be called when broker confirms that consumer is registered. ''' ...
python
def consume(self, queue, consumer, consumer_tag='', no_local=False, no_ack=True, exclusive=False, nowait=True, ticket=None, cb=None): ''' Start a queue consumer. If `cb` is supplied, will be called when broker confirms that consumer is registered. ''' ...
[ "def", "consume", "(", "self", ",", "queue", ",", "consumer", ",", "consumer_tag", "=", "''", ",", "no_local", "=", "False", ",", "no_ack", "=", "True", ",", "exclusive", "=", "False", ",", "nowait", "=", "True", ",", "ticket", "=", "None", ",", "cb"...
Start a queue consumer. If `cb` is supplied, will be called when broker confirms that consumer is registered.
[ "Start", "a", "queue", "consumer", ".", "If", "cb", "is", "supplied", "will", "be", "called", "when", "broker", "confirms", "that", "consumer", "is", "registered", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L112-L136
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.cancel
def cancel(self, consumer_tag='', nowait=True, consumer=None, cb=None): ''' Cancel a consumer. Can choose to delete based on a consumer tag or the function which is consuming. If deleting by function, take care to only use a consumer once per channel. ''' if consumer: ...
python
def cancel(self, consumer_tag='', nowait=True, consumer=None, cb=None): ''' Cancel a consumer. Can choose to delete based on a consumer tag or the function which is consuming. If deleting by function, take care to only use a consumer once per channel. ''' if consumer: ...
[ "def", "cancel", "(", "self", ",", "consumer_tag", "=", "''", ",", "nowait", "=", "True", ",", "consumer", "=", "None", ",", "cb", "=", "None", ")", ":", "if", "consumer", ":", "tag", "=", "self", ".", "_lookup_consumer_tag_by_consumer", "(", "consumer",...
Cancel a consumer. Can choose to delete based on a consumer tag or the function which is consuming. If deleting by function, take care to only use a consumer once per channel.
[ "Cancel", "a", "consumer", ".", "Can", "choose", "to", "delete", "based", "on", "a", "consumer", "tag", "or", "the", "function", "which", "is", "consuming", ".", "If", "deleting", "by", "function", "take", "care", "to", "only", "use", "a", "consumer", "o...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L146-L168
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._lookup_consumer_tag_by_consumer
def _lookup_consumer_tag_by_consumer(self, consumer): '''Look up consumer tag given its consumer function NOTE: this protected method may be called by derived classes :param callable consumer: consumer function :returns: matching consumer tag or None :rtype: str or None ...
python
def _lookup_consumer_tag_by_consumer(self, consumer): '''Look up consumer tag given its consumer function NOTE: this protected method may be called by derived classes :param callable consumer: consumer function :returns: matching consumer tag or None :rtype: str or None ...
[ "def", "_lookup_consumer_tag_by_consumer", "(", "self", ",", "consumer", ")", ":", "for", "(", "tag", ",", "func", ")", "in", "self", ".", "_consumer_cb", ".", "iteritems", "(", ")", ":", "if", "func", "==", "consumer", ":", "return", "tag" ]
Look up consumer tag given its consumer function NOTE: this protected method may be called by derived classes :param callable consumer: consumer function :returns: matching consumer tag or None :rtype: str or None
[ "Look", "up", "consumer", "tag", "given", "its", "consumer", "function" ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L179-L191
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._purge_consumer_by_tag
def _purge_consumer_by_tag(self, consumer_tag): '''Purge consumer entry from this basic instance NOTE: this protected method may be called by derived classes :param str consumer_tag: ''' try: del self._consumer_cb[consumer_tag] except KeyError: s...
python
def _purge_consumer_by_tag(self, consumer_tag): '''Purge consumer entry from this basic instance NOTE: this protected method may be called by derived classes :param str consumer_tag: ''' try: del self._consumer_cb[consumer_tag] except KeyError: s...
[ "def", "_purge_consumer_by_tag", "(", "self", ",", "consumer_tag", ")", ":", "try", ":", "del", "self", ".", "_consumer_cb", "[", "consumer_tag", "]", "except", "KeyError", ":", "self", ".", "logger", ".", "warning", "(", "'no callback registered for consumer tag ...
Purge consumer entry from this basic instance NOTE: this protected method may be called by derived classes :param str consumer_tag:
[ "Purge", "consumer", "entry", "from", "this", "basic", "instance" ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L193-L206
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.publish
def publish(self, msg, exchange, routing_key, mandatory=False, immediate=False, ticket=None): ''' publish a message. ''' args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exchange).\ write_shortstr(routing_key...
python
def publish(self, msg, exchange, routing_key, mandatory=False, immediate=False, ticket=None): ''' publish a message. ''' args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exchange).\ write_shortstr(routing_key...
[ "def", "publish", "(", "self", ",", "msg", ",", "exchange", ",", "routing_key", ",", "mandatory", "=", "False", ",", "immediate", "=", "False", ",", "ticket", "=", "None", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_short", "(", "t...
publish a message.
[ "publish", "a", "message", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L208-L225
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.return_msg
def return_msg(self, reply_code, reply_text, exchange, routing_key): ''' Return a failed message. Not named "return" because python interpreter can't deal with that. ''' args = Writer() args.write_short(reply_code).\ write_shortstr(reply_text).\ w...
python
def return_msg(self, reply_code, reply_text, exchange, routing_key): ''' Return a failed message. Not named "return" because python interpreter can't deal with that. ''' args = Writer() args.write_short(reply_code).\ write_shortstr(reply_text).\ w...
[ "def", "return_msg", "(", "self", ",", "reply_code", ",", "reply_text", ",", "exchange", ",", "routing_key", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_short", "(", "reply_code", ")", ".", "write_shortstr", "(", "reply_text", ")", ".", ...
Return a failed message. Not named "return" because python interpreter can't deal with that.
[ "Return", "a", "failed", "message", ".", "Not", "named", "return", "because", "python", "interpreter", "can", "t", "deal", "with", "that", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L227-L238
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._recv_return
def _recv_return(self, method_frame): ''' Handle basic.return method. If we have a complete message, will call the user's return listener callabck (if any). If there are not enough frames, will re-queue current frames and raise a FrameUnderflow NOTE: if the channel was in confir...
python
def _recv_return(self, method_frame): ''' Handle basic.return method. If we have a complete message, will call the user's return listener callabck (if any). If there are not enough frames, will re-queue current frames and raise a FrameUnderflow NOTE: if the channel was in confir...
[ "def", "_recv_return", "(", "self", ",", "method_frame", ")", ":", "msg", "=", "self", ".", "_read_returned_msg", "(", "method_frame", ")", "if", "callable", "(", "self", ".", "_return_listener", ")", ":", "self", ".", "_return_listener", "(", "msg", ")", ...
Handle basic.return method. If we have a complete message, will call the user's return listener callabck (if any). If there are not enough frames, will re-queue current frames and raise a FrameUnderflow NOTE: if the channel was in confirmation mode when the message was published, then t...
[ "Handle", "basic", ".", "return", "method", ".", "If", "we", "have", "a", "complete", "message", "will", "call", "the", "user", "s", "return", "listener", "callabck", "(", "if", "any", ")", ".", "If", "there", "are", "not", "enough", "frames", "will", ...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L240-L256
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.get
def get(self, queue, consumer=None, no_ack=True, ticket=None): ''' Ask to fetch a single message from a queue. If a consumer is supplied, the consumer will be called with either a Message argument, or None if there is no message in queue. If a synchronous transport, Message or N...
python
def get(self, queue, consumer=None, no_ack=True, ticket=None): ''' Ask to fetch a single message from a queue. If a consumer is supplied, the consumer will be called with either a Message argument, or None if there is no message in queue. If a synchronous transport, Message or N...
[ "def", "get", "(", "self", ",", "queue", ",", "consumer", "=", "None", ",", "no_ack", "=", "True", ",", "ticket", "=", "None", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_short", "(", "ticket", "or", "self", ".", "default_ticket", ...
Ask to fetch a single message from a queue. If a consumer is supplied, the consumer will be called with either a Message argument, or None if there is no message in queue. If a synchronous transport, Message or None is returned.
[ "Ask", "to", "fetch", "a", "single", "message", "from", "a", "queue", ".", "If", "a", "consumer", "is", "supplied", "the", "consumer", "will", "be", "called", "with", "either", "a", "Message", "argument", "or", "None", "if", "there", "is", "no", "message...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L266-L280
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._recv_get_response
def _recv_get_response(self, method_frame): ''' Handle either get_ok or get_empty. This is a hack because the synchronous callback stack is expecting one method to satisfy the expectation. To keep that loop as tight as possible, work within those constraints. Use of get is not re...
python
def _recv_get_response(self, method_frame): ''' Handle either get_ok or get_empty. This is a hack because the synchronous callback stack is expecting one method to satisfy the expectation. To keep that loop as tight as possible, work within those constraints. Use of get is not re...
[ "def", "_recv_get_response", "(", "self", ",", "method_frame", ")", ":", "if", "method_frame", ".", "method_id", "==", "71", ":", "return", "self", ".", "_recv_get_ok", "(", "method_frame", ")", "elif", "method_frame", ".", "method_id", "==", "72", ":", "ret...
Handle either get_ok or get_empty. This is a hack because the synchronous callback stack is expecting one method to satisfy the expectation. To keep that loop as tight as possible, work within those constraints. Use of get is not recommended anyway.
[ "Handle", "either", "get_ok", "or", "get_empty", ".", "This", "is", "a", "hack", "because", "the", "synchronous", "callback", "stack", "is", "expecting", "one", "method", "to", "satisfy", "the", "expectation", ".", "To", "keep", "that", "loop", "as", "tight"...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L282-L292
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.ack
def ack(self, delivery_tag, multiple=False): ''' Acknowledge delivery of a message. If multiple=True, acknowledge up-to and including delivery_tag. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(multiple) self.send_frame(MethodFram...
python
def ack(self, delivery_tag, multiple=False): ''' Acknowledge delivery of a message. If multiple=True, acknowledge up-to and including delivery_tag. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(multiple) self.send_frame(MethodFram...
[ "def", "ack", "(", "self", ",", "delivery_tag", ",", "multiple", "=", "False", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_longlong", "(", "delivery_tag", ")", ".", "write_bit", "(", "multiple", ")", "self", ".", "send_frame", "(", "...
Acknowledge delivery of a message. If multiple=True, acknowledge up-to and including delivery_tag.
[ "Acknowledge", "delivery", "of", "a", "message", ".", "If", "multiple", "=", "True", "acknowledge", "up", "-", "to", "and", "including", "delivery_tag", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L309-L318
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.reject
def reject(self, delivery_tag, requeue=False): ''' Reject a message. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(requeue) self.send_frame(MethodFrame(self.channel_id, 60, 90, args))
python
def reject(self, delivery_tag, requeue=False): ''' Reject a message. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(requeue) self.send_frame(MethodFrame(self.channel_id, 60, 90, args))
[ "def", "reject", "(", "self", ",", "delivery_tag", ",", "requeue", "=", "False", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_longlong", "(", "delivery_tag", ")", ".", "write_bit", "(", "requeue", ")", "self", ".", "send_frame", "(", ...
Reject a message.
[ "Reject", "a", "message", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L320-L328
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.recover_async
def recover_async(self, requeue=False): ''' Redeliver all unacknowledged messages on this channel. This method is deprecated in favour of the synchronous recover/recover-ok ''' args = Writer() args.write_bit(requeue) self.send_frame(MethodFrame(self.chan...
python
def recover_async(self, requeue=False): ''' Redeliver all unacknowledged messages on this channel. This method is deprecated in favour of the synchronous recover/recover-ok ''' args = Writer() args.write_bit(requeue) self.send_frame(MethodFrame(self.chan...
[ "def", "recover_async", "(", "self", ",", "requeue", "=", "False", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_bit", "(", "requeue", ")", "self", ".", "send_frame", "(", "MethodFrame", "(", "self", ".", "channel_id", ",", "60", ",", ...
Redeliver all unacknowledged messages on this channel. This method is deprecated in favour of the synchronous recover/recover-ok
[ "Redeliver", "all", "unacknowledged", "messages", "on", "this", "channel", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L330-L340
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.recover
def recover(self, requeue=False, cb=None): ''' Ask server to redeliver all unacknowledged messages. ''' args = Writer() args.write_bit(requeue) # The XML spec is incorrect; this method is always synchronous # http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/...
python
def recover(self, requeue=False, cb=None): ''' Ask server to redeliver all unacknowledged messages. ''' args = Writer() args.write_bit(requeue) # The XML spec is incorrect; this method is always synchronous # http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/...
[ "def", "recover", "(", "self", ",", "requeue", "=", "False", ",", "cb", "=", "None", ")", ":", "args", "=", "Writer", "(", ")", "args", ".", "write_bit", "(", "requeue", ")", "# The XML spec is incorrect; this method is always synchronous", "# http://lists.rabbit...
Ask server to redeliver all unacknowledged messages.
[ "Ask", "server", "to", "redeliver", "all", "unacknowledged", "messages", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L342-L353
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._read_msg
def _read_msg(self, method_frame, with_consumer_tag=False, with_message_count=False): ''' Support method to read a Message from the current frame buffer. Will return a Message, or re-queue current frames and raise a FrameUnderflow. Takes an optional argument on whether ...
python
def _read_msg(self, method_frame, with_consumer_tag=False, with_message_count=False): ''' Support method to read a Message from the current frame buffer. Will return a Message, or re-queue current frames and raise a FrameUnderflow. Takes an optional argument on whether ...
[ "def", "_read_msg", "(", "self", ",", "method_frame", ",", "with_consumer_tag", "=", "False", ",", "with_message_count", "=", "False", ")", ":", "header_frame", ",", "body", "=", "self", ".", "_reap_msg_frames", "(", "method_frame", ")", "if", "with_consumer_tag...
Support method to read a Message from the current frame buffer. Will return a Message, or re-queue current frames and raise a FrameUnderflow. Takes an optional argument on whether to read the consumer tag so it can be used for both deliver and get-ok.
[ "Support", "method", "to", "read", "a", "Message", "from", "the", "current", "frame", "buffer", ".", "Will", "return", "a", "Message", "or", "re", "-", "queue", "current", "frames", "and", "raise", "a", "FrameUnderflow", ".", "Takes", "an", "optional", "ar...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L360-L392
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._read_returned_msg
def _read_returned_msg(self, method_frame): ''' Support method to read a returned (basic.return) Message from the current frame buffer. Will return a Message with return_info, or re-queue current frames and raise a FrameUnderflow. :returns: Message with the return_info attribute...
python
def _read_returned_msg(self, method_frame): ''' Support method to read a returned (basic.return) Message from the current frame buffer. Will return a Message with return_info, or re-queue current frames and raise a FrameUnderflow. :returns: Message with the return_info attribute...
[ "def", "_read_returned_msg", "(", "self", ",", "method_frame", ")", ":", "header_frame", ",", "body", "=", "self", ".", "_reap_msg_frames", "(", "method_frame", ")", "return_info", "=", "{", "'channel'", ":", "self", ".", "channel", ",", "'reply_code'", ":", ...
Support method to read a returned (basic.return) Message from the current frame buffer. Will return a Message with return_info, or re-queue current frames and raise a FrameUnderflow. :returns: Message with the return_info attribute set, where return_info is a dict with the following p...
[ "Support", "method", "to", "read", "a", "returned", "(", "basic", ".", "return", ")", "Message", "from", "the", "current", "frame", "buffer", ".", "Will", "return", "a", "Message", "with", "return_info", "or", "re", "-", "queue", "current", "frames", "and"...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L394-L419
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._reap_msg_frames
def _reap_msg_frames(self, method_frame): ''' Support method to reap header frame and body from current frame buffer. Used in processing of basic.return, basic.deliver, and basic.get_ok. Will return a pair (<header frame>, <body>), or re-queue current frames and raise a FrameUnde...
python
def _reap_msg_frames(self, method_frame): ''' Support method to reap header frame and body from current frame buffer. Used in processing of basic.return, basic.deliver, and basic.get_ok. Will return a pair (<header frame>, <body>), or re-queue current frames and raise a FrameUnde...
[ "def", "_reap_msg_frames", "(", "self", ",", "method_frame", ")", ":", "# No need to assert that is instance of Header or Content frames", "# because failure to access as such will result in exception that", "# channel will pick up and handle accordingly.", "header_frame", "=", "self", "...
Support method to reap header frame and body from current frame buffer. Used in processing of basic.return, basic.deliver, and basic.get_ok. Will return a pair (<header frame>, <body>), or re-queue current frames and raise a FrameUnderflow. :returns: pair (<header frame>, <body>) ...
[ "Support", "method", "to", "reap", "header", "frame", "and", "body", "from", "current", "frame", "buffer", ".", "Used", "in", "processing", "of", "basic", ".", "return", "basic", ".", "deliver", "and", "basic", ".", "get_ok", ".", "Will", "return", "a", ...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L421-L452
agoragames/haigha
haigha/channel_pool.py
ChannelPool.publish
def publish(self, *args, **kwargs): ''' Publish a message. Caller can supply an optional callback which will be fired when the transaction is committed. Tries very hard to avoid closed and inactive channels, but a ChannelError or ConnectionError may still be raised. ''' ...
python
def publish(self, *args, **kwargs): ''' Publish a message. Caller can supply an optional callback which will be fired when the transaction is committed. Tries very hard to avoid closed and inactive channels, but a ChannelError or ConnectionError may still be raised. ''' ...
[ "def", "publish", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "user_cb", "=", "kwargs", ".", "pop", "(", "'cb'", ",", "None", ")", "# If the first channel we grab is inactive, continue fetching until", "# we get an active channel, then put the in...
Publish a message. Caller can supply an optional callback which will be fired when the transaction is committed. Tries very hard to avoid closed and inactive channels, but a ChannelError or ConnectionError may still be raised.
[ "Publish", "a", "message", ".", "Caller", "can", "supply", "an", "optional", "callback", "which", "will", "be", "fired", "when", "the", "transaction", "is", "committed", ".", "Tries", "very", "hard", "to", "avoid", "closed", "and", "inactive", "channels", "b...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel_pool.py#L35-L72
agoragames/haigha
haigha/channel_pool.py
ChannelPool._process_queue
def _process_queue(self): ''' If there are any message in the queue, process one of them. ''' if len(self._queue): args, kwargs = self._queue.popleft() self.publish(*args, **kwargs)
python
def _process_queue(self): ''' If there are any message in the queue, process one of them. ''' if len(self._queue): args, kwargs = self._queue.popleft() self.publish(*args, **kwargs)
[ "def", "_process_queue", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_queue", ")", ":", "args", ",", "kwargs", "=", "self", ".", "_queue", ".", "popleft", "(", ")", "self", ".", "publish", "(", "*", "args", ",", "*", "*", "kwargs", ")"...
If there are any message in the queue, process one of them.
[ "If", "there", "are", "any", "message", "in", "the", "queue", "process", "one", "of", "them", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel_pool.py#L74-L80
agoragames/haigha
haigha/channel_pool.py
ChannelPool._get_channel
def _get_channel(self): ''' Fetch a channel from the pool. Will return a new one if necessary. If a channel in the free pool is closed, will remove it. Will return None if we hit the cap. Will clean up any channels that were published to but closed due to error. ''' ...
python
def _get_channel(self): ''' Fetch a channel from the pool. Will return a new one if necessary. If a channel in the free pool is closed, will remove it. Will return None if we hit the cap. Will clean up any channels that were published to but closed due to error. ''' ...
[ "def", "_get_channel", "(", "self", ")", ":", "while", "len", "(", "self", ".", "_free_channels", ")", ":", "rval", "=", "self", ".", "_free_channels", ".", "pop", "(", ")", "if", "not", "rval", ".", "closed", ":", "return", "rval", "# don't adjust _chan...
Fetch a channel from the pool. Will return a new one if necessary. If a channel in the free pool is closed, will remove it. Will return None if we hit the cap. Will clean up any channels that were published to but closed due to error.
[ "Fetch", "a", "channel", "from", "the", "pool", ".", "Will", "return", "a", "new", "one", "if", "necessary", ".", "If", "a", "channel", "in", "the", "free", "pool", "is", "closed", "will", "remove", "it", ".", "Will", "return", "None", "if", "we", "h...
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel_pool.py#L82-L100
agoragames/haigha
haigha/frames/content_frame.py
ContentFrame.create_frames
def create_frames(self, channel_id, buf, frame_max): ''' A generator which will create frames from a buffer given a max frame size. ''' size = frame_max - 8 # 8 bytes overhead for frame header and footer offset = 0 while True: payload = buf[offset:(o...
python
def create_frames(self, channel_id, buf, frame_max): ''' A generator which will create frames from a buffer given a max frame size. ''' size = frame_max - 8 # 8 bytes overhead for frame header and footer offset = 0 while True: payload = buf[offset:(o...
[ "def", "create_frames", "(", "self", ",", "channel_id", ",", "buf", ",", "frame_max", ")", ":", "size", "=", "frame_max", "-", "8", "# 8 bytes overhead for frame header and footer", "offset", "=", "0", "while", "True", ":", "payload", "=", "buf", "[", "offset"...
A generator which will create frames from a buffer given a max frame size.
[ "A", "generator", "which", "will", "create", "frames", "from", "a", "buffer", "given", "a", "max", "frame", "size", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/content_frame.py#L30-L45
agoragames/haigha
haigha/frames/content_frame.py
ContentFrame.write_frame
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()).\ write_short(self.channel_id).\ write_long(len(self._payload)).\ write(self._payload).\ write_octet(...
python
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()).\ write_short(self.channel_id).\ write_long(len(self._payload)).\ write(self._payload).\ write_octet(...
[ "def", "write_frame", "(", "self", ",", "buf", ")", ":", "writer", "=", "Writer", "(", "buf", ")", "writer", ".", "write_octet", "(", "self", ".", "type", "(", ")", ")", ".", "write_short", "(", "self", ".", "channel_id", ")", ".", "write_long", "(",...
Write the frame into an existing buffer.
[ "Write", "the", "frame", "into", "an", "existing", "buffer", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/content_frame.py#L61-L71
agoragames/haigha
haigha/transports/event_transport.py
EventTransport.connect
def connect(self, (host, port)): ''' Connect assuming a host and port tuple. Implemented as non-blocking, and will close the transport if there's an error ''' self._host = "%s:%s" % (host, port) self._sock = EventSocket( read_cb=self._sock_read_cb, ...
python
def connect(self, (host, port)): ''' Connect assuming a host and port tuple. Implemented as non-blocking, and will close the transport if there's an error ''' self._host = "%s:%s" % (host, port) self._sock = EventSocket( read_cb=self._sock_read_cb, ...
[ "def", "connect", "(", "self", ",", "(", "host", ",", "port", ")", ")", ":", "self", ".", "_host", "=", "\"%s:%s\"", "%", "(", "host", ",", "port", ")", "self", ".", "_sock", "=", "EventSocket", "(", "read_cb", "=", "self", ".", "_sock_read_cb", ",...
Connect assuming a host and port tuple. Implemented as non-blocking, and will close the transport if there's an error
[ "Connect", "assuming", "a", "host", "and", "port", "tuple", ".", "Implemented", "as", "non", "-", "blocking", "and", "will", "close", "the", "transport", "if", "there", "s", "an", "error" ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/event_transport.py#L49-L68
agoragames/haigha
haigha/transports/event_transport.py
EventTransport.read
def read(self, timeout=None): ''' Read from the transport. If no data is available, should return None. The timeout is ignored as this returns only data that has already been buffered locally. ''' # NOTE: copying over this comment from Connection, because there is ...
python
def read(self, timeout=None): ''' Read from the transport. If no data is available, should return None. The timeout is ignored as this returns only data that has already been buffered locally. ''' # NOTE: copying over this comment from Connection, because there is ...
[ "def", "read", "(", "self", ",", "timeout", "=", "None", ")", ":", "# NOTE: copying over this comment from Connection, because there is", "# knowledge captured here, even if the details are stale", "# Because of the timer callback to dataRead when we re-buffered,", "# there's a chance that...
Read from the transport. If no data is available, should return None. The timeout is ignored as this returns only data that has already been buffered locally.
[ "Read", "from", "the", "transport", ".", "If", "no", "data", "is", "available", "should", "return", "None", ".", "The", "timeout", "is", "ignored", "as", "this", "returns", "only", "data", "that", "has", "already", "been", "buffered", "locally", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/event_transport.py#L70-L99
agoragames/haigha
haigha/transports/event_transport.py
EventTransport.disconnect
def disconnect(self): ''' Disconnect from the transport. Typically socket.close(). This call is welcome to raise exceptions, which the Connection will catch. The transport is encouraged to allow for any pending writes to complete before closing the socket. ''' if...
python
def disconnect(self): ''' Disconnect from the transport. Typically socket.close(). This call is welcome to raise exceptions, which the Connection will catch. The transport is encouraged to allow for any pending writes to complete before closing the socket. ''' if...
[ "def", "disconnect", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_sock'", ")", ":", "return", "# TODO: If there are bytes left on the output, queue the close for", "# later.", "self", ".", "_sock", ".", "close_cb", "=", "None", "self", ".", ...
Disconnect from the transport. Typically socket.close(). This call is welcome to raise exceptions, which the Connection will catch. The transport is encouraged to allow for any pending writes to complete before closing the socket.
[ "Disconnect", "from", "the", "transport", ".", "Typically", "socket", ".", "close", "()", ".", "This", "call", "is", "welcome", "to", "raise", "exceptions", "which", "the", "Connection", "will", "catch", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/event_transport.py#L117-L131
agoragames/haigha
haigha/frames/header_frame.py
HeaderFrame.parse
def parse(self, channel_id, payload): ''' Parse a header frame for a channel given a Reader payload. ''' class_id = payload.read_short() weight = payload.read_short() size = payload.read_longlong() properties = {} # The AMQP spec is overly-complex when it...
python
def parse(self, channel_id, payload): ''' Parse a header frame for a channel given a Reader payload. ''' class_id = payload.read_short() weight = payload.read_short() size = payload.read_longlong() properties = {} # The AMQP spec is overly-complex when it...
[ "def", "parse", "(", "self", ",", "channel_id", ",", "payload", ")", ":", "class_id", "=", "payload", ".", "read_short", "(", ")", "weight", "=", "payload", ".", "read_short", "(", ")", "size", "=", "payload", ".", "read_longlong", "(", ")", "properties"...
Parse a header frame for a channel given a Reader payload.
[ "Parse", "a", "header", "frame", "for", "a", "channel", "given", "a", "Reader", "payload", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/header_frame.py#L71-L115
agoragames/haigha
haigha/frames/header_frame.py
HeaderFrame.write_frame
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()) writer.write_short(self.channel_id) # Track the position where we're going to write the total length # of the frame arguments...
python
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()) writer.write_short(self.channel_id) # Track the position where we're going to write the total length # of the frame arguments...
[ "def", "write_frame", "(", "self", ",", "buf", ")", ":", "writer", "=", "Writer", "(", "buf", ")", "writer", ".", "write_octet", "(", "self", ".", "type", "(", ")", ")", "writer", ".", "write_short", "(", "self", ".", "channel_id", ")", "# Track the po...
Write the frame into an existing buffer.
[ "Write", "the", "frame", "into", "an", "existing", "buffer", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/header_frame.py#L129-L188
agoragames/haigha
haigha/frames/frame.py
Frame.read_frames
def read_frames(cls, reader): ''' Read one or more frames from an IO stream. Buffer must support file object interface. After reading, caller will need to check if there are bytes remaining in the stream. If there are, then that implies that there is one or more incompl...
python
def read_frames(cls, reader): ''' Read one or more frames from an IO stream. Buffer must support file object interface. After reading, caller will need to check if there are bytes remaining in the stream. If there are, then that implies that there is one or more incompl...
[ "def", "read_frames", "(", "cls", ",", "reader", ")", ":", "rval", "=", "deque", "(", ")", "while", "True", ":", "frame_start_pos", "=", "reader", ".", "tell", "(", ")", "try", ":", "frame", "=", "Frame", ".", "_read_frame", "(", "reader", ")", "exce...
Read one or more frames from an IO stream. Buffer must support file object interface. After reading, caller will need to check if there are bytes remaining in the stream. If there are, then that implies that there is one or more incomplete frames and more data needs to be read. The po...
[ "Read", "one", "or", "more", "frames", "from", "an", "IO", "stream", ".", "Buffer", "must", "support", "file", "object", "interface", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/frame.py#L49-L84
agoragames/haigha
haigha/frames/frame.py
Frame._read_frame
def _read_frame(cls, reader): ''' Read a single frame from a Reader. Will return None if there is an incomplete frame in the stream. Raise MissingFooter if there's a problem reading the footer byte. ''' frame_type = reader.read_octet() channel_id = reader.read_s...
python
def _read_frame(cls, reader): ''' Read a single frame from a Reader. Will return None if there is an incomplete frame in the stream. Raise MissingFooter if there's a problem reading the footer byte. ''' frame_type = reader.read_octet() channel_id = reader.read_s...
[ "def", "_read_frame", "(", "cls", ",", "reader", ")", ":", "frame_type", "=", "reader", ".", "read_octet", "(", ")", "channel_id", "=", "reader", ".", "read_short", "(", ")", "size", "=", "reader", ".", "read_long", "(", ")", "payload", "=", "Reader", ...
Read a single frame from a Reader. Will return None if there is an incomplete frame in the stream. Raise MissingFooter if there's a problem reading the footer byte.
[ "Read", "a", "single", "frame", "from", "a", "Reader", ".", "Will", "return", "None", "if", "there", "is", "an", "incomplete", "frame", "in", "the", "stream", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/frame.py#L87-L112
agoragames/haigha
haigha/connections/rabbit_connection.py
RabbitExchangeClass.unbind
def unbind(self, exchange, source, routing_key='', nowait=True, arguments={}, ticket=None, cb=None): ''' Unbind an exchange from another. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket)...
python
def unbind(self, exchange, source, routing_key='', nowait=True, arguments={}, ticket=None, cb=None): ''' Unbind an exchange from another. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket)...
[ "def", "unbind", "(", "self", ",", "exchange", ",", "source", ",", "routing_key", "=", "''", ",", "nowait", "=", "True", ",", "arguments", "=", "{", "}", ",", "ticket", "=", "None", ",", "cb", "=", "None", ")", ":", "nowait", "=", "nowait", "and", ...
Unbind an exchange from another.
[ "Unbind", "an", "exchange", "from", "another", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L117-L135
agoragames/haigha
haigha/connections/rabbit_connection.py
RabbitBasicClass._cleanup
def _cleanup(self): ''' Cleanup all the local data. ''' self._ack_listener = None self._nack_listener = None self._broker_cancel_cb_map = None super(RabbitBasicClass, self)._cleanup()
python
def _cleanup(self): ''' Cleanup all the local data. ''' self._ack_listener = None self._nack_listener = None self._broker_cancel_cb_map = None super(RabbitBasicClass, self)._cleanup()
[ "def", "_cleanup", "(", "self", ")", ":", "self", ".", "_ack_listener", "=", "None", "self", ".", "_nack_listener", "=", "None", "self", ".", "_broker_cancel_cb_map", "=", "None", "super", "(", "RabbitBasicClass", ",", "self", ")", ".", "_cleanup", "(", ")...
Cleanup all the local data.
[ "Cleanup", "all", "the", "local", "data", "." ]
train
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L165-L172