partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
BaseBlob.pos_tags
Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'ADP'), ('eight', 'NUM'), ("o'clock", 'NOUN'), ('on', 'ADP'), ('Thursday', 'NOUN'), ('morning', 'NOUN')] :rtype: list of tuples
polyglot/text.py
def pos_tags(self): """Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'ADP'), ('eight', 'NUM'), ("o'clock", 'NOUN'), ('on', 'ADP'), ('Thursday', 'NOUN'), ('morning', 'NOUN')] :rtype: list of tuples """ tagged_words = [] for word,t in self.pos_tagge...
def pos_tags(self): """Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'ADP'), ('eight', 'NUM'), ("o'clock", 'NOUN'), ('on', 'ADP'), ('Thursday', 'NOUN'), ('morning', 'NOUN')] :rtype: list of tuples """ tagged_words = [] for word,t in self.pos_tagge...
[ "Returns", "an", "list", "of", "tuples", "of", "the", "form", "(", "word", "POS", "tag", ")", ".", "Example", ":", "::", "[", "(", "At", "ADP", ")", "(", "eight", "NUM", ")", "(", "o", "clock", "NOUN", ")", "(", "on", "ADP", ")", "(", "Thursday...
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L149-L161
[ "def", "pos_tags", "(", "self", ")", ":", "tagged_words", "=", "[", "]", "for", "word", ",", "t", "in", "self", ".", "pos_tagger", ".", "annotate", "(", "self", ".", "words", ")", ":", "word", ".", "pos_tag", "=", "t", "tagged_words", ".", "append", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.transfer_pos_tags
Returns an list of tuples of the form (word, POS tag), using transfer POS tagger
polyglot/text.py
def transfer_pos_tags(self): """Returns an list of tuples of the form (word, POS tag), using transfer POS tagger""" tagged_words = [] for word,t in self.transfer_pos_tagger.annotate(self.words): word.pos_tag = t tagged_words.append((word, t)) return tagged_words
def transfer_pos_tags(self): """Returns an list of tuples of the form (word, POS tag), using transfer POS tagger""" tagged_words = [] for word,t in self.transfer_pos_tagger.annotate(self.words): word.pos_tag = t tagged_words.append((word, t)) return tagged_words
[ "Returns", "an", "list", "of", "tuples", "of", "the", "form", "(", "word", "POS", "tag", ")", "using", "transfer", "POS", "tagger" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L164-L170
[ "def", "transfer_pos_tags", "(", "self", ")", ":", "tagged_words", "=", "[", "]", "for", "word", ",", "t", "in", "self", ".", "transfer_pos_tagger", ".", "annotate", "(", "self", ".", "words", ")", ":", "word", ".", "pos_tag", "=", "t", "tagged_words", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.word_counts
Dictionary of word frequencies in this text.
polyglot/text.py
def word_counts(self): """Dictionary of word frequencies in this text. """ counts = defaultdict(int) for word in self.words: counts[word] += 1 return counts
def word_counts(self): """Dictionary of word frequencies in this text. """ counts = defaultdict(int) for word in self.words: counts[word] += 1 return counts
[ "Dictionary", "of", "word", "frequencies", "in", "this", "text", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L173-L179
[ "def", "word_counts", "(", "self", ")", ":", "counts", "=", "defaultdict", "(", "int", ")", "for", "word", "in", "self", ".", "words", ":", "counts", "[", "word", "]", "+=", "1", "return", "counts" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.np_counts
Dictionary of noun phrase frequencies in this text.
polyglot/text.py
def np_counts(self): """Dictionary of noun phrase frequencies in this text. """ counts = defaultdict(int) for phrase in self.noun_phrases: counts[phrase] += 1 return counts
def np_counts(self): """Dictionary of noun phrase frequencies in this text. """ counts = defaultdict(int) for phrase in self.noun_phrases: counts[phrase] += 1 return counts
[ "Dictionary", "of", "noun", "phrase", "frequencies", "in", "this", "text", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L182-L188
[ "def", "np_counts", "(", "self", ")", ":", "counts", "=", "defaultdict", "(", "int", ")", "for", "phrase", "in", "self", ".", "noun_phrases", ":", "counts", "[", "phrase", "]", "+=", "1", "return", "counts" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.ngrams
Return a list of n-grams (tuples of n successive words) for this blob. :rtype: List of :class:`WordLists <WordList>`
polyglot/text.py
def ngrams(self, n=3): """Return a list of n-grams (tuples of n successive words) for this blob. :rtype: List of :class:`WordLists <WordList>` """ if n <= 0: return [] grams = [WordList(self.words[i:i+n], parent=self) for i in range(len(self.words) - n + 1)] r...
def ngrams(self, n=3): """Return a list of n-grams (tuples of n successive words) for this blob. :rtype: List of :class:`WordLists <WordList>` """ if n <= 0: return [] grams = [WordList(self.words[i:i+n], parent=self) for i in range(len(self.words) - n + 1)] r...
[ "Return", "a", "list", "of", "n", "-", "grams", "(", "tuples", "of", "n", "successive", "words", ")", "for", "this", "blob", ".", ":", "rtype", ":", "List", "of", ":", "class", ":", "WordLists", "<WordList", ">" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L190-L199
[ "def", "ngrams", "(", "self", ",", "n", "=", "3", ")", ":", "if", "n", "<=", "0", ":", "return", "[", "]", "grams", "=", "[", "WordList", "(", "self", ".", "words", "[", "i", ":", "i", "+", "n", "]", ",", "parent", "=", "self", ")", "for", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.correct
Attempt to correct the spelling of a blob. .. versionadded:: 0.6.0 :rtype: :class:`BaseBlob <BaseBlob>`
polyglot/text.py
def correct(self): """Attempt to correct the spelling of a blob. .. versionadded:: 0.6.0 :rtype: :class:`BaseBlob <BaseBlob>` """ # regex matches: contraction or word or punctuation or whitespace tokens = nltk.tokenize.regexp_tokenize(self.raw, "\w*('\w*)+|\w+|[^\w\s]|\s") corrected = (Word(...
def correct(self): """Attempt to correct the spelling of a blob. .. versionadded:: 0.6.0 :rtype: :class:`BaseBlob <BaseBlob>` """ # regex matches: contraction or word or punctuation or whitespace tokens = nltk.tokenize.regexp_tokenize(self.raw, "\w*('\w*)+|\w+|[^\w\s]|\s") corrected = (Word(...
[ "Attempt", "to", "correct", "the", "spelling", "of", "a", "blob", ".", "..", "versionadded", "::", "0", ".", "6", ".", "0", ":", "rtype", ":", ":", "class", ":", "BaseBlob", "<BaseBlob", ">" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L212-L221
[ "def", "correct", "(", "self", ")", ":", "# regex matches: contraction or word or punctuation or whitespace", "tokens", "=", "nltk", ".", "tokenize", ".", "regexp_tokenize", "(", "self", ".", "raw", ",", "\"\\w*('\\w*)+|\\w+|[^\\w\\s]|\\s\"", ")", "corrected", "=", "(",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.split
Behaves like the built-in str.split() except returns a WordList. :rtype: :class:`WordList <WordList>`
polyglot/text.py
def split(self, sep=None, maxsplit=sys.maxsize): """Behaves like the built-in str.split() except returns a WordList. :rtype: :class:`WordList <WordList>` """ return WordList(self._strkey().split(sep, maxsplit), parent=self)
def split(self, sep=None, maxsplit=sys.maxsize): """Behaves like the built-in str.split() except returns a WordList. :rtype: :class:`WordList <WordList>` """ return WordList(self._strkey().split(sep, maxsplit), parent=self)
[ "Behaves", "like", "the", "built", "-", "in", "str", ".", "split", "()", "except", "returns", "a", "WordList", ".", ":", "rtype", ":", ":", "class", ":", "WordList", "<WordList", ">" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L250-L255
[ "def", "split", "(", "self", ",", "sep", "=", "None", ",", "maxsplit", "=", "sys", ".", "maxsize", ")", ":", "return", "WordList", "(", "self", ".", "_strkey", "(", ")", ".", "split", "(", "sep", ",", "maxsplit", ")", ",", "parent", "=", "self", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Word.transliterate
Transliterate the string to the target language.
polyglot/text.py
def transliterate(self, target_language="en"): """Transliterate the string to the target language.""" t = Transliterator(source_lang=self.language, target_lang=target_language) return t.transliterate(self.string)
def transliterate(self, target_language="en"): """Transliterate the string to the target language.""" t = Transliterator(source_lang=self.language, target_lang=target_language) return t.transliterate(self.string)
[ "Transliterate", "the", "string", "to", "the", "target", "language", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L327-L331
[ "def", "transliterate", "(", "self", ",", "target_language", "=", "\"en\"", ")", ":", "t", "=", "Transliterator", "(", "source_lang", "=", "self", ".", "language", ",", "target_lang", "=", "target_language", ")", "return", "t", ".", "transliterate", "(", "se...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
WordList.count
Get the count of a word or phrase `s` within this WordList. :param strg: The string to count. :param case_sensitive: A boolean, whether or not the search is case-sensitive.
polyglot/text.py
def count(self, strg, case_sensitive=False, *args, **kwargs): """Get the count of a word or phrase `s` within this WordList. :param strg: The string to count. :param case_sensitive: A boolean, whether or not the search is case-sensitive. """ if not case_sensitive: return [word.lower() for wo...
def count(self, strg, case_sensitive=False, *args, **kwargs): """Get the count of a word or phrase `s` within this WordList. :param strg: The string to count. :param case_sensitive: A boolean, whether or not the search is case-sensitive. """ if not case_sensitive: return [word.lower() for wo...
[ "Get", "the", "count", "of", "a", "word", "or", "phrase", "s", "within", "this", "WordList", ".", ":", "param", "strg", ":", "The", "string", "to", "count", ".", ":", "param", "case_sensitive", ":", "A", "boolean", "whether", "or", "not", "the", "searc...
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L367-L375
[ "def", "count", "(", "self", ",", "strg", ",", "case_sensitive", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "case_sensitive", ":", "return", "[", "word", ".", "lower", "(", ")", "for", "word", "in", "self", "]",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
WordList.append
Append an object to end. If the object is a string, appends a :class:`Word <Word>` object.
polyglot/text.py
def append(self, obj): """Append an object to end. If the object is a string, appends a :class:`Word <Word>` object. """ if isinstance(obj, basestring): return self._collection.append(Word(obj)) else: return self._collection.append(obj)
def append(self, obj): """Append an object to end. If the object is a string, appends a :class:`Word <Word>` object. """ if isinstance(obj, basestring): return self._collection.append(Word(obj)) else: return self._collection.append(obj)
[ "Append", "an", "object", "to", "end", ".", "If", "the", "object", "is", "a", "string", "appends", "a", ":", "class", ":", "Word", "<Word", ">", "object", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L377-L384
[ "def", "append", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "basestring", ")", ":", "return", "self", ".", "_collection", ".", "append", "(", "Word", "(", "obj", ")", ")", "else", ":", "return", "self", ".", "_collection"...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
WordList.extend
Extend WordList by appending elements from ``iterable``. If an element is a string, appends a :class:`Word <Word>` object.
polyglot/text.py
def extend(self, iterable): """Extend WordList by appending elements from ``iterable``. If an element is a string, appends a :class:`Word <Word>` object. """ [self._collection.append(Word(e) if isinstance(e, basestring) else e) for e in iterable] return self
def extend(self, iterable): """Extend WordList by appending elements from ``iterable``. If an element is a string, appends a :class:`Word <Word>` object. """ [self._collection.append(Word(e) if isinstance(e, basestring) else e) for e in iterable] return self
[ "Extend", "WordList", "by", "appending", "elements", "from", "iterable", ".", "If", "an", "element", "is", "a", "string", "appends", "a", ":", "class", ":", "Word", "<Word", ">", "object", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L386-L392
[ "def", "extend", "(", "self", ",", "iterable", ")", ":", "[", "self", ".", "_collection", ".", "append", "(", "Word", "(", "e", ")", "if", "isinstance", "(", "e", ",", "basestring", ")", "else", "e", ")", "for", "e", "in", "iterable", "]", "return"...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Chunk._sentiment
Calculates the sentiment of an entity as it appears in text.
polyglot/text.py
def _sentiment(self, distance=True): """Calculates the sentiment of an entity as it appears in text.""" sum_pos = 0 sum_neg = 0 text = self.parent entity_positions = range(self.start, self.end) non_entity_positions = set(range(len(text.words))).difference(entity_positions) if not distance: ...
def _sentiment(self, distance=True): """Calculates the sentiment of an entity as it appears in text.""" sum_pos = 0 sum_neg = 0 text = self.parent entity_positions = range(self.start, self.end) non_entity_positions = set(range(len(text.words))).difference(entity_positions) if not distance: ...
[ "Calculates", "the", "sentiment", "of", "an", "entity", "as", "it", "appears", "in", "text", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L441-L463
[ "def", "_sentiment", "(", "self", ",", "distance", "=", "True", ")", ":", "sum_pos", "=", "0", "sum_neg", "=", "0", "text", "=", "self", ".", "parent", "entity_positions", "=", "range", "(", "self", ".", "start", ",", "self", ".", "end", ")", "non_en...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Sentence.dict
The dict representation of this sentence.
polyglot/text.py
def dict(self): '''The dict representation of this sentence.''' return { 'raw': self.raw, 'start': self.start, 'end': self.end, 'entities': [(e.tag, e) for e in self.entities], 'tokens': self.tokens, 'words': self.words, 'pos_tags': self.pos_tags, ...
def dict(self): '''The dict representation of this sentence.''' return { 'raw': self.raw, 'start': self.start, 'end': self.end, 'entities': [(e.tag, e) for e in self.entities], 'tokens': self.tokens, 'words': self.words, 'pos_tags': self.pos_tags, ...
[ "The", "dict", "representation", "of", "this", "sentence", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L484-L496
[ "def", "dict", "(", "self", ")", ":", "return", "{", "'raw'", ":", "self", ".", "raw", ",", "'start'", ":", "self", ".", "start", ",", "'end'", ":", "self", ".", "end", ",", "'entities'", ":", "[", "(", "e", ".", "tag", ",", "e", ")", "for", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Text.to_json
Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1
polyglot/text.py
def to_json(self, *args, **kwargs): '''Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 ''' try: import ujson as json except ImportError: import json return json.dumps(self.serialized, *args, **kwargs)
def to_json(self, *args, **kwargs): '''Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 ''' try: import ujson as json except ImportError: import json return json.dumps(self.serialized, *args, **kwargs)
[ "Return", "a", "json", "representation", "(", "str", ")", "of", "this", "blob", ".", "Takes", "the", "same", "arguments", "as", "json", ".", "dumps", ".", "..", "versionadded", "::", "0", ".", "5", ".", "1" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L529-L538
[ "def", "to_json", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "import", "ujson", "as", "json", "except", "ImportError", ":", "import", "json", "return", "json", ".", "dumps", "(", "self", ".", "serialized", ",", "*",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Text._create_sentence_objects
Returns a list of Sentence objects from the raw text.
polyglot/text.py
def _create_sentence_objects(self): '''Returns a list of Sentence objects from the raw text. ''' sentence_objects = [] sent_tokenizer = SentenceTokenizer(locale=self.language.code) seq = Sequence(self.raw) seq = sent_tokenizer.transform(seq) for start_index, end_index in zip(seq.idx[:-1], se...
def _create_sentence_objects(self): '''Returns a list of Sentence objects from the raw text. ''' sentence_objects = [] sent_tokenizer = SentenceTokenizer(locale=self.language.code) seq = Sequence(self.raw) seq = sent_tokenizer.transform(seq) for start_index, end_index in zip(seq.idx[:-1], se...
[ "Returns", "a", "list", "of", "Sentence", "objects", "from", "the", "raw", "text", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L549-L563
[ "def", "_create_sentence_objects", "(", "self", ")", ":", "sentence_objects", "=", "[", "]", "sent_tokenizer", "=", "SentenceTokenizer", "(", "locale", "=", "self", ".", "language", ".", "code", ")", "seq", "=", "Sequence", "(", "self", ".", "raw", ")", "s...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Detector.detect
Decide which language is used to write the text. The method tries first to detect the language with high reliability. If that is not possible, the method switches to best effort strategy. Args: text (string): A snippet of text, the longer it is the more reliable we can detect t...
polyglot/detect/base.py
def detect(self, text): """Decide which language is used to write the text. The method tries first to detect the language with high reliability. If that is not possible, the method switches to best effort strategy. Args: text (string): A snippet of text, the longer it is the more reliable we ...
def detect(self, text): """Decide which language is used to write the text. The method tries first to detect the language with high reliability. If that is not possible, the method switches to best effort strategy. Args: text (string): A snippet of text, the longer it is the more reliable we ...
[ "Decide", "which", "language", "is", "used", "to", "write", "the", "text", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/detect/base.py#L72-L98
[ "def", "detect", "(", "self", ",", "text", ")", ":", "t", "=", "text", ".", "encode", "(", "\"utf-8\"", ")", "reliable", ",", "index", ",", "top_3_choices", "=", "cld2", ".", "detect", "(", "t", ",", "bestEffort", "=", "False", ")", "if", "not", "r...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
locate_resource
Return filename that contains specific language resource name. Args: name (string): Name of the resource. lang (string): language code to be loaded.
polyglot/load.py
def locate_resource(name, lang, filter=None): """Return filename that contains specific language resource name. Args: name (string): Name of the resource. lang (string): language code to be loaded. """ task_dir = resource_dir.get(name, name) package_id = u"{}.{}".format(task_dir, lang) p = path.joi...
def locate_resource(name, lang, filter=None): """Return filename that contains specific language resource name. Args: name (string): Name of the resource. lang (string): language code to be loaded. """ task_dir = resource_dir.get(name, name) package_id = u"{}.{}".format(task_dir, lang) p = path.joi...
[ "Return", "filename", "that", "contains", "specific", "language", "resource", "name", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/load.py#L32-L47
[ "def", "locate_resource", "(", "name", ",", "lang", ",", "filter", "=", "None", ")", ":", "task_dir", "=", "resource_dir", ".", "get", "(", "name", ",", "name", ")", "package_id", "=", "u\"{}.{}\"", ".", "format", "(", "task_dir", ",", "lang", ")", "p"...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
load_embeddings
Return a word embeddings object for `lang` and of type `type` Args: lang (string): language code. task (string): parameters that define task. type (string): skipgram, cw, cbow ... noramlized (boolean): returns noramlized word embeddings vectors.
polyglot/load.py
def load_embeddings(lang="en", task="embeddings", type="cw", normalize=False): """Return a word embeddings object for `lang` and of type `type` Args: lang (string): language code. task (string): parameters that define task. type (string): skipgram, cw, cbow ... noramlized (boolean): returns noramli...
def load_embeddings(lang="en", task="embeddings", type="cw", normalize=False): """Return a word embeddings object for `lang` and of type `type` Args: lang (string): language code. task (string): parameters that define task. type (string): skipgram, cw, cbow ... noramlized (boolean): returns noramli...
[ "Return", "a", "word", "embeddings", "object", "for", "lang", "and", "of", "type", "type" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/load.py#L51-L72
[ "def", "load_embeddings", "(", "lang", "=", "\"en\"", ",", "task", "=", "\"embeddings\"", ",", "type", "=", "\"cw\"", ",", "normalize", "=", "False", ")", ":", "src_dir", "=", "\"_\"", ".", "join", "(", "(", "type", ",", "task", ")", ")", "if", "type...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
load_vocabulary
Return a CountedVocabulary object. Args: lang (string): language code. type (string): wiki,...
polyglot/load.py
def load_vocabulary(lang="en", type="wiki"): """Return a CountedVocabulary object. Args: lang (string): language code. type (string): wiki,... """ src_dir = "{}_vocab".format(type) p = locate_resource(src_dir, lang) return CountedVocabulary.from_vocabfile(p)
def load_vocabulary(lang="en", type="wiki"): """Return a CountedVocabulary object. Args: lang (string): language code. type (string): wiki,... """ src_dir = "{}_vocab".format(type) p = locate_resource(src_dir, lang) return CountedVocabulary.from_vocabfile(p)
[ "Return", "a", "CountedVocabulary", "object", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/load.py#L76-L85
[ "def", "load_vocabulary", "(", "lang", "=", "\"en\"", ",", "type", "=", "\"wiki\"", ")", ":", "src_dir", "=", "\"{}_vocab\"", ".", "format", "(", "type", ")", "p", "=", "locate_resource", "(", "src_dir", ",", "lang", ")", "return", "CountedVocabulary", "."...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
load_ner_model
Return a named entity extractor parameters for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used.
polyglot/load.py
def load_ner_model(lang="en", version="2"): """Return a named entity extractor parameters for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "ner{}".format(version) p = locate_resource(src_dir, lang) fh = _op...
def load_ner_model(lang="en", version="2"): """Return a named entity extractor parameters for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "ner{}".format(version) p = locate_resource(src_dir, lang) fh = _op...
[ "Return", "a", "named", "entity", "extractor", "parameters", "for", "lang", "and", "of", "version", "version" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/load.py#L89-L103
[ "def", "load_ner_model", "(", "lang", "=", "\"en\"", ",", "version", "=", "\"2\"", ")", ":", "src_dir", "=", "\"ner{}\"", ".", "format", "(", "version", ")", "p", "=", "locate_resource", "(", "src_dir", ",", "lang", ")", "fh", "=", "_open", "(", "p", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
load_pos_model
Return a part of speech tagger parameters for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used.
polyglot/load.py
def load_pos_model(lang="en", version="2"): """Return a part of speech tagger parameters for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "pos{}".format(version) p = locate_resource(src_dir, lang) fh = _ope...
def load_pos_model(lang="en", version="2"): """Return a part of speech tagger parameters for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "pos{}".format(version) p = locate_resource(src_dir, lang) fh = _ope...
[ "Return", "a", "part", "of", "speech", "tagger", "parameters", "for", "lang", "and", "of", "version", "version" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/load.py#L107-L117
[ "def", "load_pos_model", "(", "lang", "=", "\"en\"", ",", "version", "=", "\"2\"", ")", ":", "src_dir", "=", "\"pos{}\"", ".", "format", "(", "version", ")", "p", "=", "locate_resource", "(", "src_dir", ",", "lang", ")", "fh", "=", "_open", "(", "p", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
load_morfessor_model
Return a morfessor model for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used.
polyglot/load.py
def load_morfessor_model(lang="en", version="2"): """Return a morfessor model for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "morph{}".format(version) p = locate_resource(src_dir, lang) file_handler = _op...
def load_morfessor_model(lang="en", version="2"): """Return a morfessor model for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "morph{}".format(version) p = locate_resource(src_dir, lang) file_handler = _op...
[ "Return", "a", "morfessor", "model", "for", "lang", "and", "of", "version", "version" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/load.py#L128-L144
[ "def", "load_morfessor_model", "(", "lang", "=", "\"en\"", ",", "version", "=", "\"2\"", ")", ":", "src_dir", "=", "\"morph{}\"", ".", "format", "(", "version", ")", "p", "=", "locate_resource", "(", "src_dir", ",", "lang", ")", "file_handler", "=", "_open...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
load_transliteration_table
Return a morfessor model for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used.
polyglot/load.py
def load_transliteration_table(lang="en", version="2"): """Return a morfessor model for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "transliteration{}".format(version) p = locate_resource(src_dir, lang) fi...
def load_transliteration_table(lang="en", version="2"): """Return a morfessor model for `lang` and of version `version` Args: lang (string): language code. version (string): version of the parameters to be used. """ src_dir = "transliteration{}".format(version) p = locate_resource(src_dir, lang) fi...
[ "Return", "a", "morfessor", "model", "for", "lang", "and", "of", "version", "version" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/load.py#L148-L158
[ "def", "load_transliteration_table", "(", "lang", "=", "\"en\"", ",", "version", "=", "\"2\"", ")", ":", "src_dir", "=", "\"transliteration{}\"", ".", "format", "(", "version", ")", "p", "=", "locate_resource", "(", "src_dir", ",", "lang", ")", "file_handler",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
vocab_counter
Calculate the vocabulary.
polyglot/__main__.py
def vocab_counter(args): """Calculate the vocabulary.""" if isinstance(args.input, TextFiles): v = CountedVocabulary.from_textfiles(args.input, workers=args.workers) else: v = CountedVocabulary.from_textfile(args.input, workers=args.workers) if args.min_count > 1: v = v.min_count(args.min_count) ...
def vocab_counter(args): """Calculate the vocabulary.""" if isinstance(args.input, TextFiles): v = CountedVocabulary.from_textfiles(args.input, workers=args.workers) else: v = CountedVocabulary.from_textfile(args.input, workers=args.workers) if args.min_count > 1: v = v.min_count(args.min_count) ...
[ "Calculate", "the", "vocabulary", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L39-L49
[ "def", "vocab_counter", "(", "args", ")", ":", "if", "isinstance", "(", "args", ".", "input", ",", "TextFiles", ")", ":", "v", "=", "CountedVocabulary", ".", "from_textfiles", "(", "args", ".", "input", ",", "workers", "=", "args", ".", "workers", ")", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
detect
Detect the language of each line.
polyglot/__main__.py
def detect(args): """ Detect the language of each line.""" for l in args.input: if l.strip(): _print("{:<20}{}".format(Detector(l).language.name, l.strip()))
def detect(args): """ Detect the language of each line.""" for l in args.input: if l.strip(): _print("{:<20}{}".format(Detector(l).language.name, l.strip()))
[ "Detect", "the", "language", "of", "each", "line", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L52-L56
[ "def", "detect", "(", "args", ")", ":", "for", "l", "in", "args", ".", "input", ":", "if", "l", ".", "strip", "(", ")", ":", "_print", "(", "\"{:<20}{}\"", ".", "format", "(", "Detector", "(", "l", ")", ".", "language", ".", "name", ",", "l", "...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
tag
Chunk named entities.
polyglot/__main__.py
def tag(tagger, args): """Chunk named entities.""" for l in args.input: words = l.strip().split() line_annotations = [u"{:<16}{:<5}".format(w,p) for w, p in tagger.annotate(words)] _print(u"\n".join(line_annotations)) _print(u"")
def tag(tagger, args): """Chunk named entities.""" for l in args.input: words = l.strip().split() line_annotations = [u"{:<16}{:<5}".format(w,p) for w, p in tagger.annotate(words)] _print(u"\n".join(line_annotations)) _print(u"")
[ "Chunk", "named", "entities", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L59-L65
[ "def", "tag", "(", "tagger", ",", "args", ")", ":", "for", "l", "in", "args", ".", "input", ":", "words", "=", "l", ".", "strip", "(", ")", ".", "split", "(", ")", "line_annotations", "=", "[", "u\"{:<16}{:<5}\"", ".", "format", "(", "w", ",", "p...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
transliterate
Transliterate words according to the target language.
polyglot/__main__.py
def transliterate(args): """Transliterate words according to the target language.""" t = Transliterator(source_lang=args.lang, target_lang=args.target) for l in args.input: words = l.strip().split() line_annotations = [u"{:<16}{:<16}".format(w, t.transliterate(w)) for w in words] ...
def transliterate(args): """Transliterate words according to the target language.""" t = Transliterator(source_lang=args.lang, target_lang=args.target) for l in args.input: words = l.strip().split() line_annotations = [u"{:<16}{:<16}".format(w, t.transliterate(w)) for w in words] ...
[ "Transliterate", "words", "according", "to", "the", "target", "language", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L68-L76
[ "def", "transliterate", "(", "args", ")", ":", "t", "=", "Transliterator", "(", "source_lang", "=", "args", ".", "lang", ",", "target_lang", "=", "args", ".", "target", ")", "for", "l", "in", "args", ".", "input", ":", "words", "=", "l", ".", "strip"...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
morphemes
Segment words according to their morphemes.
polyglot/__main__.py
def morphemes(args): """Segment words according to their morphemes.""" morfessor = load_morfessor_model(lang=args.lang) for l in args.input: words = l.strip().split() morphemes = [(w, u"_".join(morfessor.viterbi_segment(w)[0])) for w in words] line_annotations = [u"{:<16}{:<5}".format(w,p) for w, p in...
def morphemes(args): """Segment words according to their morphemes.""" morfessor = load_morfessor_model(lang=args.lang) for l in args.input: words = l.strip().split() morphemes = [(w, u"_".join(morfessor.viterbi_segment(w)[0])) for w in words] line_annotations = [u"{:<16}{:<5}".format(w,p) for w, p in...
[ "Segment", "words", "according", "to", "their", "morphemes", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L79-L87
[ "def", "morphemes", "(", "args", ")", ":", "morfessor", "=", "load_morfessor_model", "(", "lang", "=", "args", ".", "lang", ")", "for", "l", "in", "args", ".", "input", ":", "words", "=", "l", ".", "strip", "(", ")", ".", "split", "(", ")", "morphe...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
ner_chunk
Chunk named entities.
polyglot/__main__.py
def ner_chunk(args): """Chunk named entities.""" chunker = NEChunker(lang=args.lang) tag(chunker, args)
def ner_chunk(args): """Chunk named entities.""" chunker = NEChunker(lang=args.lang) tag(chunker, args)
[ "Chunk", "named", "entities", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L90-L93
[ "def", "ner_chunk", "(", "args", ")", ":", "chunker", "=", "NEChunker", "(", "lang", "=", "args", ".", "lang", ")", "tag", "(", "chunker", ",", "args", ")" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
pos_tag
Tag words with their part of speech.
polyglot/__main__.py
def pos_tag(args): """Tag words with their part of speech.""" tagger = POSTagger(lang=args.lang) tag(tagger, args)
def pos_tag(args): """Tag words with their part of speech.""" tagger = POSTagger(lang=args.lang) tag(tagger, args)
[ "Tag", "words", "with", "their", "part", "of", "speech", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L96-L99
[ "def", "pos_tag", "(", "args", ")", ":", "tagger", "=", "POSTagger", "(", "lang", "=", "args", ".", "lang", ")", "tag", "(", "tagger", ",", "args", ")" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
download
Download polyglot packages and models.
polyglot/__main__.py
def download(args): """ Download polyglot packages and models.""" downloader = Downloader(server_index_url = args.server_index_url) if args.packages: for pkg_id in args.packages: rv = downloader.download(info_or_id=unicode(pkg_id), download_dir=args.dir, quiet=args.quiet,...
def download(args): """ Download polyglot packages and models.""" downloader = Downloader(server_index_url = args.server_index_url) if args.packages: for pkg_id in args.packages: rv = downloader.download(info_or_id=unicode(pkg_id), download_dir=args.dir, quiet=args.quiet,...
[ "Download", "polyglot", "packages", "and", "models", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L108-L121
[ "def", "download", "(", "args", ")", ":", "downloader", "=", "Downloader", "(", "server_index_url", "=", "args", ".", "server_index_url", ")", "if", "args", ".", "packages", ":", "for", "pkg_id", "in", "args", ".", "packages", ":", "rv", "=", "downloader",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_open
Open file object given filenames, open files or even archives.
polyglot/utils.py
def _open(file_, mode='r'): """Open file object given filenames, open files or even archives.""" if isinstance(file_, string_types): _, ext = path.splitext(file_) if ext in {'.bz2', '.gz'}: s = tarfile.open(file_) return s.extractfile(s.next()) else: return open(file_, mode) return f...
def _open(file_, mode='r'): """Open file object given filenames, open files or even archives.""" if isinstance(file_, string_types): _, ext = path.splitext(file_) if ext in {'.bz2', '.gz'}: s = tarfile.open(file_) return s.extractfile(s.next()) else: return open(file_, mode) return f...
[ "Open", "file", "object", "given", "filenames", "open", "files", "or", "even", "archives", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/utils.py#L16-L25
[ "def", "_open", "(", "file_", ",", "mode", "=", "'r'", ")", ":", "if", "isinstance", "(", "file_", ",", "string_types", ")", ":", "_", ",", "ext", "=", "path", ".", "splitext", "(", "file_", ")", "if", "ext", "in", "{", "'.bz2'", ",", "'.gz'", "}...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_unpickle_method
Unpickle methods properly, including class methods.
polyglot/utils.py
def _unpickle_method(func_name, obj, cls): """Unpickle methods properly, including class methods.""" if obj is None: return cls.__dict__[func_name].__get__(obj, cls) for cls in cls.__mro__: try: func = cls.__dict__[func_name] except KeyError: pass else: break return func.__get...
def _unpickle_method(func_name, obj, cls): """Unpickle methods properly, including class methods.""" if obj is None: return cls.__dict__[func_name].__get__(obj, cls) for cls in cls.__mro__: try: func = cls.__dict__[func_name] except KeyError: pass else: break return func.__get...
[ "Unpickle", "methods", "properly", "including", "class", "methods", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/utils.py#L53-L65
[ "def", "_unpickle_method", "(", "func_name", ",", "obj", ",", "cls", ")", ":", "if", "obj", "is", "None", ":", "return", "cls", ".", "__dict__", "[", "func_name", "]", ".", "__get__", "(", "obj", ",", "cls", ")", "for", "cls", "in", "cls", ".", "__...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_linkcode_resolve
Determine a link to online source for a class/method/function This is called by sphinx.ext.linkcode An example with a long-untouched module that everyone has >>> _linkcode_resolve('py', {'module': 'tty', ... 'fullname': 'setraw'}, ... package='tty', ....
docs/sphinxext/github_link.py
def _linkcode_resolve(domain, info, package, url_fmt, revision): """Determine a link to online source for a class/method/function This is called by sphinx.ext.linkcode An example with a long-untouched module that everyone has >>> _linkcode_resolve('py', {'module': 'tty', ... ...
def _linkcode_resolve(domain, info, package, url_fmt, revision): """Determine a link to online source for a class/method/function This is called by sphinx.ext.linkcode An example with a long-untouched module that everyone has >>> _linkcode_resolve('py', {'module': 'tty', ... ...
[ "Determine", "a", "link", "to", "online", "source", "for", "a", "class", "/", "method", "/", "function" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/docs/sphinxext/github_link.py#L20-L71
[ "def", "_linkcode_resolve", "(", "domain", ",", "info", ",", "package", ",", "url_fmt", ",", "revision", ")", ":", "if", "revision", "is", "None", ":", "return", "if", "domain", "not", "in", "(", "'py'", ",", "'pyx'", ")", ":", "return", "if", "not", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
make_linkcode_resolve
Returns a linkcode_resolve function for the given URL format revision is a git commit reference (hash or name) package is the name of the root module of the package url_fmt is along the lines of ('https://github.com/USER/PROJECT/' 'blob/{revision}/{package}/' ...
docs/sphinxext/github_link.py
def make_linkcode_resolve(package, url_fmt): """Returns a linkcode_resolve function for the given URL format revision is a git commit reference (hash or name) package is the name of the root module of the package url_fmt is along the lines of ('https://github.com/USER/PROJECT/' ...
def make_linkcode_resolve(package, url_fmt): """Returns a linkcode_resolve function for the given URL format revision is a git commit reference (hash or name) package is the name of the root module of the package url_fmt is along the lines of ('https://github.com/USER/PROJECT/' ...
[ "Returns", "a", "linkcode_resolve", "function", "for", "the", "given", "URL", "format" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/docs/sphinxext/github_link.py#L74-L87
[ "def", "make_linkcode_resolve", "(", "package", ",", "url_fmt", ")", ":", "revision", "=", "_get_git_revision", "(", ")", "return", "partial", "(", "_linkcode_resolve", ",", "revision", "=", "revision", ",", "package", "=", "package", ",", "url_fmt", "=", "url...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
count
Counts the word frequences in a list of sentences. Note: This is a helper function for parallel execution of `Vocabulary.from_text` method.
polyglot/mapping/base.py
def count(lines): """ Counts the word frequences in a list of sentences. Note: This is a helper function for parallel execution of `Vocabulary.from_text` method. """ words = [w for l in lines for w in l.strip().split()] return Counter(words)
def count(lines): """ Counts the word frequences in a list of sentences. Note: This is a helper function for parallel execution of `Vocabulary.from_text` method. """ words = [w for l in lines for w in l.strip().split()] return Counter(words)
[ "Counts", "the", "word", "frequences", "in", "a", "list", "of", "sentences", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/base.py#L20-L28
[ "def", "count", "(", "lines", ")", ":", "words", "=", "[", "w", "for", "l", "in", "lines", "for", "w", "in", "l", ".", "strip", "(", ")", ".", "split", "(", ")", "]", "return", "Counter", "(", "words", ")" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
VocabularyBase.sanitize_words
Guarantees that all textual symbols are unicode. Note: We do not convert numbers, only strings to unicode. We assume that the strings are encoded in utf-8.
polyglot/mapping/base.py
def sanitize_words(self, words): """Guarantees that all textual symbols are unicode. Note: We do not convert numbers, only strings to unicode. We assume that the strings are encoded in utf-8. """ _words = [] for w in words: if isinstance(w, string_types) and not isinstance(w, unic...
def sanitize_words(self, words): """Guarantees that all textual symbols are unicode. Note: We do not convert numbers, only strings to unicode. We assume that the strings are encoded in utf-8. """ _words = [] for w in words: if isinstance(w, string_types) and not isinstance(w, unic...
[ "Guarantees", "that", "all", "textual", "symbols", "are", "unicode", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/base.py#L52-L65
[ "def", "sanitize_words", "(", "self", ",", "words", ")", ":", "_words", "=", "[", "]", "for", "w", "in", "words", ":", "if", "isinstance", "(", "w", ",", "string_types", ")", "and", "not", "isinstance", "(", "w", ",", "unicode", ")", ":", "_words", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
VocabularyBase.from_vocabfile
Construct a CountedVocabulary out of a vocabulary file. Note: File has the following format word1 word2
polyglot/mapping/base.py
def from_vocabfile(cls, filename): """ Construct a CountedVocabulary out of a vocabulary file. Note: File has the following format word1 word2 """ words = [x.strip() for x in _open(filename, 'r').read().splitlines()] return cls(words=words)
def from_vocabfile(cls, filename): """ Construct a CountedVocabulary out of a vocabulary file. Note: File has the following format word1 word2 """ words = [x.strip() for x in _open(filename, 'r').read().splitlines()] return cls(words=words)
[ "Construct", "a", "CountedVocabulary", "out", "of", "a", "vocabulary", "file", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/base.py#L117-L125
[ "def", "from_vocabfile", "(", "cls", ",", "filename", ")", ":", "words", "=", "[", "x", ".", "strip", "(", ")", "for", "x", "in", "_open", "(", "filename", ",", "'r'", ")", ".", "read", "(", ")", ".", "splitlines", "(", ")", "]", "return", "cls",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
CountedVocabulary.from_textfile
Count the set of words appeared in a text file. Args: textfile (string): The name of the text file or `TextFile` object. min_count (integer): Minimum number of times a word/token appeared in the document to be considered part of the vocabulary. workers (integer): Number of parall...
polyglot/mapping/base.py
def from_textfile(cls, textfile, workers=1, job_size=1000): """ Count the set of words appeared in a text file. Args: textfile (string): The name of the text file or `TextFile` object. min_count (integer): Minimum number of times a word/token appeared in the document to be consider...
def from_textfile(cls, textfile, workers=1, job_size=1000): """ Count the set of words appeared in a text file. Args: textfile (string): The name of the text file or `TextFile` object. min_count (integer): Minimum number of times a word/token appeared in the document to be consider...
[ "Count", "the", "set", "of", "words", "appeared", "in", "a", "text", "file", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/base.py#L193-L213
[ "def", "from_textfile", "(", "cls", ",", "textfile", ",", "workers", "=", "1", ",", "job_size", "=", "1000", ")", ":", "c", "=", "Counter", "(", ")", "if", "isinstance", "(", "textfile", ",", "string_types", ")", ":", "textfile", "=", "TextFile", "(", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
CountedVocabulary.most_frequent
Returns a vocabulary with the most frequent `k` words. Args: k (integer): specifies the top k most frequent words to be returned.
polyglot/mapping/base.py
def most_frequent(self, k): """ Returns a vocabulary with the most frequent `k` words. Args: k (integer): specifies the top k most frequent words to be returned. """ word_count = {w:self.word_count[w] for w in self.words[:k]} return CountedVocabulary(word_count=word_count)
def most_frequent(self, k): """ Returns a vocabulary with the most frequent `k` words. Args: k (integer): specifies the top k most frequent words to be returned. """ word_count = {w:self.word_count[w] for w in self.words[:k]} return CountedVocabulary(word_count=word_count)
[ "Returns", "a", "vocabulary", "with", "the", "most", "frequent", "k", "words", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/base.py#L215-L222
[ "def", "most_frequent", "(", "self", ",", "k", ")", ":", "word_count", "=", "{", "w", ":", "self", ".", "word_count", "[", "w", "]", "for", "w", "in", "self", ".", "words", "[", ":", "k", "]", "}", "return", "CountedVocabulary", "(", "word_count", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
CountedVocabulary.min_count
Returns a vocabulary after eliminating the words that appear < `n`. Args: n (integer): specifies the minimum word frequency allowed.
polyglot/mapping/base.py
def min_count(self, n=1): """ Returns a vocabulary after eliminating the words that appear < `n`. Args: n (integer): specifies the minimum word frequency allowed. """ word_count = {w:c for w,c in iteritems(self.word_count) if c >= n} return CountedVocabulary(word_count=word_count)
def min_count(self, n=1): """ Returns a vocabulary after eliminating the words that appear < `n`. Args: n (integer): specifies the minimum word frequency allowed. """ word_count = {w:c for w,c in iteritems(self.word_count) if c >= n} return CountedVocabulary(word_count=word_count)
[ "Returns", "a", "vocabulary", "after", "eliminating", "the", "words", "that", "appear", "<", "n", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/base.py#L224-L231
[ "def", "min_count", "(", "self", ",", "n", "=", "1", ")", ":", "word_count", "=", "{", "w", ":", "c", "for", "w", ",", "c", "in", "iteritems", "(", "self", ".", "word_count", ")", "if", "c", ">=", "n", "}", "return", "CountedVocabulary", "(", "wo...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
CountedVocabulary.from_vocabfile
Construct a CountedVocabulary out of a vocabulary file. Note: File has the following format word1 count1 word2 count2
polyglot/mapping/base.py
def from_vocabfile(filename): """ Construct a CountedVocabulary out of a vocabulary file. Note: File has the following format word1 count1 word2 count2 """ word_count = [x.strip().split() for x in _open(filename, 'r').read().splitlines()] word_count = {w:in...
def from_vocabfile(filename): """ Construct a CountedVocabulary out of a vocabulary file. Note: File has the following format word1 count1 word2 count2 """ word_count = [x.strip().split() for x in _open(filename, 'r').read().splitlines()] word_count = {w:in...
[ "Construct", "a", "CountedVocabulary", "out", "of", "a", "vocabulary", "file", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/base.py#L246-L255
[ "def", "from_vocabfile", "(", "filename", ")", ":", "word_count", "=", "[", "x", ".", "strip", "(", ")", ".", "split", "(", ")", "for", "x", "in", "_open", "(", "filename", ",", "'r'", ")", ".", "read", "(", ")", ".", "splitlines", "(", ")", "]",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Sequence.split
Split into subsequences according to `sequence`.
polyglot/base.py
def split(self, sequence): """ Split into subsequences according to `sequence`.""" major_idx = sequence.idx idx2 = 0 for start, end in zip(major_idx[:-1], major_idx[1:]): idx1 = self.idx.index(start, idx2) idx2 = self.idx.index(end, idx2) seq = Sequence(self.text[start:end]) seq...
def split(self, sequence): """ Split into subsequences according to `sequence`.""" major_idx = sequence.idx idx2 = 0 for start, end in zip(major_idx[:-1], major_idx[1:]): idx1 = self.idx.index(start, idx2) idx2 = self.idx.index(end, idx2) seq = Sequence(self.text[start:end]) seq...
[ "Split", "into", "subsequences", "according", "to", "sequence", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/base.py#L53-L63
[ "def", "split", "(", "self", ",", "sequence", ")", ":", "major_idx", "=", "sequence", ".", "idx", "idx2", "=", "0", "for", "start", ",", "end", "in", "zip", "(", "major_idx", "[", ":", "-", "1", "]", ",", "major_idx", "[", "1", ":", "]", ")", "...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
TextFile.iter_delimiter
Generalization of the default iter file delimited by '\n'. Note: The newline string can be arbitrarily long; it need not be restricted to a single character. You can also set the read size and control whether or not the newline string is left on the end of the iterated lines. Setting newlin...
polyglot/base.py
def iter_delimiter(self, byte_size=8192): """ Generalization of the default iter file delimited by '\n'. Note: The newline string can be arbitrarily long; it need not be restricted to a single character. You can also set the read size and control whether or not the newline string is left on th...
def iter_delimiter(self, byte_size=8192): """ Generalization of the default iter file delimited by '\n'. Note: The newline string can be arbitrarily long; it need not be restricted to a single character. You can also set the read size and control whether or not the newline string is left on th...
[ "Generalization", "of", "the", "default", "iter", "file", "delimited", "by", "\\", "n", ".", "Note", ":", "The", "newline", "string", "can", "be", "arbitrarily", "long", ";", "it", "need", "not", "be", "restricted", "to", "a", "single", "character", ".", ...
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/base.py#L108-L132
[ "def", "iter_delimiter", "(", "self", ",", "byte_size", "=", "8192", ")", ":", "partial", "=", "u''", "while", "True", ":", "read_chars", "=", "self", ".", "read", "(", "byte_size", ")", "if", "not", "read_chars", ":", "break", "partial", "+=", "read_cha...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
TextFile.read
Read `size` of bytes.
polyglot/base.py
def read(self, size=None): """ Read `size` of bytes.""" if size is None: return self.buf.read() + self.open_file.read() contents = self.buf.read(size) if len(contents) < size: contents += self.open_file.read(size - len(contents)) return contents
def read(self, size=None): """ Read `size` of bytes.""" if size is None: return self.buf.read() + self.open_file.read() contents = self.buf.read(size) if len(contents) < size: contents += self.open_file.read(size - len(contents)) return contents
[ "Read", "size", "of", "bytes", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/base.py#L159-L166
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "return", "self", ".", "buf", ".", "read", "(", ")", "+", "self", ".", "open_file", ".", "read", "(", ")", "contents", "=", "self", ".", "buf", "."...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
TextFile.apply
Apply `func` to lines of text in parallel or sequential. Args: func : a function that takes a list of lines.
polyglot/base.py
def apply(self, func, workers=1, job_size=10000): """Apply `func` to lines of text in parallel or sequential. Args: func : a function that takes a list of lines. """ if workers == 1: for lines in self.iter_chunks(job_size): yield func(lines) else: with ProcessPoolExecutor(...
def apply(self, func, workers=1, job_size=10000): """Apply `func` to lines of text in parallel or sequential. Args: func : a function that takes a list of lines. """ if workers == 1: for lines in self.iter_chunks(job_size): yield func(lines) else: with ProcessPoolExecutor(...
[ "Apply", "func", "to", "lines", "of", "text", "in", "parallel", "or", "sequential", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/base.py#L174-L186
[ "def", "apply", "(", "self", ",", "func", ",", "workers", "=", "1", ",", "job_size", "=", "10000", ")", ":", "if", "workers", "==", "1", ":", "for", "lines", "in", "self", ".", "iter_chunks", "(", "job_size", ")", ":", "yield", "func", "(", "lines"...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
TaggerBase.annotate
Annotate a squence of words with entity tags. Args: sent: sequence of strings/words.
polyglot/tag/base.py
def annotate(self, sent): """Annotate a squence of words with entity tags. Args: sent: sequence of strings/words. """ preds = [] words = [] for word, fv in self.sent2examples(sent): probs = self.predictor(fv) tags = probs.argsort() tag = self.ID_TAG[tags[-1]] word...
def annotate(self, sent): """Annotate a squence of words with entity tags. Args: sent: sequence of strings/words. """ preds = [] words = [] for word, fv in self.sent2examples(sent): probs = self.predictor(fv) tags = probs.argsort() tag = self.ID_TAG[tags[-1]] word...
[ "Annotate", "a", "squence", "of", "words", "with", "entity", "tags", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/tag/base.py#L62-L80
[ "def", "annotate", "(", "self", ",", "sent", ")", ":", "preds", "=", "[", "]", "words", "=", "[", "]", "for", "word", ",", "fv", "in", "self", ".", "sent2examples", "(", "sent", ")", ":", "probs", "=", "self", ".", "predictor", "(", "fv", ")", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
TaggerBase.sent2examples
Convert ngrams into feature vectors.
polyglot/tag/base.py
def sent2examples(self, sent): """ Convert ngrams into feature vectors.""" # TODO(rmyeid): use expanders. words = [w if w in self.embeddings else TaggerBase.UNK for w in sent] ngrams = TaggerBase.ngrams(words, self.context, self.transfer) fvs = [] for word, ngram in zip(sent, ngrams): fv ...
def sent2examples(self, sent): """ Convert ngrams into feature vectors.""" # TODO(rmyeid): use expanders. words = [w if w in self.embeddings else TaggerBase.UNK for w in sent] ngrams = TaggerBase.ngrams(words, self.context, self.transfer) fvs = [] for word, ngram in zip(sent, ngrams): fv ...
[ "Convert", "ngrams", "into", "feature", "vectors", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/tag/base.py#L82-L93
[ "def", "sent2examples", "(", "self", ",", "sent", ")", ":", "# TODO(rmyeid): use expanders.", "words", "=", "[", "w", "if", "w", "in", "self", ".", "embeddings", "else", "TaggerBase", ".", "UNK", "for", "w", "in", "sent", "]", "ngrams", "=", "TaggerBase", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
NEChunker._load_network
Building the predictor out of the model.
polyglot/tag/base.py
def _load_network(self): """ Building the predictor out of the model.""" self.embeddings = load_embeddings(self.lang, type='cw', normalize=True) self.model = load_ner_model(lang=self.lang, version=2) first_layer, second_layer = self.model def predict_proba(input_): hidden = np.tanh(np.dot(fir...
def _load_network(self): """ Building the predictor out of the model.""" self.embeddings = load_embeddings(self.lang, type='cw', normalize=True) self.model = load_ner_model(lang=self.lang, version=2) first_layer, second_layer = self.model def predict_proba(input_): hidden = np.tanh(np.dot(fir...
[ "Building", "the", "predictor", "out", "of", "the", "model", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/tag/base.py#L107-L120
[ "def", "_load_network", "(", "self", ")", ":", "self", ".", "embeddings", "=", "load_embeddings", "(", "self", ".", "lang", ",", "type", "=", "'cw'", ",", "normalize", "=", "True", ")", "self", ".", "model", "=", "load_ner_model", "(", "lang", "=", "se...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
POSTagger._load_network
Building the predictor out of the model.
polyglot/tag/base.py
def _load_network(self): """ Building the predictor out of the model.""" self.embeddings = load_embeddings(self.lang, type='cw') self.model = load_pos_model(lang=self.lang, version=2) def predict_proba(input_): hidden = np.tanh(np.dot(input_, self.model["W1"]) + self.model["b1"]) output = ...
def _load_network(self): """ Building the predictor out of the model.""" self.embeddings = load_embeddings(self.lang, type='cw') self.model = load_pos_model(lang=self.lang, version=2) def predict_proba(input_): hidden = np.tanh(np.dot(input_, self.model["W1"]) + self.model["b1"]) output = ...
[ "Building", "the", "predictor", "out", "of", "the", "model", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/tag/base.py#L135-L146
[ "def", "_load_network", "(", "self", ")", ":", "self", ".", "embeddings", "=", "load_embeddings", "(", "self", ".", "lang", ",", "type", "=", "'cw'", ")", "self", ".", "model", "=", "load_pos_model", "(", "lang", "=", "self", ".", "lang", ",", "version...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
OpenMapQuest._construct_url
Construct geocoding request url. Overridden. :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. :return: string URL.
geopy/geocoders/openmapquest.py
def _construct_url(self, base_api, params): """ Construct geocoding request url. Overridden. :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. :return: string URL. """ params['...
def _construct_url(self, base_api, params): """ Construct geocoding request url. Overridden. :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. :return: string URL. """ params['...
[ "Construct", "geocoding", "request", "url", ".", "Overridden", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/openmapquest.py#L117-L129
[ "def", "_construct_url", "(", "self", ",", "base_api", ",", "params", ")", ":", "params", "[", "'key'", "]", "=", "self", ".", "api_key", "return", "super", "(", "OpenMapQuest", ",", "self", ")", ".", "_construct_url", "(", "base_api", ",", "params", ")"...
02c838d965e76497f3c3d61f53808c86b5c58224
train
BANFrance.geocode
Return a location point by address. :param str query: The address or query you wish to geocode. :param int limit: Defines the maximum number of items in the response structure. If not provided and there are multiple results the BAN API will return 5 results by default. ...
geopy/geocoders/banfrance.py
def geocode( self, query, limit=None, exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. :param str query: The address or query you wish to geocode. :param int limit: Defines the maximum...
def geocode( self, query, limit=None, exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. :param str query: The address or query you wish to geocode. :param int limit: Defines the maximum...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/banfrance.py#L73-L115
[ "def", "geocode", "(", "self", ",", "query", ",", "limit", "=", "None", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", ")", ":", "params", "=", "{", "'q'", ":", "self", ".", "format_string", "%", "query", ",", "}", "if...
02c838d965e76497f3c3d61f53808c86b5c58224
train
ArcGIS._authenticated_call_geocoder
Wrap self._call_geocoder, handling tokens.
geopy/geocoders/arcgis.py
def _authenticated_call_geocoder(self, url, timeout=DEFAULT_SENTINEL): """ Wrap self._call_geocoder, handling tokens. """ if self.token is None or int(time()) > self.token_expiry: self._refresh_authentication_token() request = Request( "&".join((url, urlen...
def _authenticated_call_geocoder(self, url, timeout=DEFAULT_SENTINEL): """ Wrap self._call_geocoder, handling tokens. """ if self.token is None or int(time()) > self.token_expiry: self._refresh_authentication_token() request = Request( "&".join((url, urlen...
[ "Wrap", "self", ".", "_call_geocoder", "handling", "tokens", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/arcgis.py#L145-L155
[ "def", "_authenticated_call_geocoder", "(", "self", ",", "url", ",", "timeout", "=", "DEFAULT_SENTINEL", ")", ":", "if", "self", ".", "token", "is", "None", "or", "int", "(", "time", "(", ")", ")", ">", "self", ".", "token_expiry", ":", "self", ".", "_...
02c838d965e76497f3c3d61f53808c86b5c58224
train
ArcGIS.geocode
Return a location point by address. :param str query: The address or query you wish to geocode. :param bool exactly_one: Return one result or a list of results, if available. :param int timeout: Time, in seconds, to wait for the geocoding service to respond before rais...
geopy/geocoders/arcgis.py
def geocode(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, out_fields=None): """ Return a location point by address. :param str query: The address or query you wish to geocode. :param bool exactly_one: Return one result or a list of results, if ava...
def geocode(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, out_fields=None): """ Return a location point by address. :param str query: The address or query you wish to geocode. :param bool exactly_one: Return one result or a list of results, if ava...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/arcgis.py#L157-L220
[ "def", "geocode", "(", "self", ",", "query", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", "out_fields", "=", "None", ")", ":", "params", "=", "{", "'singleLine'", ":", "self", ".", "format_string", "%", "query", ",", "'f...
02c838d965e76497f3c3d61f53808c86b5c58224
train
ArcGIS.reverse
Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :class:`geopy.point.Point`, list or tuple of ``(latitude, longitude)``, or string as ``"%(latitude)s, %(longitude)s"``. :pa...
geopy/geocoders/arcgis.py
def reverse(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, distance=None, wkid=DEFAULT_WKID): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :cla...
def reverse(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, distance=None, wkid=DEFAULT_WKID): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :cla...
[ "Return", "an", "address", "by", "location", "point", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/arcgis.py#L222-L306
[ "def", "reverse", "(", "self", ",", "query", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", "distance", "=", "None", ",", "wkid", "=", "DEFAULT_WKID", ")", ":", "location", "=", "self", ".", "_coerce_point_to_string", "(", "...
02c838d965e76497f3c3d61f53808c86b5c58224
train
ArcGIS._refresh_authentication_token
POST to ArcGIS requesting a new token.
geopy/geocoders/arcgis.py
def _refresh_authentication_token(self): """ POST to ArcGIS requesting a new token. """ if self.retry == self._MAX_RETRIES: raise GeocoderAuthenticationFailure( 'Too many retries for auth: %s' % self.retry ) token_request_arguments = { ...
def _refresh_authentication_token(self): """ POST to ArcGIS requesting a new token. """ if self.retry == self._MAX_RETRIES: raise GeocoderAuthenticationFailure( 'Too many retries for auth: %s' % self.retry ) token_request_arguments = { ...
[ "POST", "to", "ArcGIS", "requesting", "a", "new", "token", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/arcgis.py#L308-L337
[ "def", "_refresh_authentication_token", "(", "self", ")", ":", "if", "self", ".", "retry", "==", "self", ".", "_MAX_RETRIES", ":", "raise", "GeocoderAuthenticationFailure", "(", "'Too many retries for auth: %s'", "%", "self", ".", "retry", ")", "token_request_argument...
02c838d965e76497f3c3d61f53808c86b5c58224
train
pairwise
Pair an iterable, e.g., (1, 2, 3, 4) -> ((1, 2), (2, 3), (3, 4))
geopy/util.py
def pairwise(seq): """ Pair an iterable, e.g., (1, 2, 3, 4) -> ((1, 2), (2, 3), (3, 4)) """ for i in range(0, len(seq) - 1): yield (seq[i], seq[i + 1])
def pairwise(seq): """ Pair an iterable, e.g., (1, 2, 3, 4) -> ((1, 2), (2, 3), (3, 4)) """ for i in range(0, len(seq) - 1): yield (seq[i], seq[i + 1])
[ "Pair", "an", "iterable", "e", ".", "g", ".", "(", "1", "2", "3", "4", ")", "-", ">", "((", "1", "2", ")", "(", "2", "3", ")", "(", "3", "4", "))" ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/util.py#L25-L30
[ "def", "pairwise", "(", "seq", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "seq", ")", "-", "1", ")", ":", "yield", "(", "seq", "[", "i", "]", ",", "seq", "[", "i", "+", "1", "]", ")" ]
02c838d965e76497f3c3d61f53808c86b5c58224
train
join_filter
Join with a filter.
geopy/util.py
def join_filter(sep, seq, pred=bool): """ Join with a filter. """ return sep.join([text_type(i) for i in seq if pred(i)])
def join_filter(sep, seq, pred=bool): """ Join with a filter. """ return sep.join([text_type(i) for i in seq if pred(i)])
[ "Join", "with", "a", "filter", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/util.py#L33-L37
[ "def", "join_filter", "(", "sep", ",", "seq", ",", "pred", "=", "bool", ")", ":", "return", "sep", ".", "join", "(", "[", "text_type", "(", "i", ")", "for", "i", "in", "seq", "if", "pred", "(", "i", ")", "]", ")" ]
02c838d965e76497f3c3d61f53808c86b5c58224
train
decode_page
Return unicode string of geocoder results. Nearly all services use JSON, so assume UTF8 encoding unless the response specifies otherwise.
geopy/util.py
def decode_page(page): """ Return unicode string of geocoder results. Nearly all services use JSON, so assume UTF8 encoding unless the response specifies otherwise. """ if hasattr(page, 'read'): # urllib if py3k: encoding = page.headers.get_param("charset") or "utf-8" ...
def decode_page(page): """ Return unicode string of geocoder results. Nearly all services use JSON, so assume UTF8 encoding unless the response specifies otherwise. """ if hasattr(page, 'read'): # urllib if py3k: encoding = page.headers.get_param("charset") or "utf-8" ...
[ "Return", "unicode", "string", "of", "geocoder", "results", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/util.py#L40-L55
[ "def", "decode_page", "(", "page", ")", ":", "if", "hasattr", "(", "page", ",", "'read'", ")", ":", "# urllib", "if", "py3k", ":", "encoding", "=", "page", ".", "headers", ".", "get_param", "(", "\"charset\"", ")", "or", "\"utf-8\"", "else", ":", "enco...
02c838d965e76497f3c3d61f53808c86b5c58224
train
great_circle.destination
TODO docs.
geopy/distance.py
def destination(self, point, bearing, distance=None): """ TODO docs. """ point = Point(point) lat1 = units.radians(degrees=point.latitude) lng1 = units.radians(degrees=point.longitude) bearing = units.radians(degrees=bearing) if distance is None: ...
def destination(self, point, bearing, distance=None): """ TODO docs. """ point = Point(point) lat1 = units.radians(degrees=point.latitude) lng1 = units.radians(degrees=point.longitude) bearing = units.radians(degrees=bearing) if distance is None: ...
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/distance.py#L322-L348
[ "def", "destination", "(", "self", ",", "point", ",", "bearing", ",", "distance", "=", "None", ")", ":", "point", "=", "Point", "(", "point", ")", "lat1", "=", "units", ".", "radians", "(", "degrees", "=", "point", ".", "latitude", ")", "lng1", "=", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
geodesic.destination
TODO docs.
geopy/distance.py
def destination(self, point, bearing, distance=None): """ TODO docs. """ point = Point(point) lat1 = point.latitude lon1 = point.longitude azi1 = bearing if distance is None: distance = self if isinstance(distance, Distance): ...
def destination(self, point, bearing, distance=None): """ TODO docs. """ point = Point(point) lat1 = point.latitude lon1 = point.longitude azi1 = bearing if distance is None: distance = self if isinstance(distance, Distance): ...
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/distance.py#L424-L446
[ "def", "destination", "(", "self", ",", "point", ",", "bearing", ",", "distance", "=", "None", ")", ":", "point", "=", "Point", "(", "point", ")", "lat1", "=", "point", ".", "latitude", "lon1", "=", "point", ".", "longitude", "azi1", "=", "bearing", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
vincenty.set_ellipsoid
Change the ellipsoid used in the calculation.
geopy/distance.py
def set_ellipsoid(self, ellipsoid): """ Change the ellipsoid used in the calculation. """ if not isinstance(ellipsoid, (list, tuple)): try: self.ELLIPSOID = ELLIPSOIDS[ellipsoid] self.ellipsoid_key = ellipsoid except KeyError: ...
def set_ellipsoid(self, ellipsoid): """ Change the ellipsoid used in the calculation. """ if not isinstance(ellipsoid, (list, tuple)): try: self.ELLIPSOID = ELLIPSOIDS[ellipsoid] self.ellipsoid_key = ellipsoid except KeyError: ...
[ "Change", "the", "ellipsoid", "used", "in", "the", "calculation", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/distance.py#L499-L514
[ "def", "set_ellipsoid", "(", "self", ",", "ellipsoid", ")", ":", "if", "not", "isinstance", "(", "ellipsoid", ",", "(", "list", ",", "tuple", ")", ")", ":", "try", ":", "self", ".", "ELLIPSOID", "=", "ELLIPSOIDS", "[", "ellipsoid", "]", "self", ".", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
vincenty.destination
TODO docs.
geopy/distance.py
def destination(self, point, bearing, distance=None): """ TODO docs. """ point = Point(point) lat1 = units.radians(degrees=point.latitude) lng1 = units.radians(degrees=point.longitude) bearing = units.radians(degrees=bearing) if distance is None: ...
def destination(self, point, bearing, distance=None): """ TODO docs. """ point = Point(point) lat1 = units.radians(degrees=point.latitude) lng1 = units.radians(degrees=point.longitude) bearing = units.radians(degrees=bearing) if distance is None: ...
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/distance.py#L616-L701
[ "def", "destination", "(", "self", ",", "point", ",", "bearing", ",", "distance", "=", "None", ")", ":", "point", "=", "Point", "(", "point", ")", "lat1", "=", "units", ".", "radians", "(", "degrees", "=", "point", ".", "latitude", ")", "lng1", "=", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
_normalize_angle
Normalize angle `x` to be within `[-limit; limit)` range.
geopy/point.py
def _normalize_angle(x, limit): """ Normalize angle `x` to be within `[-limit; limit)` range. """ double_limit = limit * 2.0 modulo = fmod(x, double_limit) or 0.0 # `or 0` is to turn -0 to +0. if modulo < -limit: return modulo + double_limit if modulo >= limit: return modulo...
def _normalize_angle(x, limit): """ Normalize angle `x` to be within `[-limit; limit)` range. """ double_limit = limit * 2.0 modulo = fmod(x, double_limit) or 0.0 # `or 0` is to turn -0 to +0. if modulo < -limit: return modulo + double_limit if modulo >= limit: return modulo...
[ "Normalize", "angle", "x", "to", "be", "within", "[", "-", "limit", ";", "limit", ")", "range", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L45-L55
[ "def", "_normalize_angle", "(", "x", ",", "limit", ")", ":", "double_limit", "=", "limit", "*", "2.0", "modulo", "=", "fmod", "(", "x", ",", "double_limit", ")", "or", "0.0", "# `or 0` is to turn -0 to +0.", "if", "modulo", "<", "-", "limit", ":", "return"...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Point.format
Format decimal degrees (DD) to degrees minutes seconds (DMS)
geopy/point.py
def format(self, altitude=None, deg_char='', min_char='m', sec_char='s'): """ Format decimal degrees (DD) to degrees minutes seconds (DMS) """ latitude = "%s %s" % ( format_degrees(abs(self.latitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': se...
def format(self, altitude=None, deg_char='', min_char='m', sec_char='s'): """ Format decimal degrees (DD) to degrees minutes seconds (DMS) """ latitude = "%s %s" % ( format_degrees(abs(self.latitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': se...
[ "Format", "decimal", "degrees", "(", "DD", ")", "to", "degrees", "minutes", "seconds", "(", "DMS", ")" ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L207-L232
[ "def", "format", "(", "self", ",", "altitude", "=", "None", ",", "deg_char", "=", "''", ",", "min_char", "=", "'m'", ",", "sec_char", "=", "'s'", ")", ":", "latitude", "=", "\"%s %s\"", "%", "(", "format_degrees", "(", "abs", "(", "self", ".", "latit...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Point.format_decimal
Format decimal degrees with altitude
geopy/point.py
def format_decimal(self, altitude=None): """ Format decimal degrees with altitude """ coordinates = [str(self.latitude), str(self.longitude)] if altitude is None: altitude = bool(self.altitude) if altitude: if not isinstance(altitude, string_compa...
def format_decimal(self, altitude=None): """ Format decimal degrees with altitude """ coordinates = [str(self.latitude), str(self.longitude)] if altitude is None: altitude = bool(self.altitude) if altitude: if not isinstance(altitude, string_compa...
[ "Format", "decimal", "degrees", "with", "altitude" ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L234-L247
[ "def", "format_decimal", "(", "self", ",", "altitude", "=", "None", ")", ":", "coordinates", "=", "[", "str", "(", "self", ".", "latitude", ")", ",", "str", "(", "self", ".", "longitude", ")", "]", "if", "altitude", "is", "None", ":", "altitude", "="...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Point.parse_degrees
Parse degrees minutes seconds including direction (N, S, E, W)
geopy/point.py
def parse_degrees(cls, degrees, arcminutes, arcseconds, direction=None): """ Parse degrees minutes seconds including direction (N, S, E, W) """ degrees = float(degrees) negative = degrees < 0 arcminutes = float(arcminutes) arcseconds = float(arcseconds) i...
def parse_degrees(cls, degrees, arcminutes, arcseconds, direction=None): """ Parse degrees minutes seconds including direction (N, S, E, W) """ degrees = float(degrees) negative = degrees < 0 arcminutes = float(arcminutes) arcseconds = float(arcseconds) i...
[ "Parse", "degrees", "minutes", "seconds", "including", "direction", "(", "N", "S", "E", "W", ")" ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L272-L293
[ "def", "parse_degrees", "(", "cls", ",", "degrees", ",", "arcminutes", ",", "arcseconds", ",", "direction", "=", "None", ")", ":", "degrees", "=", "float", "(", "degrees", ")", "negative", "=", "degrees", "<", "0", "arcminutes", "=", "float", "(", "arcmi...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Point.parse_altitude
Parse altitude managing units conversion
geopy/point.py
def parse_altitude(cls, distance, unit): """ Parse altitude managing units conversion """ if distance is not None: distance = float(distance) CONVERTERS = { 'km': lambda d: d, 'm': lambda d: units.kilometers(meters=d), ...
def parse_altitude(cls, distance, unit): """ Parse altitude managing units conversion """ if distance is not None: distance = float(distance) CONVERTERS = { 'km': lambda d: d, 'm': lambda d: units.kilometers(meters=d), ...
[ "Parse", "altitude", "managing", "units", "conversion" ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L296-L318
[ "def", "parse_altitude", "(", "cls", ",", "distance", ",", "unit", ")", ":", "if", "distance", "is", "not", "None", ":", "distance", "=", "float", "(", "distance", ")", "CONVERTERS", "=", "{", "'km'", ":", "lambda", "d", ":", "d", ",", "'m'", ":", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Point.from_string
Create and return a ``Point`` instance from a string containing latitude and longitude, and optionally, altitude. Latitude and longitude must be in degrees and may be in decimal form or indicate arcminutes and arcseconds (labeled with Unicode prime and double prime, ASCII quote and doub...
geopy/point.py
def from_string(cls, string): """ Create and return a ``Point`` instance from a string containing latitude and longitude, and optionally, altitude. Latitude and longitude must be in degrees and may be in decimal form or indicate arcminutes and arcseconds (labeled with Unicode pr...
def from_string(cls, string): """ Create and return a ``Point`` instance from a string containing latitude and longitude, and optionally, altitude. Latitude and longitude must be in degrees and may be in decimal form or indicate arcminutes and arcseconds (labeled with Unicode pr...
[ "Create", "and", "return", "a", "Point", "instance", "from", "a", "string", "containing", "latitude", "and", "longitude", "and", "optionally", "altitude", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L321-L392
[ "def", "from_string", "(", "cls", ",", "string", ")", ":", "match", "=", "re", ".", "match", "(", "cls", ".", "POINT_PATTERN", ",", "re", ".", "sub", "(", "r\"''\"", ",", "r'\"'", ",", "string", ")", ")", "if", "match", ":", "latitude_direction", "="...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Point.from_sequence
Create and return a new ``Point`` instance from any iterable with 0 to 3 elements. The elements, if present, must be latitude, longitude, and altitude, respectively.
geopy/point.py
def from_sequence(cls, seq): """ Create and return a new ``Point`` instance from any iterable with 0 to 3 elements. The elements, if present, must be latitude, longitude, and altitude, respectively. """ args = tuple(islice(seq, 4)) if len(args) > 3: r...
def from_sequence(cls, seq): """ Create and return a new ``Point`` instance from any iterable with 0 to 3 elements. The elements, if present, must be latitude, longitude, and altitude, respectively. """ args = tuple(islice(seq, 4)) if len(args) > 3: r...
[ "Create", "and", "return", "a", "new", "Point", "instance", "from", "any", "iterable", "with", "0", "to", "3", "elements", ".", "The", "elements", "if", "present", "must", "be", "latitude", "longitude", "and", "altitude", "respectively", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L395-L405
[ "def", "from_sequence", "(", "cls", ",", "seq", ")", ":", "args", "=", "tuple", "(", "islice", "(", "seq", ",", "4", ")", ")", "if", "len", "(", "args", ")", ">", "3", ":", "raise", "ValueError", "(", "'When creating a Point from sequence, it '", "'must ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Point.from_point
Create and return a new ``Point`` instance from another ``Point`` instance.
geopy/point.py
def from_point(cls, point): """ Create and return a new ``Point`` instance from another ``Point`` instance. """ return cls(point.latitude, point.longitude, point.altitude)
def from_point(cls, point): """ Create and return a new ``Point`` instance from another ``Point`` instance. """ return cls(point.latitude, point.longitude, point.altitude)
[ "Create", "and", "return", "a", "new", "Point", "instance", "from", "another", "Point", "instance", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/point.py#L408-L413
[ "def", "from_point", "(", "cls", ",", "point", ")", ":", "return", "cls", "(", "point", ".", "latitude", ",", "point", ".", "longitude", ",", "point", ".", "altitude", ")" ]
02c838d965e76497f3c3d61f53808c86b5c58224
train
DataBC.geocode
Return a location point by address. :param str query: The address or query you wish to geocode. :param int max_results: The maximum number of resutls to request. :param float set_back: The distance to move the accessPoint away from the curb (in meters) and towards the interior of ...
geopy/geocoders/databc.py
def geocode( self, query, max_results=25, set_back=0, location_descriptor='any', exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. :param str query: The address or query ...
def geocode( self, query, max_results=25, set_back=0, location_descriptor='any', exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. :param str query: The address or query ...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/databc.py#L66-L133
[ "def", "geocode", "(", "self", ",", "query", ",", "max_results", "=", "25", ",", "set_back", "=", "0", ",", "location_descriptor", "=", "'any'", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", ")", ":", "params", "=", "{", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
GeocodeFarm.reverse
Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :class:`geopy.point.Point`, list or tuple of ``(latitude, longitude)``, or string as ``"%(latitude)s, %(longitude)s"``. :pa...
geopy/geocoders/geocodefarm.py
def reverse(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :class:`geopy.point.Point`, list or tuple of ``(latitu...
def reverse(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :class:`geopy.point.Point`, list or tuple of ``(latitu...
[ "Return", "an", "address", "by", "location", "point", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/geocodefarm.py#L109-L144
[ "def", "reverse", "(", "self", ",", "query", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ")", ":", "try", ":", "lat", ",", "lon", "=", "self", ".", "_coerce_point_to_string", "(", "query", ")", ".", "split", "(", "','", ")...
02c838d965e76497f3c3d61f53808c86b5c58224
train
GeocodeFarm._check_for_api_errors
Raise any exceptions if there were problems reported in the api response.
geopy/geocoders/geocodefarm.py
def _check_for_api_errors(geocoding_results): """ Raise any exceptions if there were problems reported in the api response. """ status_result = geocoding_results.get("STATUS", {}) if "NO_RESULTS" in status_result.get("status", ""): return api_call_succ...
def _check_for_api_errors(geocoding_results): """ Raise any exceptions if there were problems reported in the api response. """ status_result = geocoding_results.get("STATUS", {}) if "NO_RESULTS" in status_result.get("status", ""): return api_call_succ...
[ "Raise", "any", "exceptions", "if", "there", "were", "problems", "reported", "in", "the", "api", "response", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/geocodefarm.py#L183-L201
[ "def", "_check_for_api_errors", "(", "geocoding_results", ")", ":", "status_result", "=", "geocoding_results", ".", "get", "(", "\"STATUS\"", ",", "{", "}", ")", "if", "\"NO_RESULTS\"", "in", "status_result", ".", "get", "(", "\"status\"", ",", "\"\"", ")", ":...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Bing.geocode
Return a location point by address. :param str query: The address or query you wish to geocode. For a structured query, provide a dictionary whose keys are one of: `addressLine`, `locality` (city), `adminDistrict` (state), `countryRegion`, or `postalcode`. :param b...
geopy/geocoders/bing.py
def geocode( self, query, exactly_one=True, user_location=None, timeout=DEFAULT_SENTINEL, culture=None, include_neighborhood=None, include_country_code=False ): """ Return a location point by address. ...
def geocode( self, query, exactly_one=True, user_location=None, timeout=DEFAULT_SENTINEL, culture=None, include_neighborhood=None, include_country_code=False ): """ Return a location point by address. ...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/bing.py#L85-L166
[ "def", "geocode", "(", "self", ",", "query", ",", "exactly_one", "=", "True", ",", "user_location", "=", "None", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", "culture", "=", "None", ",", "include_neighborhood", "=", "None", ",", "include_country_code", "=", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Bing.reverse
Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :class:`geopy.point.Point`, list or tuple of ``(latitude, longitude)``, or string as ``"%(latitude)s, %(longitude)s"``. :pa...
geopy/geocoders/bing.py
def reverse( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, culture=None, include_country_code=False ): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the ...
def reverse( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, culture=None, include_country_code=False ): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the ...
[ "Return", "an", "address", "by", "location", "point", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/bing.py#L168-L217
[ "def", "reverse", "(", "self", ",", "query", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", "culture", "=", "None", ",", "include_country_code", "=", "False", ")", ":", "point", "=", "self", ".", "_coerce_point_to_string", "("...
02c838d965e76497f3c3d61f53808c86b5c58224
train
degrees
TODO docs.
geopy/units.py
def degrees(radians=0, arcminutes=0, arcseconds=0): """ TODO docs. """ deg = 0. if radians: deg = math.degrees(radians) if arcminutes: deg += arcminutes / arcmin(degrees=1.) if arcseconds: deg += arcseconds / arcsec(degrees=1.) return deg
def degrees(radians=0, arcminutes=0, arcseconds=0): """ TODO docs. """ deg = 0. if radians: deg = math.degrees(radians) if arcminutes: deg += arcminutes / arcmin(degrees=1.) if arcseconds: deg += arcseconds / arcsec(degrees=1.) return deg
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/units.py#L10-L21
[ "def", "degrees", "(", "radians", "=", "0", ",", "arcminutes", "=", "0", ",", "arcseconds", "=", "0", ")", ":", "deg", "=", "0.", "if", "radians", ":", "deg", "=", "math", ".", "degrees", "(", "radians", ")", "if", "arcminutes", ":", "deg", "+=", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
radians
TODO docs.
geopy/units.py
def radians(degrees=0, arcminutes=0, arcseconds=0): """ TODO docs. """ if arcminutes: degrees += arcminutes / arcmin(degrees=1.) if arcseconds: degrees += arcseconds / arcsec(degrees=1.) return math.radians(degrees)
def radians(degrees=0, arcminutes=0, arcseconds=0): """ TODO docs. """ if arcminutes: degrees += arcminutes / arcmin(degrees=1.) if arcseconds: degrees += arcseconds / arcsec(degrees=1.) return math.radians(degrees)
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/units.py#L24-L32
[ "def", "radians", "(", "degrees", "=", "0", ",", "arcminutes", "=", "0", ",", "arcseconds", "=", "0", ")", ":", "if", "arcminutes", ":", "degrees", "+=", "arcminutes", "/", "arcmin", "(", "degrees", "=", "1.", ")", "if", "arcseconds", ":", "degrees", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
kilometers
TODO docs.
geopy/units.py
def kilometers(meters=0, miles=0, feet=0, nautical=0): """ TODO docs. """ ret = 0. if meters: ret += meters / 1000. if feet: ret += feet / ft(1.) if nautical: ret += nautical / nm(1.) ret += miles * 1.609344 return ret
def kilometers(meters=0, miles=0, feet=0, nautical=0): """ TODO docs. """ ret = 0. if meters: ret += meters / 1000. if feet: ret += feet / ft(1.) if nautical: ret += nautical / nm(1.) ret += miles * 1.609344 return ret
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/units.py#L59-L71
[ "def", "kilometers", "(", "meters", "=", "0", ",", "miles", "=", "0", ",", "feet", "=", "0", ",", "nautical", "=", "0", ")", ":", "ret", "=", "0.", "if", "meters", ":", "ret", "+=", "meters", "/", "1000.", "if", "feet", ":", "ret", "+=", "feet"...
02c838d965e76497f3c3d61f53808c86b5c58224
train
meters
TODO docs.
geopy/units.py
def meters(kilometers=0, miles=0, feet=0, nautical=0): """ TODO docs. """ return (kilometers + km(nautical=nautical, miles=miles, feet=feet)) * 1000
def meters(kilometers=0, miles=0, feet=0, nautical=0): """ TODO docs. """ return (kilometers + km(nautical=nautical, miles=miles, feet=feet)) * 1000
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/units.py#L74-L78
[ "def", "meters", "(", "kilometers", "=", "0", ",", "miles", "=", "0", ",", "feet", "=", "0", ",", "nautical", "=", "0", ")", ":", "return", "(", "kilometers", "+", "km", "(", "nautical", "=", "nautical", ",", "miles", "=", "miles", ",", "feet", "...
02c838d965e76497f3c3d61f53808c86b5c58224
train
miles
TODO docs.
geopy/units.py
def miles(kilometers=0, meters=0, feet=0, nautical=0): """ TODO docs. """ ret = 0. if nautical: kilometers += nautical / nm(1.) if feet: kilometers += feet / ft(1.) if meters: kilometers += meters / 1000. ret += kilometers / 1.609344 return ret
def miles(kilometers=0, meters=0, feet=0, nautical=0): """ TODO docs. """ ret = 0. if nautical: kilometers += nautical / nm(1.) if feet: kilometers += feet / ft(1.) if meters: kilometers += meters / 1000. ret += kilometers / 1.609344 return ret
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/units.py#L81-L93
[ "def", "miles", "(", "kilometers", "=", "0", ",", "meters", "=", "0", ",", "feet", "=", "0", ",", "nautical", "=", "0", ")", ":", "ret", "=", "0.", "if", "nautical", ":", "kilometers", "+=", "nautical", "/", "nm", "(", "1.", ")", "if", "feet", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
feet
TODO docs.
geopy/units.py
def feet(kilometers=0, meters=0, miles=0, nautical=0): """ TODO docs. """ ret = 0. if nautical: kilometers += nautical / nm(1.) if meters: kilometers += meters / 1000. if kilometers: miles += mi(kilometers=kilometers) ret += miles * 5280 return ret
def feet(kilometers=0, meters=0, miles=0, nautical=0): """ TODO docs. """ ret = 0. if nautical: kilometers += nautical / nm(1.) if meters: kilometers += meters / 1000. if kilometers: miles += mi(kilometers=kilometers) ret += miles * 5280 return ret
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/units.py#L96-L108
[ "def", "feet", "(", "kilometers", "=", "0", ",", "meters", "=", "0", ",", "miles", "=", "0", ",", "nautical", "=", "0", ")", ":", "ret", "=", "0.", "if", "nautical", ":", "kilometers", "+=", "nautical", "/", "nm", "(", "1.", ")", "if", "meters", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
nautical
TODO docs.
geopy/units.py
def nautical(kilometers=0, meters=0, miles=0, feet=0): """ TODO docs. """ ret = 0. if feet: kilometers += feet / ft(1.) if miles: kilometers += km(miles=miles) if meters: kilometers += meters / 1000. ret += kilometers / 1.852 return ret
def nautical(kilometers=0, meters=0, miles=0, feet=0): """ TODO docs. """ ret = 0. if feet: kilometers += feet / ft(1.) if miles: kilometers += km(miles=miles) if meters: kilometers += meters / 1000. ret += kilometers / 1.852 return ret
[ "TODO", "docs", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/units.py#L111-L123
[ "def", "nautical", "(", "kilometers", "=", "0", ",", "meters", "=", "0", ",", "miles", "=", "0", ",", "feet", "=", "0", ")", ":", "ret", "=", "0.", "if", "feet", ":", "kilometers", "+=", "feet", "/", "ft", "(", "1.", ")", "if", "miles", ":", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
LiveAddress.geocode
Return a location point by address. :param str query: The address or query you wish to geocode. :param bool exactly_one: Return one result or a list of results, if available. :param int timeout: Time, in seconds, to wait for the geocoding service to respond before rais...
geopy/geocoders/smartystreets.py
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, candidates=None, # TODO: change default value to `1` in geopy 2.0 ): """ Return a location point by address. :param str query: The address or query you wish to ...
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, candidates=None, # TODO: change default value to `1` in geopy 2.0 ): """ Return a location point by address. :param str query: The address or query you wish to ...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/smartystreets.py#L113-L163
[ "def", "geocode", "(", "self", ",", "query", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", "candidates", "=", "None", ",", "# TODO: change default value to `1` in geopy 2.0", ")", ":", "if", "candidates", "is", "None", ":", "cand...
02c838d965e76497f3c3d61f53808c86b5c58224
train
LiveAddress._parse_json
Parse responses as JSON objects.
geopy/geocoders/smartystreets.py
def _parse_json(self, response, exactly_one=True): """ Parse responses as JSON objects. """ if not len(response): return None if exactly_one: return self._format_structured_address(response[0]) else: return [self._format_structured_addr...
def _parse_json(self, response, exactly_one=True): """ Parse responses as JSON objects. """ if not len(response): return None if exactly_one: return self._format_structured_address(response[0]) else: return [self._format_structured_addr...
[ "Parse", "responses", "as", "JSON", "objects", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/smartystreets.py#L172-L181
[ "def", "_parse_json", "(", "self", ",", "response", ",", "exactly_one", "=", "True", ")", ":", "if", "not", "len", "(", "response", ")", ":", "return", "None", "if", "exactly_one", ":", "return", "self", ".", "_format_structured_address", "(", "response", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
LiveAddress._format_structured_address
Pretty-print address and return lat, lon tuple.
geopy/geocoders/smartystreets.py
def _format_structured_address(address): """ Pretty-print address and return lat, lon tuple. """ latitude = address['metadata'].get('latitude') longitude = address['metadata'].get('longitude') return Location( ", ".join((address['delivery_line_1'], address['la...
def _format_structured_address(address): """ Pretty-print address and return lat, lon tuple. """ latitude = address['metadata'].get('latitude') longitude = address['metadata'].get('longitude') return Location( ", ".join((address['delivery_line_1'], address['la...
[ "Pretty", "-", "print", "address", "and", "return", "lat", "lon", "tuple", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/smartystreets.py#L184-L194
[ "def", "_format_structured_address", "(", "address", ")", ":", "latitude", "=", "address", "[", "'metadata'", "]", ".", "get", "(", "'latitude'", ")", "longitude", "=", "address", "[", "'metadata'", "]", ".", "get", "(", "'longitude'", ")", "return", "Locati...
02c838d965e76497f3c3d61f53808c86b5c58224
train
PickPoint._construct_url
Construct geocoding request url. Overridden. :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. :return: string URL.
geopy/geocoders/pickpoint.py
def _construct_url(self, base_api, params): """ Construct geocoding request url. Overridden. :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. :return: string URL. """ params['...
def _construct_url(self, base_api, params): """ Construct geocoding request url. Overridden. :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. :return: string URL. """ params['...
[ "Construct", "geocoding", "request", "url", ".", "Overridden", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/pickpoint.py#L108-L120
[ "def", "_construct_url", "(", "self", ",", "base_api", ",", "params", ")", ":", "params", "[", "'key'", "]", "=", "self", ".", "api_key", "return", "super", "(", "PickPoint", ",", "self", ")", ".", "_construct_url", "(", "base_api", ",", "params", ")" ]
02c838d965e76497f3c3d61f53808c86b5c58224
train
GoogleV3._get_signed_url
Returns a Premier account signed url. Docs on signature: https://developers.google.com/maps/documentation/business/webservices/auth#digital_signatures
geopy/geocoders/googlev3.py
def _get_signed_url(self, params): """ Returns a Premier account signed url. Docs on signature: https://developers.google.com/maps/documentation/business/webservices/auth#digital_signatures """ params['client'] = self.client_id if self.channel: params['ch...
def _get_signed_url(self, params): """ Returns a Premier account signed url. Docs on signature: https://developers.google.com/maps/documentation/business/webservices/auth#digital_signatures """ params['client'] = self.client_id if self.channel: params['ch...
[ "Returns", "a", "Premier", "account", "signed", "url", ".", "Docs", "on", "signature", ":", "https", ":", "//", "developers", ".", "google", ".", "com", "/", "maps", "/", "documentation", "/", "business", "/", "webservices", "/", "auth#digital_signatures" ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/googlev3.py#L127-L148
[ "def", "_get_signed_url", "(", "self", ",", "params", ")", ":", "params", "[", "'client'", "]", "=", "self", ".", "client_id", "if", "self", ".", "channel", ":", "params", "[", "'channel'", "]", "=", "self", ".", "channel", "path", "=", "\"?\"", ".", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
GoogleV3.geocode
Return a location point by address. :param str query: The address or query you wish to geocode. Optional, if ``components`` param is set:: >>> g.geocode(components={"city": "Paris", "country": "FR"}) Location(France, (46.227638, 2.213749, 0.0)) .. versi...
geopy/geocoders/googlev3.py
def geocode( self, query=None, exactly_one=True, timeout=DEFAULT_SENTINEL, bounds=None, region=None, components=None, place_id=None, language=None, sensor=False, ): """ Return a lo...
def geocode( self, query=None, exactly_one=True, timeout=DEFAULT_SENTINEL, bounds=None, region=None, components=None, place_id=None, language=None, sensor=False, ): """ Return a lo...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/googlev3.py#L159-L274
[ "def", "geocode", "(", "self", ",", "query", "=", "None", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", "bounds", "=", "None", ",", "region", "=", "None", ",", "components", "=", "None", ",", "place_id", "=", "None", ",...
02c838d965e76497f3c3d61f53808c86b5c58224
train
GoogleV3.timezone
Find the timezone a `location` was in for a specified `at_time`, and return a pytz timezone object. .. versionadded:: 1.2.0 .. deprecated:: 1.18.0 Use :meth:`GoogleV3.reverse_timezone` instead. This method will be removed in geopy 2.0. .. versionchanged:: 1.18.1 ...
geopy/geocoders/googlev3.py
def timezone(self, location, at_time=None, timeout=DEFAULT_SENTINEL): """ Find the timezone a `location` was in for a specified `at_time`, and return a pytz timezone object. .. versionadded:: 1.2.0 .. deprecated:: 1.18.0 Use :meth:`GoogleV3.reverse_timezone` instead....
def timezone(self, location, at_time=None, timeout=DEFAULT_SENTINEL): """ Find the timezone a `location` was in for a specified `at_time`, and return a pytz timezone object. .. versionadded:: 1.2.0 .. deprecated:: 1.18.0 Use :meth:`GoogleV3.reverse_timezone` instead....
[ "Find", "the", "timezone", "a", "location", "was", "in", "for", "a", "specified", "at_time", "and", "return", "a", "pytz", "timezone", "object", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/googlev3.py#L341-L390
[ "def", "timezone", "(", "self", ",", "location", ",", "at_time", "=", "None", ",", "timeout", "=", "DEFAULT_SENTINEL", ")", ":", "warnings", ".", "warn", "(", "'%(cls)s.timezone method is deprecated in favor of '", "'%(cls)s.reverse_timezone, which returns geopy.Timezone '"...
02c838d965e76497f3c3d61f53808c86b5c58224
train
GoogleV3.reverse_timezone
Find the timezone a point in `query` was in for a specified `at_time`. .. versionadded:: 1.18.0 .. versionchanged:: 1.18.1 Previously a :class:`KeyError` was raised for a point without an assigned Olson timezone id (e.g. for Antarctica). Now this method returns None fo...
geopy/geocoders/googlev3.py
def reverse_timezone(self, query, at_time=None, timeout=DEFAULT_SENTINEL): """ Find the timezone a point in `query` was in for a specified `at_time`. .. versionadded:: 1.18.0 .. versionchanged:: 1.18.1 Previously a :class:`KeyError` was raised for a point without ...
def reverse_timezone(self, query, at_time=None, timeout=DEFAULT_SENTINEL): """ Find the timezone a point in `query` was in for a specified `at_time`. .. versionadded:: 1.18.0 .. versionchanged:: 1.18.1 Previously a :class:`KeyError` was raised for a point without ...
[ "Find", "the", "timezone", "a", "point", "in", "query", "was", "in", "for", "a", "specified", "at_time", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/googlev3.py#L392-L437
[ "def", "reverse_timezone", "(", "self", ",", "query", ",", "at_time", "=", "None", ",", "timeout", "=", "DEFAULT_SENTINEL", ")", ":", "ensure_pytz_is_installed", "(", ")", "location", "=", "self", ".", "_coerce_point_to_string", "(", "query", ")", "timestamp", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
GoogleV3._parse_json
Returns location, (latitude, longitude) from json feed.
geopy/geocoders/googlev3.py
def _parse_json(self, page, exactly_one=True): '''Returns location, (latitude, longitude) from json feed.''' places = page.get('results', []) if not len(places): self._check_status(page.get('status')) return None def parse_place(place): '''Get the lo...
def _parse_json(self, page, exactly_one=True): '''Returns location, (latitude, longitude) from json feed.''' places = page.get('results', []) if not len(places): self._check_status(page.get('status')) return None def parse_place(place): '''Get the lo...
[ "Returns", "location", "(", "latitude", "longitude", ")", "from", "json", "feed", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/googlev3.py#L475-L493
[ "def", "_parse_json", "(", "self", ",", "page", ",", "exactly_one", "=", "True", ")", ":", "places", "=", "page", ".", "get", "(", "'results'", ",", "[", "]", ")", "if", "not", "len", "(", "places", ")", ":", "self", ".", "_check_status", "(", "pag...
02c838d965e76497f3c3d61f53808c86b5c58224
train
GoogleV3._check_status
Validates error statuses.
geopy/geocoders/googlev3.py
def _check_status(status): """ Validates error statuses. """ if status == 'ZERO_RESULTS': # When there are no results, just return. return if status == 'OVER_QUERY_LIMIT': raise GeocoderQuotaExceeded( 'The given key has gone ove...
def _check_status(status): """ Validates error statuses. """ if status == 'ZERO_RESULTS': # When there are no results, just return. return if status == 'OVER_QUERY_LIMIT': raise GeocoderQuotaExceeded( 'The given key has gone ove...
[ "Validates", "error", "statuses", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/googlev3.py#L496-L516
[ "def", "_check_status", "(", "status", ")", ":", "if", "status", "==", "'ZERO_RESULTS'", ":", "# When there are no results, just return.", "return", "if", "status", "==", "'OVER_QUERY_LIMIT'", ":", "raise", "GeocoderQuotaExceeded", "(", "'The given key has gone over the req...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Here.geocode
Return a location point by address. This implementation supports only a subset of all available parameters. A list of all parameters of the pure REST API is available here: https://developer.here.com/documentation/geocoder/topics/resource-geocode.html :param str query: The address or q...
geopy/geocoders/here.py
def geocode( self, query, bbox=None, mapview=None, exactly_one=True, maxresults=None, pageinformation=None, language=None, additional_data=False, timeout=DEFAULT_SENTINEL ): """ Re...
def geocode( self, query, bbox=None, mapview=None, exactly_one=True, maxresults=None, pageinformation=None, language=None, additional_data=False, timeout=DEFAULT_SENTINEL ): """ Re...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/here.py#L96-L202
[ "def", "geocode", "(", "self", ",", "query", ",", "bbox", "=", "None", ",", "mapview", "=", "None", ",", "exactly_one", "=", "True", ",", "maxresults", "=", "None", ",", "pageinformation", "=", "None", ",", "language", "=", "None", ",", "additional_data"...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Here.reverse
Return an address by location point. This implementation supports only a subset of all available parameters. A list of all parameters of the pure REST API is available here: https://developer.here.com/documentation/geocoder/topics/resource-reverse-geocode.html :param query: The coordin...
geopy/geocoders/here.py
def reverse( self, query, radius=None, exactly_one=True, maxresults=None, pageinformation=None, language=None, mode='retrieveAddresses', timeout=DEFAULT_SENTINEL ): """ Return an address by lo...
def reverse( self, query, radius=None, exactly_one=True, maxresults=None, pageinformation=None, language=None, mode='retrieveAddresses', timeout=DEFAULT_SENTINEL ): """ Return an address by lo...
[ "Return", "an", "address", "by", "location", "point", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/here.py#L204-L279
[ "def", "reverse", "(", "self", ",", "query", ",", "radius", "=", "None", ",", "exactly_one", "=", "True", ",", "maxresults", "=", "None", ",", "pageinformation", "=", "None", ",", "language", "=", "None", ",", "mode", "=", "'retrieveAddresses'", ",", "ti...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Here._parse_json
Parse a location name, latitude, and longitude from an JSON response.
geopy/geocoders/here.py
def _parse_json(doc, exactly_one=True): """ Parse a location name, latitude, and longitude from an JSON response. """ status_code = doc.get("statusCode", 200) if status_code != 200: err = doc.get("errorDetails", "") if status_code == 401: r...
def _parse_json(doc, exactly_one=True): """ Parse a location name, latitude, and longitude from an JSON response. """ status_code = doc.get("statusCode", 200) if status_code != 200: err = doc.get("errorDetails", "") if status_code == 401: r...
[ "Parse", "a", "location", "name", "latitude", "and", "longitude", "from", "an", "JSON", "response", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/here.py#L282-L333
[ "def", "_parse_json", "(", "doc", ",", "exactly_one", "=", "True", ")", ":", "status_code", "=", "doc", ".", "get", "(", "\"statusCode\"", ",", "200", ")", "if", "status_code", "!=", "200", ":", "err", "=", "doc", ".", "get", "(", "\"errorDetails\"", "...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Geocoder._coerce_point_to_string
Do the right thing on "point" input. For geocoders with reverse methods.
geopy/geocoders/base.py
def _coerce_point_to_string(point, output_format="%(lat)s,%(lon)s"): """ Do the right thing on "point" input. For geocoders with reverse methods. """ try: if not isinstance(point, Point): point = Point(point) except ValueError as e: ...
def _coerce_point_to_string(point, output_format="%(lat)s,%(lon)s"): """ Do the right thing on "point" input. For geocoders with reverse methods. """ try: if not isinstance(point, Point): point = Point(point) except ValueError as e: ...
[ "Do", "the", "right", "thing", "on", "point", "input", ".", "For", "geocoders", "with", "reverse", "methods", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/base.py#L254-L274
[ "def", "_coerce_point_to_string", "(", "point", ",", "output_format", "=", "\"%(lat)s,%(lon)s\"", ")", ":", "try", ":", "if", "not", "isinstance", "(", "point", ",", "Point", ")", ":", "point", "=", "Point", "(", "point", ")", "except", "ValueError", "as", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Geocoder._format_bounding_box
Transform bounding box boundaries to a string matching `output_format` from the following formats: - [Point(lat1, lon1), Point(lat2, lon2)] - [[lat1, lon1], [lat2, lon2]] - ["lat1,lon1", "lat2,lon2"] It is guaranteed that lat1 <= lat2 and lon1 <= lon2.
geopy/geocoders/base.py
def _format_bounding_box(bbox, output_format="%(lat1)s,%(lon1)s,%(lat2)s,%(lon2)s"): """ Transform bounding box boundaries to a string matching `output_format` from the following formats: - [Point(lat1, lon1), Point(lat2, lon2)] - [[lat1, lon1], [lat2, lon2]] ...
def _format_bounding_box(bbox, output_format="%(lat1)s,%(lon1)s,%(lat2)s,%(lon2)s"): """ Transform bounding box boundaries to a string matching `output_format` from the following formats: - [Point(lat1, lon1), Point(lat2, lon2)] - [[lat1, lon1], [lat2, lon2]] ...
[ "Transform", "bounding", "box", "boundaries", "to", "a", "string", "matching", "output_format", "from", "the", "following", "formats", ":" ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/base.py#L277-L295
[ "def", "_format_bounding_box", "(", "bbox", ",", "output_format", "=", "\"%(lat1)s,%(lon1)s,%(lat2)s,%(lon2)s\"", ")", ":", "if", "len", "(", "bbox", ")", "!=", "2", ":", "raise", "GeocoderQueryError", "(", "\"Unsupported format for a bounding box\"", ")", "p1", ",", ...
02c838d965e76497f3c3d61f53808c86b5c58224
train
Geocoder._call_geocoder
For a generated query URL, get the results.
geopy/geocoders/base.py
def _call_geocoder( self, url, timeout=DEFAULT_SENTINEL, raw=False, requester=None, deserializer=json.loads, **kwargs ): """ For a generated query URL, get the results. """ if requester: ...
def _call_geocoder( self, url, timeout=DEFAULT_SENTINEL, raw=False, requester=None, deserializer=json.loads, **kwargs ): """ For a generated query URL, get the results. """ if requester: ...
[ "For", "a", "generated", "query", "URL", "get", "the", "results", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/base.py#L306-L410
[ "def", "_call_geocoder", "(", "self", ",", "url", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", "raw", "=", "False", ",", "requester", "=", "None", ",", "deserializer", "=", "json", ".", "loads", ",", "*", "*", "kwargs", ")", ":", "if", "requester", ":...
02c838d965e76497f3c3d61f53808c86b5c58224
train
OpenCage.geocode
Return a location point by address. :param str query: The address or query you wish to geocode. :param str language: an IETF format language code (such as `es` for Spanish or pt-BR for Brazilian Portuguese); if this is omitted a code of `en` (English) will be assumed by the rem...
geopy/geocoders/opencage.py
def geocode( self, query, bounds=None, country=None, language=None, exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. :param str query: The address or query you wish to g...
def geocode( self, query, bounds=None, country=None, language=None, exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. :param str query: The address or query you wish to g...
[ "Return", "a", "location", "point", "by", "address", "." ]
geopy/geopy
python
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/opencage.py#L82-L174
[ "def", "geocode", "(", "self", ",", "query", ",", "bounds", "=", "None", ",", "country", "=", "None", ",", "language", "=", "None", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ",", ")", ":", "params", "=", "{", "'key'", ...
02c838d965e76497f3c3d61f53808c86b5c58224