text
stringlengths
0
828
Adds the node with the given name to the graph.
Arguments:
node_name (str): The name of the node to add to the graph.
external_id (Optional[str]): The external ID of the node.
""""""
self._nodes.add_node_by_name(node_name, external_id)"
4444,"def get_authentic_node_name(self, node_name: str) -> Optional[str]:
""""""
Returns the exact, authentic node name for the given node name if a node corresponding to
the given name exists in the graph (maybe not locally yet) or `None` otherwise.
By default, this method checks whether a node with the given name exists locally in the
graph and return `node_name` if it does or `None` otherwise.
In `Graph` extensions that are used by applications where the user can enter potentially
incorrect node names, this method should be overridden to improve usability.
Arguments:
node_name (str): The node name to return the authentic node name for.
Returns:
The authentic name of the node corresponding to the given node name or
`None` if no such node exists.
""""""
node: Node = self._nodes.get_node_by_name(node_name)
return node.name if node is not None else None"
4445,"def beforeSummaryReport(self, event):
'''Output profiling results'''
self.prof.disable()
stats = pstats.Stats(self.prof, stream=event.stream).sort_stats(
self.sort)
event.stream.writeln(nose2.util.ln('Profiling results'))
stats.print_stats()
if self.pfile:
stats.dump_stats(self.pfile)
if self.cachegrind:
visualize(self.prof.getstats())"
4446,"def separate(text):
'''Takes text and separates it into a list of words'''
alphabet = 'abcdefghijklmnopqrstuvwxyz'
words = text.split()
standardwords = []
for word in words:
newstr = ''
for char in word:
if char in alphabet or char in alphabet.upper():
newstr += char
if newstr != '':
standardwords.append(newstr)
return map(lambda x: x.lower(),standardwords)"
4447,"def eliminate_repeats(text):
'''Returns a list of words that occur in the text. Eliminates stopwords.'''
bannedwords = read_file('stopwords.txt')
alphabet = 'abcdefghijklmnopqrstuvwxyz'
words = text.split()
standardwords = []
for word in words:
newstr = ''
for char in word:
if char in alphabet or char in alphabet.upper():
newstr += char
if newstr not in standardwords and newstr != '' and newstr not in bannedwords:
standardwords.append(newstr)
return map(lambda x: x.lower(),standardwords)"
4448,"def wordcount(text):
'''Returns the count of the words in a file.'''
bannedwords = read_file('stopwords.txt')
wordcount = {}
separated = separate(text)
for word in separated:
if word not in bannedwords:
if not wordcount.has_key(word):
wordcount[word] = 1
else:
wordcount[word] += 1
return wordcount"
4449,"def tuplecount(text):
'''Changes a dictionary into a list of tuples.'''
worddict = wordcount(text)
countlist = []
for key in worddict.keys():
countlist.append((key,worddict[key]))
countlist = list(reversed(sorted(countlist,key = lambda x: x[1])))
return countlist"
4450,"def add_log_error(self, x, flag_also_show=False, E=None):
""""""Delegates to parent form""""""
self.parent_form.add_log_error(x, flag_also_show, E)"
4451,"def add_log(self, x, flag_also_show=False):
""""""Delegates to parent form""""""
self.parent_form.add_log(x, flag_also_show)"
4452,"def get_file_md5(filename):
""""""Get a file's MD5""""""
if os.path.exists(filename):
blocksize = 65536
try:
hasher = hashlib.md5()
except BaseException: