id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15,200 | jeongyoonlee/Kaggler | kaggler/model/nn.py | NN.fprime | def fprime(self, w, *args):
"""Return the derivatives of the cost function for predictions.
Args:
w (array of float): weight vectors such that:
w[:-h1] -- weights between the input and h layers
w[-h1:] -- weights between the h and output layers
ar... | python | def fprime(self, w, *args):
"""Return the derivatives of the cost function for predictions.
Args:
w (array of float): weight vectors such that:
w[:-h1] -- weights between the input and h layers
w[-h1:] -- weights between the h and output layers
ar... | [
"def",
"fprime",
"(",
"self",
",",
"w",
",",
"*",
"args",
")",
":",
"x0",
"=",
"args",
"[",
"0",
"]",
"x1",
"=",
"args",
"[",
"1",
"]",
"n0",
"=",
"x0",
".",
"shape",
"[",
"0",
"]",
"n1",
"=",
"x1",
".",
"shape",
"[",
"0",
"]",
"# n -- nu... | Return the derivatives of the cost function for predictions.
Args:
w (array of float): weight vectors such that:
w[:-h1] -- weights between the input and h layers
w[-h1:] -- weights between the h and output layers
args: features (args[0]) and target (args... | [
"Return",
"the",
"derivatives",
"of",
"the",
"cost",
"function",
"for",
"predictions",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/model/nn.py#L258-L320 |
15,201 | jeongyoonlee/Kaggler | kaggler/preprocessing/data.py | Normalizer._transform_col | def _transform_col(self, x, col):
"""Normalize one numerical column.
Args:
x (numpy.array): a numerical column to normalize
col (int): column index
Returns:
A normalized feature vector.
"""
return norm.ppf(self.ecdfs[col](x) * .998 + .001) | python | def _transform_col(self, x, col):
"""Normalize one numerical column.
Args:
x (numpy.array): a numerical column to normalize
col (int): column index
Returns:
A normalized feature vector.
"""
return norm.ppf(self.ecdfs[col](x) * .998 + .001) | [
"def",
"_transform_col",
"(",
"self",
",",
"x",
",",
"col",
")",
":",
"return",
"norm",
".",
"ppf",
"(",
"self",
".",
"ecdfs",
"[",
"col",
"]",
"(",
"x",
")",
"*",
".998",
"+",
".001",
")"
] | Normalize one numerical column.
Args:
x (numpy.array): a numerical column to normalize
col (int): column index
Returns:
A normalized feature vector. | [
"Normalize",
"one",
"numerical",
"column",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/preprocessing/data.py#L66-L77 |
15,202 | jeongyoonlee/Kaggler | kaggler/preprocessing/data.py | LabelEncoder._get_label_encoder_and_max | def _get_label_encoder_and_max(self, x):
"""Return a mapping from values and its maximum of a column to integer labels.
Args:
x (pandas.Series): a categorical column to encode.
Returns:
label_encoder (dict): mapping from values of features to integers
max_la... | python | def _get_label_encoder_and_max(self, x):
"""Return a mapping from values and its maximum of a column to integer labels.
Args:
x (pandas.Series): a categorical column to encode.
Returns:
label_encoder (dict): mapping from values of features to integers
max_la... | [
"def",
"_get_label_encoder_and_max",
"(",
"self",
",",
"x",
")",
":",
"# NaN cannot be used as a key for dict. So replace it with a random integer.",
"label_count",
"=",
"x",
".",
"fillna",
"(",
"NAN_INT",
")",
".",
"value_counts",
"(",
")",
"n_uniq",
"=",
"label_count"... | Return a mapping from values and its maximum of a column to integer labels.
Args:
x (pandas.Series): a categorical column to encode.
Returns:
label_encoder (dict): mapping from values of features to integers
max_label (int): maximum label | [
"Return",
"a",
"mapping",
"from",
"values",
"and",
"its",
"maximum",
"of",
"a",
"column",
"to",
"integer",
"labels",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/preprocessing/data.py#L101-L128 |
15,203 | jeongyoonlee/Kaggler | kaggler/preprocessing/data.py | LabelEncoder._transform_col | def _transform_col(self, x, i):
"""Encode one categorical column into labels.
Args:
x (pandas.Series): a categorical column to encode
i (int): column index
Returns:
x (pandas.Series): a column with labels.
"""
return x.fillna(NAN_INT).map(sel... | python | def _transform_col(self, x, i):
"""Encode one categorical column into labels.
Args:
x (pandas.Series): a categorical column to encode
i (int): column index
Returns:
x (pandas.Series): a column with labels.
"""
return x.fillna(NAN_INT).map(sel... | [
"def",
"_transform_col",
"(",
"self",
",",
"x",
",",
"i",
")",
":",
"return",
"x",
".",
"fillna",
"(",
"NAN_INT",
")",
".",
"map",
"(",
"self",
".",
"label_encoders",
"[",
"i",
"]",
")",
".",
"fillna",
"(",
"0",
")"
] | Encode one categorical column into labels.
Args:
x (pandas.Series): a categorical column to encode
i (int): column index
Returns:
x (pandas.Series): a column with labels. | [
"Encode",
"one",
"categorical",
"column",
"into",
"labels",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/preprocessing/data.py#L130-L140 |
15,204 | jeongyoonlee/Kaggler | kaggler/preprocessing/data.py | OneHotEncoder._transform_col | def _transform_col(self, x, i):
"""Encode one categorical column into sparse matrix with one-hot-encoding.
Args:
x (pandas.Series): a categorical column to encode
i (int): column index
Returns:
X (scipy.sparse.coo_matrix): sparse matrix encoding a categorica... | python | def _transform_col(self, x, i):
"""Encode one categorical column into sparse matrix with one-hot-encoding.
Args:
x (pandas.Series): a categorical column to encode
i (int): column index
Returns:
X (scipy.sparse.coo_matrix): sparse matrix encoding a categorica... | [
"def",
"_transform_col",
"(",
"self",
",",
"x",
",",
"i",
")",
":",
"labels",
"=",
"self",
".",
"label_encoder",
".",
"_transform_col",
"(",
"x",
",",
"i",
")",
"label_max",
"=",
"self",
".",
"label_encoder",
".",
"label_maxes",
"[",
"i",
"]",
"# build... | Encode one categorical column into sparse matrix with one-hot-encoding.
Args:
x (pandas.Series): a categorical column to encode
i (int): column index
Returns:
X (scipy.sparse.coo_matrix): sparse matrix encoding a categorical
... | [
"Encode",
"one",
"categorical",
"column",
"into",
"sparse",
"matrix",
"with",
"one",
"-",
"hot",
"-",
"encoding",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/preprocessing/data.py#L212-L237 |
15,205 | jeongyoonlee/Kaggler | kaggler/preprocessing/data.py | OneHotEncoder.transform | def transform(self, X):
"""Encode categorical columns into sparse matrix with one-hot-encoding.
Args:
X (pandas.DataFrame): categorical columns to encode
Returns:
X_new (scipy.sparse.coo_matrix): sparse matrix encoding categorical
... | python | def transform(self, X):
"""Encode categorical columns into sparse matrix with one-hot-encoding.
Args:
X (pandas.DataFrame): categorical columns to encode
Returns:
X_new (scipy.sparse.coo_matrix): sparse matrix encoding categorical
... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"for",
"i",
",",
"col",
"in",
"enumerate",
"(",
"X",
".",
"columns",
")",
":",
"X_col",
"=",
"self",
".",
"_transform_col",
"(",
"X",
"[",
"col",
"]",
",",
"i",
")",
"if",
"X_col",
"is",
"not... | Encode categorical columns into sparse matrix with one-hot-encoding.
Args:
X (pandas.DataFrame): categorical columns to encode
Returns:
X_new (scipy.sparse.coo_matrix): sparse matrix encoding categorical
variables into dummy variable... | [
"Encode",
"categorical",
"columns",
"into",
"sparse",
"matrix",
"with",
"one",
"-",
"hot",
"-",
"encoding",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/preprocessing/data.py#L244-L267 |
15,206 | jeongyoonlee/Kaggler | kaggler/online_model/DecisionTree/OnlineClassificationTree.py | ClassificationTree.predict | def predict(self, x):
"""
Make prediction recursively. Use both the samples inside the current
node and the statistics inherited from parent.
"""
if self._is_leaf():
d1 = self.predict_initialize['count_dict']
d2 = count_dict(self.Y)
for key, va... | python | def predict(self, x):
"""
Make prediction recursively. Use both the samples inside the current
node and the statistics inherited from parent.
"""
if self._is_leaf():
d1 = self.predict_initialize['count_dict']
d2 = count_dict(self.Y)
for key, va... | [
"def",
"predict",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"_is_leaf",
"(",
")",
":",
"d1",
"=",
"self",
".",
"predict_initialize",
"[",
"'count_dict'",
"]",
"d2",
"=",
"count_dict",
"(",
"self",
".",
"Y",
")",
"for",
"key",
",",
"value"... | Make prediction recursively. Use both the samples inside the current
node and the statistics inherited from parent. | [
"Make",
"prediction",
"recursively",
".",
"Use",
"both",
"the",
"samples",
"inside",
"the",
"current",
"node",
"and",
"the",
"statistics",
"inherited",
"from",
"parent",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/online_model/DecisionTree/OnlineClassificationTree.py#L74-L92 |
15,207 | jeongyoonlee/Kaggler | kaggler/ensemble/linear.py | netflix | def netflix(es, ps, e0, l=.0001):
"""
Combine predictions with the optimal weights to minimize RMSE.
Args:
es (list of float): RMSEs of predictions
ps (list of np.array): predictions
e0 (float): RMSE of all zero prediction
l (float): lambda as in the ridge regression
Re... | python | def netflix(es, ps, e0, l=.0001):
"""
Combine predictions with the optimal weights to minimize RMSE.
Args:
es (list of float): RMSEs of predictions
ps (list of np.array): predictions
e0 (float): RMSE of all zero prediction
l (float): lambda as in the ridge regression
Re... | [
"def",
"netflix",
"(",
"es",
",",
"ps",
",",
"e0",
",",
"l",
"=",
".0001",
")",
":",
"m",
"=",
"len",
"(",
"es",
")",
"n",
"=",
"len",
"(",
"ps",
"[",
"0",
"]",
")",
"X",
"=",
"np",
".",
"stack",
"(",
"ps",
")",
".",
"T",
"pTy",
"=",
... | Combine predictions with the optimal weights to minimize RMSE.
Args:
es (list of float): RMSEs of predictions
ps (list of np.array): predictions
e0 (float): RMSE of all zero prediction
l (float): lambda as in the ridge regression
Returns:
Ensemble prediction (np.array) ... | [
"Combine",
"predictions",
"with",
"the",
"optimal",
"weights",
"to",
"minimize",
"RMSE",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/ensemble/linear.py#L7-L28 |
15,208 | jeongyoonlee/Kaggler | kaggler/data_io.py | save_data | def save_data(X, y, path):
"""Save data as a CSV, LibSVM or HDF5 file based on the file extension.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector. If None, all zero vector will be saved.
path (str): Path to the CSV, LibSVM or HDF5 file to save data.
... | python | def save_data(X, y, path):
"""Save data as a CSV, LibSVM or HDF5 file based on the file extension.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector. If None, all zero vector will be saved.
path (str): Path to the CSV, LibSVM or HDF5 file to save data.
... | [
"def",
"save_data",
"(",
"X",
",",
"y",
",",
"path",
")",
":",
"catalog",
"=",
"{",
"'.csv'",
":",
"save_csv",
",",
"'.sps'",
":",
"save_libsvm",
",",
"'.h5'",
":",
"save_hdf5",
"}",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")",... | Save data as a CSV, LibSVM or HDF5 file based on the file extension.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector. If None, all zero vector will be saved.
path (str): Path to the CSV, LibSVM or HDF5 file to save data. | [
"Save",
"data",
"as",
"a",
"CSV",
"LibSVM",
"or",
"HDF5",
"file",
"based",
"on",
"the",
"file",
"extension",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L34-L50 |
15,209 | jeongyoonlee/Kaggler | kaggler/data_io.py | save_csv | def save_csv(X, y, path):
"""Save data as a CSV file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data.
"""
if sparse.issparse(X):
X = X.todense()
np.savetxt(path, np.hstack((y.reshape... | python | def save_csv(X, y, path):
"""Save data as a CSV file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data.
"""
if sparse.issparse(X):
X = X.todense()
np.savetxt(path, np.hstack((y.reshape... | [
"def",
"save_csv",
"(",
"X",
",",
"y",
",",
"path",
")",
":",
"if",
"sparse",
".",
"issparse",
"(",
"X",
")",
":",
"X",
"=",
"X",
".",
"todense",
"(",
")",
"np",
".",
"savetxt",
"(",
"path",
",",
"np",
".",
"hstack",
"(",
"(",
"y",
".",
"re... | Save data as a CSV file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data. | [
"Save",
"data",
"as",
"a",
"CSV",
"file",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L53-L65 |
15,210 | jeongyoonlee/Kaggler | kaggler/data_io.py | save_libsvm | def save_libsvm(X, y, path):
"""Save data as a LibSVM file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data.
"""
dump_svmlight_file(X, y, path, zero_based=False) | python | def save_libsvm(X, y, path):
"""Save data as a LibSVM file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data.
"""
dump_svmlight_file(X, y, path, zero_based=False) | [
"def",
"save_libsvm",
"(",
"X",
",",
"y",
",",
"path",
")",
":",
"dump_svmlight_file",
"(",
"X",
",",
"y",
",",
"path",
",",
"zero_based",
"=",
"False",
")"
] | Save data as a LibSVM file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data. | [
"Save",
"data",
"as",
"a",
"LibSVM",
"file",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L68-L77 |
15,211 | jeongyoonlee/Kaggler | kaggler/data_io.py | save_hdf5 | def save_hdf5(X, y, path):
"""Save data as a HDF5 file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the HDF5 file to save data.
"""
with h5py.File(path, 'w') as f:
is_sparse = 1 if sparse.issparse(X) else 0
... | python | def save_hdf5(X, y, path):
"""Save data as a HDF5 file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the HDF5 file to save data.
"""
with h5py.File(path, 'w') as f:
is_sparse = 1 if sparse.issparse(X) else 0
... | [
"def",
"save_hdf5",
"(",
"X",
",",
"y",
",",
"path",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"is_sparse",
"=",
"1",
"if",
"sparse",
".",
"issparse",
"(",
"X",
")",
"else",
"0",
"f",
"[",
"'issparse'"... | Save data as a HDF5 file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the HDF5 file to save data. | [
"Save",
"data",
"as",
"a",
"HDF5",
"file",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L80-L103 |
15,212 | jeongyoonlee/Kaggler | kaggler/data_io.py | load_data | def load_data(path, dense=False):
"""Load data from a CSV, LibSVM or HDF5 file based on the file extension.
Args:
path (str): A path to the CSV, LibSVM or HDF5 format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be d... | python | def load_data(path, dense=False):
"""Load data from a CSV, LibSVM or HDF5 file based on the file extension.
Args:
path (str): A path to the CSV, LibSVM or HDF5 format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be d... | [
"def",
"load_data",
"(",
"path",
",",
"dense",
"=",
"False",
")",
":",
"catalog",
"=",
"{",
"'.csv'",
":",
"load_csv",
",",
"'.sps'",
":",
"load_svmlight_file",
",",
"'.h5'",
":",
"load_hdf5",
"}",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
... | Load data from a CSV, LibSVM or HDF5 file based on the file extension.
Args:
path (str): A path to the CSV, LibSVM or HDF5 format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be dense. By default, it is false.
Retu... | [
"Load",
"data",
"from",
"a",
"CSV",
"LibSVM",
"or",
"HDF5",
"file",
"based",
"on",
"the",
"file",
"extension",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L106-L127 |
15,213 | jeongyoonlee/Kaggler | kaggler/data_io.py | load_csv | def load_csv(path):
"""Load data from a CSV file.
Args:
path (str): A path to the CSV format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be dense. By default, it is false.
Returns:
Data matrix X and ta... | python | def load_csv(path):
"""Load data from a CSV file.
Args:
path (str): A path to the CSV format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be dense. By default, it is false.
Returns:
Data matrix X and ta... | [
"def",
"load_csv",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"line",
"=",
"f",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"X",
"=",
"np",
".",
"loadtxt",
"(",
"path",
",",
"delimiter",
"=",
"','",
",",
"... | Load data from a CSV file.
Args:
path (str): A path to the CSV format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be dense. By default, it is false.
Returns:
Data matrix X and target vector y | [
"Load",
"data",
"from",
"a",
"CSV",
"file",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L130-L151 |
15,214 | jeongyoonlee/Kaggler | kaggler/data_io.py | load_hdf5 | def load_hdf5(path):
"""Load data from a HDF5 file.
Args:
path (str): A path to the HDF5 format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be dense. By default, it is false.
Returns:
Data matrix X and... | python | def load_hdf5(path):
"""Load data from a HDF5 file.
Args:
path (str): A path to the HDF5 format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be dense. By default, it is false.
Returns:
Data matrix X and... | [
"def",
"load_hdf5",
"(",
"path",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"is_sparse",
"=",
"f",
"[",
"'issparse'",
"]",
"[",
"...",
"]",
"if",
"is_sparse",
":",
"shape",
"=",
"tuple",
"(",
"f",
"[",
... | Load data from a HDF5 file.
Args:
path (str): A path to the HDF5 format file containing data.
dense (boolean): An optional variable indicating if the return matrix
should be dense. By default, it is false.
Returns:
Data matrix X and target vector y | [
"Load",
"data",
"from",
"a",
"HDF5",
"file",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L154-L179 |
15,215 | jeongyoonlee/Kaggler | kaggler/data_io.py | read_sps | def read_sps(path):
"""Read a LibSVM file line-by-line.
Args:
path (str): A path to the LibSVM file to read.
Yields:
data (list) and target (int).
"""
for line in open(path):
# parse x
xs = line.rstrip().split(' ')
yield xs[1:], int(xs[0]) | python | def read_sps(path):
"""Read a LibSVM file line-by-line.
Args:
path (str): A path to the LibSVM file to read.
Yields:
data (list) and target (int).
"""
for line in open(path):
# parse x
xs = line.rstrip().split(' ')
yield xs[1:], int(xs[0]) | [
"def",
"read_sps",
"(",
"path",
")",
":",
"for",
"line",
"in",
"open",
"(",
"path",
")",
":",
"# parse x",
"xs",
"=",
"line",
".",
"rstrip",
"(",
")",
".",
"split",
"(",
"' '",
")",
"yield",
"xs",
"[",
"1",
":",
"]",
",",
"int",
"(",
"xs",
"[... | Read a LibSVM file line-by-line.
Args:
path (str): A path to the LibSVM file to read.
Yields:
data (list) and target (int). | [
"Read",
"a",
"LibSVM",
"file",
"line",
"-",
"by",
"-",
"line",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L182-L196 |
15,216 | jeongyoonlee/Kaggler | kaggler/metrics/regression.py | gini | def gini(y, p):
"""Normalized Gini Coefficient.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
e (numpy.float64): normalized Gini coefficient
"""
# check and get number of samples
assert y.shape == p.shape
n_samples = y.shape[0]
# sort row... | python | def gini(y, p):
"""Normalized Gini Coefficient.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
e (numpy.float64): normalized Gini coefficient
"""
# check and get number of samples
assert y.shape == p.shape
n_samples = y.shape[0]
# sort row... | [
"def",
"gini",
"(",
"y",
",",
"p",
")",
":",
"# check and get number of samples",
"assert",
"y",
".",
"shape",
"==",
"p",
".",
"shape",
"n_samples",
"=",
"y",
".",
"shape",
"[",
"0",
"]",
"# sort rows on prediction column",
"# (from largest to smallest)",
"arr",... | Normalized Gini Coefficient.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
e (numpy.float64): normalized Gini coefficient | [
"Normalized",
"Gini",
"Coefficient",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/metrics/regression.py#L46-L78 |
15,217 | jeongyoonlee/Kaggler | kaggler/metrics/classification.py | logloss | def logloss(y, p):
"""Bounded log loss error.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
bounded log loss error
"""
p[p < EPS] = EPS
p[p > 1 - EPS] = 1 - EPS
return log_loss(y, p) | python | def logloss(y, p):
"""Bounded log loss error.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
bounded log loss error
"""
p[p < EPS] = EPS
p[p > 1 - EPS] = 1 - EPS
return log_loss(y, p) | [
"def",
"logloss",
"(",
"y",
",",
"p",
")",
":",
"p",
"[",
"p",
"<",
"EPS",
"]",
"=",
"EPS",
"p",
"[",
"p",
">",
"1",
"-",
"EPS",
"]",
"=",
"1",
"-",
"EPS",
"return",
"log_loss",
"(",
"y",
",",
"p",
")"
] | Bounded log loss error.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
bounded log loss error | [
"Bounded",
"log",
"loss",
"error",
"."
] | 20661105b61958dc9a3c529c1d3b2313ab23ae32 | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/metrics/classification.py#L10-L23 |
15,218 | vividvilla/csvtotable | csvtotable/convert.py | convert | def convert(input_file_name, **kwargs):
"""Convert CSV file to HTML table"""
delimiter = kwargs["delimiter"] or ","
quotechar = kwargs["quotechar"] or "|"
if six.PY2:
delimiter = delimiter.encode("utf-8")
quotechar = quotechar.encode("utf-8")
# Read CSV and form a header and rows l... | python | def convert(input_file_name, **kwargs):
"""Convert CSV file to HTML table"""
delimiter = kwargs["delimiter"] or ","
quotechar = kwargs["quotechar"] or "|"
if six.PY2:
delimiter = delimiter.encode("utf-8")
quotechar = quotechar.encode("utf-8")
# Read CSV and form a header and rows l... | [
"def",
"convert",
"(",
"input_file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"delimiter",
"=",
"kwargs",
"[",
"\"delimiter\"",
"]",
"or",
"\",\"",
"quotechar",
"=",
"kwargs",
"[",
"\"quotechar\"",
"]",
"or",
"\"|\"",
"if",
"six",
".",
"PY2",
":",
"delimi... | Convert CSV file to HTML table | [
"Convert",
"CSV",
"file",
"to",
"HTML",
"table"
] | d894dca1fcc1071c9a52260a9194f8cc3b327905 | https://github.com/vividvilla/csvtotable/blob/d894dca1fcc1071c9a52260a9194f8cc3b327905/csvtotable/convert.py#L36-L68 |
15,219 | vividvilla/csvtotable | csvtotable/convert.py | save | def save(file_name, content):
"""Save content to a file"""
with open(file_name, "w", encoding="utf-8") as output_file:
output_file.write(content)
return output_file.name | python | def save(file_name, content):
"""Save content to a file"""
with open(file_name, "w", encoding="utf-8") as output_file:
output_file.write(content)
return output_file.name | [
"def",
"save",
"(",
"file_name",
",",
"content",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"\"w\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"as",
"output_file",
":",
"output_file",
".",
"write",
"(",
"content",
")",
"return",
"output_file",
".",
"... | Save content to a file | [
"Save",
"content",
"to",
"a",
"file"
] | d894dca1fcc1071c9a52260a9194f8cc3b327905 | https://github.com/vividvilla/csvtotable/blob/d894dca1fcc1071c9a52260a9194f8cc3b327905/csvtotable/convert.py#L71-L75 |
15,220 | vividvilla/csvtotable | csvtotable/convert.py | serve | def serve(content):
"""Write content to a temp file and serve it in browser"""
temp_folder = tempfile.gettempdir()
temp_file_name = tempfile.gettempprefix() + str(uuid.uuid4()) + ".html"
# Generate a file path with a random name in temporary dir
temp_file_path = os.path.join(temp_folder, temp_file_n... | python | def serve(content):
"""Write content to a temp file and serve it in browser"""
temp_folder = tempfile.gettempdir()
temp_file_name = tempfile.gettempprefix() + str(uuid.uuid4()) + ".html"
# Generate a file path with a random name in temporary dir
temp_file_path = os.path.join(temp_folder, temp_file_n... | [
"def",
"serve",
"(",
"content",
")",
":",
"temp_folder",
"=",
"tempfile",
".",
"gettempdir",
"(",
")",
"temp_file_name",
"=",
"tempfile",
".",
"gettempprefix",
"(",
")",
"+",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"+",
"\".html\"",
"# Generate ... | Write content to a temp file and serve it in browser | [
"Write",
"content",
"to",
"a",
"temp",
"file",
"and",
"serve",
"it",
"in",
"browser"
] | d894dca1fcc1071c9a52260a9194f8cc3b327905 | https://github.com/vividvilla/csvtotable/blob/d894dca1fcc1071c9a52260a9194f8cc3b327905/csvtotable/convert.py#L78-L97 |
15,221 | vividvilla/csvtotable | csvtotable/convert.py | render_template | def render_template(table_headers, table_items, **options):
"""
Render Jinja2 template
"""
caption = options.get("caption") or "Table"
display_length = options.get("display_length") or -1
height = options.get("height") or "70vh"
default_length_menu = [-1, 10, 25, 50]
pagination = options... | python | def render_template(table_headers, table_items, **options):
"""
Render Jinja2 template
"""
caption = options.get("caption") or "Table"
display_length = options.get("display_length") or -1
height = options.get("height") or "70vh"
default_length_menu = [-1, 10, 25, 50]
pagination = options... | [
"def",
"render_template",
"(",
"table_headers",
",",
"table_items",
",",
"*",
"*",
"options",
")",
":",
"caption",
"=",
"options",
".",
"get",
"(",
"\"caption\"",
")",
"or",
"\"Table\"",
"display_length",
"=",
"options",
".",
"get",
"(",
"\"display_length\"",
... | Render Jinja2 template | [
"Render",
"Jinja2",
"template"
] | d894dca1fcc1071c9a52260a9194f8cc3b327905 | https://github.com/vividvilla/csvtotable/blob/d894dca1fcc1071c9a52260a9194f8cc3b327905/csvtotable/convert.py#L100-L193 |
15,222 | vividvilla/csvtotable | csvtotable/convert.py | freeze_js | def freeze_js(html):
"""
Freeze all JS assets to the rendered html itself.
"""
matches = js_src_pattern.finditer(html)
if not matches:
return html
# Reverse regex matches to replace match string with respective JS content
for match in reversed(tuple(matches)):
# JS file nam... | python | def freeze_js(html):
"""
Freeze all JS assets to the rendered html itself.
"""
matches = js_src_pattern.finditer(html)
if not matches:
return html
# Reverse regex matches to replace match string with respective JS content
for match in reversed(tuple(matches)):
# JS file nam... | [
"def",
"freeze_js",
"(",
"html",
")",
":",
"matches",
"=",
"js_src_pattern",
".",
"finditer",
"(",
"html",
")",
"if",
"not",
"matches",
":",
"return",
"html",
"# Reverse regex matches to replace match string with respective JS content",
"for",
"match",
"in",
"reversed... | Freeze all JS assets to the rendered html itself. | [
"Freeze",
"all",
"JS",
"assets",
"to",
"the",
"rendered",
"html",
"itself",
"."
] | d894dca1fcc1071c9a52260a9194f8cc3b327905 | https://github.com/vividvilla/csvtotable/blob/d894dca1fcc1071c9a52260a9194f8cc3b327905/csvtotable/convert.py#L196-L218 |
15,223 | vividvilla/csvtotable | csvtotable/cli.py | cli | def cli(*args, **kwargs):
"""
CSVtoTable commandline utility.
"""
# Convert CSV file
content = convert.convert(kwargs["input_file"], **kwargs)
# Serve the temporary file in browser.
if kwargs["serve"]:
convert.serve(content)
# Write to output file
elif kwargs["output_file"]:... | python | def cli(*args, **kwargs):
"""
CSVtoTable commandline utility.
"""
# Convert CSV file
content = convert.convert(kwargs["input_file"], **kwargs)
# Serve the temporary file in browser.
if kwargs["serve"]:
convert.serve(content)
# Write to output file
elif kwargs["output_file"]:... | [
"def",
"cli",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Convert CSV file",
"content",
"=",
"convert",
".",
"convert",
"(",
"kwargs",
"[",
"\"input_file\"",
"]",
",",
"*",
"*",
"kwargs",
")",
"# Serve the temporary file in browser.",
"if",
"kwar... | CSVtoTable commandline utility. | [
"CSVtoTable",
"commandline",
"utility",
"."
] | d894dca1fcc1071c9a52260a9194f8cc3b327905 | https://github.com/vividvilla/csvtotable/blob/d894dca1fcc1071c9a52260a9194f8cc3b327905/csvtotable/cli.py#L54-L76 |
15,224 | django-userena-ce/django-userena-ce | userena/views.py | activate_retry | def activate_retry(request, activation_key,
template_name='userena/activate_retry_success.html',
extra_context=None):
"""
Reissue a new ``activation_key`` for the user with the expired
``activation_key``.
If ``activation_key`` does not exists, or ``USERENA_ACTIVATI... | python | def activate_retry(request, activation_key,
template_name='userena/activate_retry_success.html',
extra_context=None):
"""
Reissue a new ``activation_key`` for the user with the expired
``activation_key``.
If ``activation_key`` does not exists, or ``USERENA_ACTIVATI... | [
"def",
"activate_retry",
"(",
"request",
",",
"activation_key",
",",
"template_name",
"=",
"'userena/activate_retry_success.html'",
",",
"extra_context",
"=",
"None",
")",
":",
"if",
"not",
"userena_settings",
".",
"USERENA_ACTIVATION_RETRY",
":",
"return",
"redirect",
... | Reissue a new ``activation_key`` for the user with the expired
``activation_key``.
If ``activation_key`` does not exists, or ``USERENA_ACTIVATION_RETRY`` is
set to False and for any other error condition user is redirected to
:func:`activate` for error message display.
:param activation_key:
... | [
"Reissue",
"a",
"new",
"activation_key",
"for",
"the",
"user",
"with",
"the",
"expired",
"activation_key",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/views.py#L227-L267 |
15,225 | django-userena-ce/django-userena-ce | userena/views.py | disabled_account | def disabled_account(request, username, template_name, extra_context=None):
"""
Checks if the account is disabled, if so, returns the disabled account template.
:param username:
String defining the username of the user that made the action.
:param template_name:
String defining the nam... | python | def disabled_account(request, username, template_name, extra_context=None):
"""
Checks if the account is disabled, if so, returns the disabled account template.
:param username:
String defining the username of the user that made the action.
:param template_name:
String defining the nam... | [
"def",
"disabled_account",
"(",
"request",
",",
"username",
",",
"template_name",
",",
"extra_context",
"=",
"None",
")",
":",
"user",
"=",
"get_object_or_404",
"(",
"get_user_model",
"(",
")",
",",
"username__iexact",
"=",
"username",
")",
"if",
"user",
".",
... | Checks if the account is disabled, if so, returns the disabled account template.
:param username:
String defining the username of the user that made the action.
:param template_name:
String defining the name of the template to use. Defaults to
``userena/signup_complete.html``.
**K... | [
"Checks",
"if",
"the",
"account",
"is",
"disabled",
"if",
"so",
"returns",
"the",
"disabled",
"account",
"template",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/views.py#L354-L390 |
15,226 | django-userena-ce/django-userena-ce | userena/views.py | profile_list | def profile_list(request, page=1, template_name='userena/profile_list.html',
paginate_by=50, extra_context=None, **kwargs): # pragma: no cover
"""
Returns a list of all profiles that are public.
It's possible to disable this by changing ``USERENA_DISABLE_PROFILE_LIST``
to ``True`` in y... | python | def profile_list(request, page=1, template_name='userena/profile_list.html',
paginate_by=50, extra_context=None, **kwargs): # pragma: no cover
"""
Returns a list of all profiles that are public.
It's possible to disable this by changing ``USERENA_DISABLE_PROFILE_LIST``
to ``True`` in y... | [
"def",
"profile_list",
"(",
"request",
",",
"page",
"=",
"1",
",",
"template_name",
"=",
"'userena/profile_list.html'",
",",
"paginate_by",
"=",
"50",
",",
"extra_context",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pragma: no cover",
"warnings",
".",
... | Returns a list of all profiles that are public.
It's possible to disable this by changing ``USERENA_DISABLE_PROFILE_LIST``
to ``True`` in your settings.
:param page:
Integer of the active page used for pagination. Defaults to the first
page.
:param template_name:
String defini... | [
"Returns",
"a",
"list",
"of",
"all",
"profiles",
"that",
"are",
"public",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/views.py#L757-L818 |
15,227 | django-userena-ce/django-userena-ce | userena/contrib/umessages/managers.py | MessageContactManager.get_or_create | def get_or_create(self, um_from_user, um_to_user, message):
"""
Get or create a Contact
We override Django's :func:`get_or_create` because we want contact to
be unique in a bi-directional manner.
"""
created = False
try:
contact = self.get(Q(um_from_... | python | def get_or_create(self, um_from_user, um_to_user, message):
"""
Get or create a Contact
We override Django's :func:`get_or_create` because we want contact to
be unique in a bi-directional manner.
"""
created = False
try:
contact = self.get(Q(um_from_... | [
"def",
"get_or_create",
"(",
"self",
",",
"um_from_user",
",",
"um_to_user",
",",
"message",
")",
":",
"created",
"=",
"False",
"try",
":",
"contact",
"=",
"self",
".",
"get",
"(",
"Q",
"(",
"um_from_user",
"=",
"um_from_user",
",",
"um_to_user",
"=",
"u... | Get or create a Contact
We override Django's :func:`get_or_create` because we want contact to
be unique in a bi-directional manner. | [
"Get",
"or",
"create",
"a",
"Contact"
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/managers.py#L11-L30 |
15,228 | django-userena-ce/django-userena-ce | userena/contrib/umessages/managers.py | MessageContactManager.update_contact | def update_contact(self, um_from_user, um_to_user, message):
""" Get or update a contacts information """
contact, created = self.get_or_create(um_from_user,
um_to_user,
message)
# If the contact already... | python | def update_contact(self, um_from_user, um_to_user, message):
""" Get or update a contacts information """
contact, created = self.get_or_create(um_from_user,
um_to_user,
message)
# If the contact already... | [
"def",
"update_contact",
"(",
"self",
",",
"um_from_user",
",",
"um_to_user",
",",
"message",
")",
":",
"contact",
",",
"created",
"=",
"self",
".",
"get_or_create",
"(",
"um_from_user",
",",
"um_to_user",
",",
"message",
")",
"# If the contact already existed, up... | Get or update a contacts information | [
"Get",
"or",
"update",
"a",
"contacts",
"information"
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/managers.py#L32-L42 |
15,229 | django-userena-ce/django-userena-ce | userena/contrib/umessages/managers.py | MessageContactManager.get_contacts_for | def get_contacts_for(self, user):
"""
Returns the contacts for this user.
Contacts are other users that this user has received messages
from or send messages to.
:param user:
The :class:`User` which to get the contacts for.
"""
contacts = self.filte... | python | def get_contacts_for(self, user):
"""
Returns the contacts for this user.
Contacts are other users that this user has received messages
from or send messages to.
:param user:
The :class:`User` which to get the contacts for.
"""
contacts = self.filte... | [
"def",
"get_contacts_for",
"(",
"self",
",",
"user",
")",
":",
"contacts",
"=",
"self",
".",
"filter",
"(",
"Q",
"(",
"um_from_user",
"=",
"user",
")",
"|",
"Q",
"(",
"um_to_user",
"=",
"user",
")",
")",
"return",
"contacts"
] | Returns the contacts for this user.
Contacts are other users that this user has received messages
from or send messages to.
:param user:
The :class:`User` which to get the contacts for. | [
"Returns",
"the",
"contacts",
"for",
"this",
"user",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/managers.py#L44-L56 |
15,230 | django-userena-ce/django-userena-ce | userena/contrib/umessages/managers.py | MessageManager.send_message | def send_message(self, sender, um_to_user_list, body):
"""
Send a message from a user, to a user.
:param sender:
The :class:`User` which sends the message.
:param um_to_user_list:
A list which elements are :class:`User` to whom the message is for.
:para... | python | def send_message(self, sender, um_to_user_list, body):
"""
Send a message from a user, to a user.
:param sender:
The :class:`User` which sends the message.
:param um_to_user_list:
A list which elements are :class:`User` to whom the message is for.
:para... | [
"def",
"send_message",
"(",
"self",
",",
"sender",
",",
"um_to_user_list",
",",
"body",
")",
":",
"msg",
"=",
"self",
".",
"model",
"(",
"sender",
"=",
"sender",
",",
"body",
"=",
"body",
")",
"msg",
".",
"save",
"(",
")",
"# Save the recipients",
"msg... | Send a message from a user, to a user.
:param sender:
The :class:`User` which sends the message.
:param um_to_user_list:
A list which elements are :class:`User` to whom the message is for.
:param message:
String containing the message. | [
"Send",
"a",
"message",
"from",
"a",
"user",
"to",
"a",
"user",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/managers.py#L61-L84 |
15,231 | django-userena-ce/django-userena-ce | userena/contrib/umessages/managers.py | MessageManager.get_conversation_between | def get_conversation_between(self, um_from_user, um_to_user):
""" Returns a conversation between two users """
messages = self.filter(Q(sender=um_from_user, recipients=um_to_user,
sender_deleted_at__isnull=True) |
Q(sender=um_to_user, recip... | python | def get_conversation_between(self, um_from_user, um_to_user):
""" Returns a conversation between two users """
messages = self.filter(Q(sender=um_from_user, recipients=um_to_user,
sender_deleted_at__isnull=True) |
Q(sender=um_to_user, recip... | [
"def",
"get_conversation_between",
"(",
"self",
",",
"um_from_user",
",",
"um_to_user",
")",
":",
"messages",
"=",
"self",
".",
"filter",
"(",
"Q",
"(",
"sender",
"=",
"um_from_user",
",",
"recipients",
"=",
"um_to_user",
",",
"sender_deleted_at__isnull",
"=",
... | Returns a conversation between two users | [
"Returns",
"a",
"conversation",
"between",
"two",
"users"
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/managers.py#L86-L92 |
15,232 | django-userena-ce/django-userena-ce | userena/contrib/umessages/managers.py | MessageRecipientManager.count_unread_messages_for | def count_unread_messages_for(self, user):
"""
Returns the amount of unread messages for this user
:param user:
A Django :class:`User`
:return:
An integer with the amount of unread messages.
"""
unread_total = self.filter(user=user,
... | python | def count_unread_messages_for(self, user):
"""
Returns the amount of unread messages for this user
:param user:
A Django :class:`User`
:return:
An integer with the amount of unread messages.
"""
unread_total = self.filter(user=user,
... | [
"def",
"count_unread_messages_for",
"(",
"self",
",",
"user",
")",
":",
"unread_total",
"=",
"self",
".",
"filter",
"(",
"user",
"=",
"user",
",",
"read_at__isnull",
"=",
"True",
",",
"deleted_at__isnull",
"=",
"True",
")",
".",
"count",
"(",
")",
"return"... | Returns the amount of unread messages for this user
:param user:
A Django :class:`User`
:return:
An integer with the amount of unread messages. | [
"Returns",
"the",
"amount",
"of",
"unread",
"messages",
"for",
"this",
"user"
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/managers.py#L97-L112 |
15,233 | django-userena-ce/django-userena-ce | userena/contrib/umessages/managers.py | MessageRecipientManager.count_unread_messages_between | def count_unread_messages_between(self, um_to_user, um_from_user):
"""
Returns the amount of unread messages between two users
:param um_to_user:
A Django :class:`User` for who the messages are for.
:param um_from_user:
A Django :class:`User` from whom the messa... | python | def count_unread_messages_between(self, um_to_user, um_from_user):
"""
Returns the amount of unread messages between two users
:param um_to_user:
A Django :class:`User` for who the messages are for.
:param um_from_user:
A Django :class:`User` from whom the messa... | [
"def",
"count_unread_messages_between",
"(",
"self",
",",
"um_to_user",
",",
"um_from_user",
")",
":",
"unread_total",
"=",
"self",
".",
"filter",
"(",
"message__sender",
"=",
"um_from_user",
",",
"user",
"=",
"um_to_user",
",",
"read_at__isnull",
"=",
"True",
"... | Returns the amount of unread messages between two users
:param um_to_user:
A Django :class:`User` for who the messages are for.
:param um_from_user:
A Django :class:`User` from whom the messages originate from.
:return:
An integer with the amount of unread ... | [
"Returns",
"the",
"amount",
"of",
"unread",
"messages",
"between",
"two",
"users"
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/managers.py#L114-L133 |
15,234 | django-userena-ce/django-userena-ce | userena/managers.py | UserenaManager.reissue_activation | def reissue_activation(self, activation_key):
"""
Creates a new ``activation_key`` resetting activation timeframe when
users let the previous key expire.
:param activation_key:
String containing the secret SHA1 activation key.
"""
try:
userena = ... | python | def reissue_activation(self, activation_key):
"""
Creates a new ``activation_key`` resetting activation timeframe when
users let the previous key expire.
:param activation_key:
String containing the secret SHA1 activation key.
"""
try:
userena = ... | [
"def",
"reissue_activation",
"(",
"self",
",",
"activation_key",
")",
":",
"try",
":",
"userena",
"=",
"self",
".",
"get",
"(",
"activation_key",
"=",
"activation_key",
")",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
":",
"return",
"False",
"try",
... | Creates a new ``activation_key`` resetting activation timeframe when
users let the previous key expire.
:param activation_key:
String containing the secret SHA1 activation key. | [
"Creates",
"a",
"new",
"activation_key",
"resetting",
"activation",
"timeframe",
"when",
"users",
"let",
"the",
"previous",
"key",
"expire",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/managers.py#L106-L128 |
15,235 | django-userena-ce/django-userena-ce | userena/managers.py | UserenaManager.check_expired_activation | def check_expired_activation(self, activation_key):
"""
Check if ``activation_key`` is still valid.
Raises a ``self.model.DoesNotExist`` exception if key is not present or
``activation_key`` is not a valid string
:param activation_key:
String containing the secret ... | python | def check_expired_activation(self, activation_key):
"""
Check if ``activation_key`` is still valid.
Raises a ``self.model.DoesNotExist`` exception if key is not present or
``activation_key`` is not a valid string
:param activation_key:
String containing the secret ... | [
"def",
"check_expired_activation",
"(",
"self",
",",
"activation_key",
")",
":",
"if",
"SHA1_RE",
".",
"search",
"(",
"activation_key",
")",
":",
"userena",
"=",
"self",
".",
"get",
"(",
"activation_key",
"=",
"activation_key",
")",
"return",
"userena",
".",
... | Check if ``activation_key`` is still valid.
Raises a ``self.model.DoesNotExist`` exception if key is not present or
``activation_key`` is not a valid string
:param activation_key:
String containing the secret SHA1 for a valid activation.
:return:
True if the k... | [
"Check",
"if",
"activation_key",
"is",
"still",
"valid",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/managers.py#L163-L180 |
15,236 | django-userena-ce/django-userena-ce | userena/managers.py | UserenaManager.check_permissions | def check_permissions(self):
"""
Checks that all permissions are set correctly for the users.
:return: A set of users whose permissions was wrong.
"""
# Variable to supply some feedback
changed_permissions = []
changed_users = []
warnings = []
#... | python | def check_permissions(self):
"""
Checks that all permissions are set correctly for the users.
:return: A set of users whose permissions was wrong.
"""
# Variable to supply some feedback
changed_permissions = []
changed_users = []
warnings = []
#... | [
"def",
"check_permissions",
"(",
"self",
")",
":",
"# Variable to supply some feedback",
"changed_permissions",
"=",
"[",
"]",
"changed_users",
"=",
"[",
"]",
"warnings",
"=",
"[",
"]",
"# Check that all the permissions are available.",
"for",
"model",
",",
"perms",
"... | Checks that all permissions are set correctly for the users.
:return: A set of users whose permissions was wrong. | [
"Checks",
"that",
"all",
"permissions",
"are",
"set",
"correctly",
"for",
"the",
"users",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/managers.py#L236-L287 |
15,237 | django-userena-ce/django-userena-ce | userena/contrib/umessages/templatetags/umessages_tags.py | get_unread_message_count_for | def get_unread_message_count_for(parser, token):
"""
Returns the unread message count for a user.
Syntax::
{% get_unread_message_count_for [user] as [var_name] %}
Example usage::
{% get_unread_message_count_for pero as message_count %}
"""
try:
tag_name, arg = token.... | python | def get_unread_message_count_for(parser, token):
"""
Returns the unread message count for a user.
Syntax::
{% get_unread_message_count_for [user] as [var_name] %}
Example usage::
{% get_unread_message_count_for pero as message_count %}
"""
try:
tag_name, arg = token.... | [
"def",
"get_unread_message_count_for",
"(",
"parser",
",",
"token",
")",
":",
"try",
":",
"tag_name",
",",
"arg",
"=",
"token",
".",
"contents",
".",
"split",
"(",
"None",
",",
"1",
")",
"except",
"ValueError",
":",
"raise",
"template",
".",
"TemplateSynta... | Returns the unread message count for a user.
Syntax::
{% get_unread_message_count_for [user] as [var_name] %}
Example usage::
{% get_unread_message_count_for pero as message_count %} | [
"Returns",
"the",
"unread",
"message",
"count",
"for",
"a",
"user",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/templatetags/umessages_tags.py#L40-L61 |
15,238 | django-userena-ce/django-userena-ce | userena/contrib/umessages/templatetags/umessages_tags.py | get_unread_message_count_between | def get_unread_message_count_between(parser, token):
"""
Returns the unread message count between two users.
Syntax::
{% get_unread_message_count_between [user] and [user] as [var_name] %}
Example usage::
{% get_unread_message_count_between funky and wunki as message_count %}
""... | python | def get_unread_message_count_between(parser, token):
"""
Returns the unread message count between two users.
Syntax::
{% get_unread_message_count_between [user] and [user] as [var_name] %}
Example usage::
{% get_unread_message_count_between funky and wunki as message_count %}
""... | [
"def",
"get_unread_message_count_between",
"(",
"parser",
",",
"token",
")",
":",
"try",
":",
"tag_name",
",",
"arg",
"=",
"token",
".",
"contents",
".",
"split",
"(",
"None",
",",
"1",
")",
"except",
"ValueError",
":",
"raise",
"template",
".",
"TemplateS... | Returns the unread message count between two users.
Syntax::
{% get_unread_message_count_between [user] and [user] as [var_name] %}
Example usage::
{% get_unread_message_count_between funky and wunki as message_count %} | [
"Returns",
"the",
"unread",
"message",
"count",
"between",
"two",
"users",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/templatetags/umessages_tags.py#L64-L85 |
15,239 | django-userena-ce/django-userena-ce | userena/models.py | upload_to_mugshot | def upload_to_mugshot(instance, filename):
"""
Uploads a mugshot for a user to the ``USERENA_MUGSHOT_PATH`` and saving it
under unique hash for the image. This is for privacy reasons so others
can't just browse through the mugshot directory.
"""
extension = filename.split('.')[-1].lower()
s... | python | def upload_to_mugshot(instance, filename):
"""
Uploads a mugshot for a user to the ``USERENA_MUGSHOT_PATH`` and saving it
under unique hash for the image. This is for privacy reasons so others
can't just browse through the mugshot directory.
"""
extension = filename.split('.')[-1].lower()
s... | [
"def",
"upload_to_mugshot",
"(",
"instance",
",",
"filename",
")",
":",
"extension",
"=",
"filename",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
".",
"lower",
"(",
")",
"salt",
",",
"hash",
"=",
"generate_sha1",
"(",
"instance",
".",
"pk",
")... | Uploads a mugshot for a user to the ``USERENA_MUGSHOT_PATH`` and saving it
under unique hash for the image. This is for privacy reasons so others
can't just browse through the mugshot directory. | [
"Uploads",
"a",
"mugshot",
"for",
"a",
"user",
"to",
"the",
"USERENA_MUGSHOT_PATH",
"and",
"saving",
"it",
"under",
"unique",
"hash",
"for",
"the",
"image",
".",
"This",
"is",
"for",
"privacy",
"reasons",
"so",
"others",
"can",
"t",
"just",
"browse",
"thro... | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/models.py#L24-L39 |
15,240 | django-userena-ce/django-userena-ce | userena/contrib/umessages/views.py | message_compose | def message_compose(request, recipients=None, compose_form=ComposeForm,
success_url=None, template_name="umessages/message_form.html",
recipient_filter=None, extra_context=None):
"""
Compose a new message
:recipients:
String containing the usernames to whom t... | python | def message_compose(request, recipients=None, compose_form=ComposeForm,
success_url=None, template_name="umessages/message_form.html",
recipient_filter=None, extra_context=None):
"""
Compose a new message
:recipients:
String containing the usernames to whom t... | [
"def",
"message_compose",
"(",
"request",
",",
"recipients",
"=",
"None",
",",
"compose_form",
"=",
"ComposeForm",
",",
"success_url",
"=",
"None",
",",
"template_name",
"=",
"\"umessages/message_form.html\"",
",",
"recipient_filter",
"=",
"None",
",",
"extra_contex... | Compose a new message
:recipients:
String containing the usernames to whom the message is send to. Can be
multiple username by seperating them with a ``+`` sign.
:param compose_form:
The form that is used for getting neccesary information. Defaults to
:class:`ComposeForm`.
... | [
"Compose",
"a",
"new",
"message"
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/views.py#L73-L141 |
15,241 | django-userena-ce/django-userena-ce | userena/contrib/umessages/views.py | message_remove | def message_remove(request, undo=False):
"""
A ``POST`` to remove messages.
:param undo:
A Boolean that if ``True`` unremoves messages.
POST can have the following keys:
``message_pks``
List of message id's that should be deleted.
``next``
String conta... | python | def message_remove(request, undo=False):
"""
A ``POST`` to remove messages.
:param undo:
A Boolean that if ``True`` unremoves messages.
POST can have the following keys:
``message_pks``
List of message id's that should be deleted.
``next``
String conta... | [
"def",
"message_remove",
"(",
"request",
",",
"undo",
"=",
"False",
")",
":",
"message_pks",
"=",
"request",
".",
"POST",
".",
"getlist",
"(",
"'message_pks'",
")",
"redirect_to",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"REDIRECT_FIELD_NAME",
",",
"re... | A ``POST`` to remove messages.
:param undo:
A Boolean that if ``True`` unremoves messages.
POST can have the following keys:
``message_pks``
List of message id's that should be deleted.
``next``
String containing the URI which to redirect to after the keys are... | [
"A",
"POST",
"to",
"remove",
"messages",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/views.py#L145-L217 |
15,242 | django-userena-ce/django-userena-ce | demo/profiles/forms.py | SignupFormExtra.save | def save(self):
"""
Override the save method to save the first and last name to the user
field.
"""
# First save the parent form and get the user.
new_user = super(SignupFormExtra, self).save()
new_user.first_name = self.cleaned_data['first_name']
new_u... | python | def save(self):
"""
Override the save method to save the first and last name to the user
field.
"""
# First save the parent form and get the user.
new_user = super(SignupFormExtra, self).save()
new_user.first_name = self.cleaned_data['first_name']
new_u... | [
"def",
"save",
"(",
"self",
")",
":",
"# First save the parent form and get the user.",
"new_user",
"=",
"super",
"(",
"SignupFormExtra",
",",
"self",
")",
".",
"save",
"(",
")",
"new_user",
".",
"first_name",
"=",
"self",
".",
"cleaned_data",
"[",
"'first_name'... | Override the save method to save the first and last name to the user
field. | [
"Override",
"the",
"save",
"method",
"to",
"save",
"the",
"first",
"and",
"last",
"name",
"to",
"the",
"user",
"field",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/demo/profiles/forms.py#L38-L53 |
15,243 | django-userena-ce/django-userena-ce | userena/contrib/umessages/forms.py | ComposeForm.save | def save(self, sender):
"""
Save the message and send it out into the wide world.
:param sender:
The :class:`User` that sends the message.
:param parent_msg:
The :class:`Message` that preceded this message in the thread.
:return: The saved :class:`Messa... | python | def save(self, sender):
"""
Save the message and send it out into the wide world.
:param sender:
The :class:`User` that sends the message.
:param parent_msg:
The :class:`Message` that preceded this message in the thread.
:return: The saved :class:`Messa... | [
"def",
"save",
"(",
"self",
",",
"sender",
")",
":",
"um_to_user_list",
"=",
"self",
".",
"cleaned_data",
"[",
"'to'",
"]",
"body",
"=",
"self",
".",
"cleaned_data",
"[",
"'body'",
"]",
"msg",
"=",
"Message",
".",
"objects",
".",
"send_message",
"(",
"... | Save the message and send it out into the wide world.
:param sender:
The :class:`User` that sends the message.
:param parent_msg:
The :class:`Message` that preceded this message in the thread.
:return: The saved :class:`Message`. | [
"Save",
"the",
"message",
"and",
"send",
"it",
"out",
"into",
"the",
"wide",
"world",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/contrib/umessages/forms.py#L15-L35 |
15,244 | django-userena-ce/django-userena-ce | userena/forms.py | SignupForm.clean_username | def clean_username(self):
"""
Validate that the username is alphanumeric and is not already in use.
Also validates that the username is not listed in
``USERENA_FORBIDDEN_USERNAMES`` list.
"""
try:
user = get_user_model().objects.get(username__iexact=self.clea... | python | def clean_username(self):
"""
Validate that the username is alphanumeric and is not already in use.
Also validates that the username is not listed in
``USERENA_FORBIDDEN_USERNAMES`` list.
"""
try:
user = get_user_model().objects.get(username__iexact=self.clea... | [
"def",
"clean_username",
"(",
"self",
")",
":",
"try",
":",
"user",
"=",
"get_user_model",
"(",
")",
".",
"objects",
".",
"get",
"(",
"username__iexact",
"=",
"self",
".",
"cleaned_data",
"[",
"'username'",
"]",
")",
"except",
"get_user_model",
"(",
")",
... | Validate that the username is alphanumeric and is not already in use.
Also validates that the username is not listed in
``USERENA_FORBIDDEN_USERNAMES`` list. | [
"Validate",
"that",
"the",
"username",
"is",
"alphanumeric",
"and",
"is",
"not",
"already",
"in",
"use",
".",
"Also",
"validates",
"that",
"the",
"username",
"is",
"not",
"listed",
"in",
"USERENA_FORBIDDEN_USERNAMES",
"list",
"."
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/forms.py#L44-L61 |
15,245 | django-userena-ce/django-userena-ce | userena/forms.py | SignupFormOnlyEmail.save | def save(self):
""" Generate a random username before falling back to parent signup form """
while True:
username = sha1(str(random.random()).encode('utf-8')).hexdigest()[:5]
try:
get_user_model().objects.get(username__iexact=username)
except get_user_... | python | def save(self):
""" Generate a random username before falling back to parent signup form """
while True:
username = sha1(str(random.random()).encode('utf-8')).hexdigest()[:5]
try:
get_user_model().objects.get(username__iexact=username)
except get_user_... | [
"def",
"save",
"(",
"self",
")",
":",
"while",
"True",
":",
"username",
"=",
"sha1",
"(",
"str",
"(",
"random",
".",
"random",
"(",
")",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"hexdigest",
"(",
")",
"[",
":",
"5",
"]",
"try",
":",
... | Generate a random username before falling back to parent signup form | [
"Generate",
"a",
"random",
"username",
"before",
"falling",
"back",
"to",
"parent",
"signup",
"form"
] | 2d8b745eed25128134e961ca96c270802e730256 | https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/forms.py#L110-L119 |
15,246 | dogoncouch/logdissect | logdissect/parsers/linejson.py | ParseModule.parse_file | def parse_file(self, sourcepath):
"""Parse an object-per-line JSON file into a log data dict"""
# Open input file and read JSON array:
with open(sourcepath, 'r') as logfile:
jsonlist = logfile.readlines()
# Set our attributes for this entry and add it to data.entries:
... | python | def parse_file(self, sourcepath):
"""Parse an object-per-line JSON file into a log data dict"""
# Open input file and read JSON array:
with open(sourcepath, 'r') as logfile:
jsonlist = logfile.readlines()
# Set our attributes for this entry and add it to data.entries:
... | [
"def",
"parse_file",
"(",
"self",
",",
"sourcepath",
")",
":",
"# Open input file and read JSON array:",
"with",
"open",
"(",
"sourcepath",
",",
"'r'",
")",
"as",
"logfile",
":",
"jsonlist",
"=",
"logfile",
".",
"readlines",
"(",
")",
"# Set our attributes for thi... | Parse an object-per-line JSON file into a log data dict | [
"Parse",
"an",
"object",
"-",
"per",
"-",
"line",
"JSON",
"file",
"into",
"a",
"log",
"data",
"dict"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/parsers/linejson.py#L41-L59 |
15,247 | dogoncouch/logdissect | logdissect/parsers/sojson.py | ParseModule.parse_file | def parse_file(self, sourcepath):
"""Parse single JSON object into a LogData object"""
# Open input file and read JSON array:
with open(sourcepath, 'r') as logfile:
jsonstr = logfile.read()
# Set our attributes for this entry and add it to data.entries:
data = {}
... | python | def parse_file(self, sourcepath):
"""Parse single JSON object into a LogData object"""
# Open input file and read JSON array:
with open(sourcepath, 'r') as logfile:
jsonstr = logfile.read()
# Set our attributes for this entry and add it to data.entries:
data = {}
... | [
"def",
"parse_file",
"(",
"self",
",",
"sourcepath",
")",
":",
"# Open input file and read JSON array:",
"with",
"open",
"(",
"sourcepath",
",",
"'r'",
")",
"as",
"logfile",
":",
"jsonstr",
"=",
"logfile",
".",
"read",
"(",
")",
"# Set our attributes for this entr... | Parse single JSON object into a LogData object | [
"Parse",
"single",
"JSON",
"object",
"into",
"a",
"LogData",
"object"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/parsers/sojson.py#L41-L56 |
15,248 | dogoncouch/logdissect | logdissect/core.py | LogDissectCore.run_job | def run_job(self):
"""Execute a logdissect job"""
try:
self.load_parsers()
self.load_filters()
self.load_outputs()
self.config_args()
if self.args.list_parsers:
self.list_parsers()
if self.args.verbosemode: print('Lo... | python | def run_job(self):
"""Execute a logdissect job"""
try:
self.load_parsers()
self.load_filters()
self.load_outputs()
self.config_args()
if self.args.list_parsers:
self.list_parsers()
if self.args.verbosemode: print('Lo... | [
"def",
"run_job",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"load_parsers",
"(",
")",
"self",
".",
"load_filters",
"(",
")",
"self",
".",
"load_outputs",
"(",
")",
"self",
".",
"config_args",
"(",
")",
"if",
"self",
".",
"args",
".",
"list_pars... | Execute a logdissect job | [
"Execute",
"a",
"logdissect",
"job"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/core.py#L58-L80 |
15,249 | dogoncouch/logdissect | logdissect/core.py | LogDissectCore.run_parse | def run_parse(self):
"""Parse one or more log files"""
# Data set already has source file names from load_inputs
parsedset = {}
parsedset['data_set'] = []
for log in self.input_files:
parsemodule = self.parse_modules[self.args.parser]
try:
... | python | def run_parse(self):
"""Parse one or more log files"""
# Data set already has source file names from load_inputs
parsedset = {}
parsedset['data_set'] = []
for log in self.input_files:
parsemodule = self.parse_modules[self.args.parser]
try:
... | [
"def",
"run_parse",
"(",
"self",
")",
":",
"# Data set already has source file names from load_inputs",
"parsedset",
"=",
"{",
"}",
"parsedset",
"[",
"'data_set'",
"]",
"=",
"[",
"]",
"for",
"log",
"in",
"self",
".",
"input_files",
":",
"parsemodule",
"=",
"self... | Parse one or more log files | [
"Parse",
"one",
"or",
"more",
"log",
"files"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/core.py#L82-L95 |
15,250 | dogoncouch/logdissect | logdissect/core.py | LogDissectCore.run_output | def run_output(self):
"""Output finalized data"""
for f in logdissect.output.__formats__:
ouroutput = self.output_modules[f]
ouroutput.write_output(self.data_set['finalized_data'],
args=self.args)
del(ouroutput)
# Output to terminal if sil... | python | def run_output(self):
"""Output finalized data"""
for f in logdissect.output.__formats__:
ouroutput = self.output_modules[f]
ouroutput.write_output(self.data_set['finalized_data'],
args=self.args)
del(ouroutput)
# Output to terminal if sil... | [
"def",
"run_output",
"(",
"self",
")",
":",
"for",
"f",
"in",
"logdissect",
".",
"output",
".",
"__formats__",
":",
"ouroutput",
"=",
"self",
".",
"output_modules",
"[",
"f",
"]",
"ouroutput",
".",
"write_output",
"(",
"self",
".",
"data_set",
"[",
"'fin... | Output finalized data | [
"Output",
"finalized",
"data"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/core.py#L107-L120 |
15,251 | dogoncouch/logdissect | logdissect/core.py | LogDissectCore.config_args | def config_args(self):
"""Set config options"""
# Module list options:
self.arg_parser.add_argument('--version', action='version',
version='%(prog)s ' + str(__version__))
self.arg_parser.add_argument('--verbose',
action='store_true', dest = 'verbosemode',
... | python | def config_args(self):
"""Set config options"""
# Module list options:
self.arg_parser.add_argument('--version', action='version',
version='%(prog)s ' + str(__version__))
self.arg_parser.add_argument('--verbose',
action='store_true', dest = 'verbosemode',
... | [
"def",
"config_args",
"(",
"self",
")",
":",
"# Module list options:",
"self",
".",
"arg_parser",
".",
"add_argument",
"(",
"'--version'",
",",
"action",
"=",
"'version'",
",",
"version",
"=",
"'%(prog)s '",
"+",
"str",
"(",
"__version__",
")",
")",
"self",
... | Set config options | [
"Set",
"config",
"options"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/core.py#L124-L156 |
15,252 | dogoncouch/logdissect | logdissect/core.py | LogDissectCore.load_inputs | def load_inputs(self):
"""Load the specified inputs"""
for f in self.args.files:
if os.path.isfile(f):
fparts = str(f).split('.')
if fparts[-1] == 'gz':
if self.args.unzip:
fullpath = os.path.abspath(str(f))
... | python | def load_inputs(self):
"""Load the specified inputs"""
for f in self.args.files:
if os.path.isfile(f):
fparts = str(f).split('.')
if fparts[-1] == 'gz':
if self.args.unzip:
fullpath = os.path.abspath(str(f))
... | [
"def",
"load_inputs",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"args",
".",
"files",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"f",
")",
":",
"fparts",
"=",
"str",
"(",
"f",
")",
".",
"split",
"(",
"'.'",
")",
"if",
"fpar... | Load the specified inputs | [
"Load",
"the",
"specified",
"inputs"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/core.py#L161-L179 |
15,253 | dogoncouch/logdissect | logdissect/core.py | LogDissectCore.list_parsers | def list_parsers(self, *args):
"""Return a list of available parsing modules"""
print('==== Available parsing modules: ====\n')
for parser in sorted(self.parse_modules):
print(self.parse_modules[parser].name.ljust(16) + \
': ' + self.parse_modules[parser].desc)
... | python | def list_parsers(self, *args):
"""Return a list of available parsing modules"""
print('==== Available parsing modules: ====\n')
for parser in sorted(self.parse_modules):
print(self.parse_modules[parser].name.ljust(16) + \
': ' + self.parse_modules[parser].desc)
... | [
"def",
"list_parsers",
"(",
"self",
",",
"*",
"args",
")",
":",
"print",
"(",
"'==== Available parsing modules: ====\\n'",
")",
"for",
"parser",
"in",
"sorted",
"(",
"self",
".",
"parse_modules",
")",
":",
"print",
"(",
"self",
".",
"parse_modules",
"[",
"pa... | Return a list of available parsing modules | [
"Return",
"a",
"list",
"of",
"available",
"parsing",
"modules"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/core.py#L182-L188 |
15,254 | dogoncouch/logdissect | logdissect/utils.py | get_utc_date | def get_utc_date(entry):
"""Return datestamp converted to UTC"""
if entry['numeric_date_stamp'] == '0':
entry['numeric_date_stamp_utc'] = '0'
return entry
else:
if '.' in entry['numeric_date_stamp']:
t = datetime.strptime(entry['numeric_date_stamp'],
... | python | def get_utc_date(entry):
"""Return datestamp converted to UTC"""
if entry['numeric_date_stamp'] == '0':
entry['numeric_date_stamp_utc'] = '0'
return entry
else:
if '.' in entry['numeric_date_stamp']:
t = datetime.strptime(entry['numeric_date_stamp'],
... | [
"def",
"get_utc_date",
"(",
"entry",
")",
":",
"if",
"entry",
"[",
"'numeric_date_stamp'",
"]",
"==",
"'0'",
":",
"entry",
"[",
"'numeric_date_stamp_utc'",
"]",
"=",
"'0'",
"return",
"entry",
"else",
":",
"if",
"'.'",
"in",
"entry",
"[",
"'numeric_date_stamp... | Return datestamp converted to UTC | [
"Return",
"datestamp",
"converted",
"to",
"UTC"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/utils.py#L145-L168 |
15,255 | dogoncouch/logdissect | logdissect/utils.py | get_local_tzone | def get_local_tzone():
"""Get the current time zone on the local host"""
if localtime().tm_isdst:
if altzone < 0:
tzone = '+' + \
str(int(float(altzone) / 60 // 60)).rjust(2,
'0') + \
str(int(float(
... | python | def get_local_tzone():
"""Get the current time zone on the local host"""
if localtime().tm_isdst:
if altzone < 0:
tzone = '+' + \
str(int(float(altzone) / 60 // 60)).rjust(2,
'0') + \
str(int(float(
... | [
"def",
"get_local_tzone",
"(",
")",
":",
"if",
"localtime",
"(",
")",
".",
"tm_isdst",
":",
"if",
"altzone",
"<",
"0",
":",
"tzone",
"=",
"'+'",
"+",
"str",
"(",
"int",
"(",
"float",
"(",
"altzone",
")",
"/",
"60",
"//",
"60",
")",
")",
".",
"r... | Get the current time zone on the local host | [
"Get",
"the",
"current",
"time",
"zone",
"on",
"the",
"local",
"host"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/utils.py#L171-L200 |
15,256 | dogoncouch/logdissect | logdissect/utils.py | merge_logs | def merge_logs(dataset, sort=True):
"""Merge log dictionaries together into one log dictionary"""
ourlog = {}
ourlog['entries'] = []
for d in dataset:
ourlog['entries'] = ourlog['entries'] + d['entries']
if sort:
ourlog['entries'].sort(key= lambda x: x['numeric_date_stamp_utc'])
... | python | def merge_logs(dataset, sort=True):
"""Merge log dictionaries together into one log dictionary"""
ourlog = {}
ourlog['entries'] = []
for d in dataset:
ourlog['entries'] = ourlog['entries'] + d['entries']
if sort:
ourlog['entries'].sort(key= lambda x: x['numeric_date_stamp_utc'])
... | [
"def",
"merge_logs",
"(",
"dataset",
",",
"sort",
"=",
"True",
")",
":",
"ourlog",
"=",
"{",
"}",
"ourlog",
"[",
"'entries'",
"]",
"=",
"[",
"]",
"for",
"d",
"in",
"dataset",
":",
"ourlog",
"[",
"'entries'",
"]",
"=",
"ourlog",
"[",
"'entries'",
"]... | Merge log dictionaries together into one log dictionary | [
"Merge",
"log",
"dictionaries",
"together",
"into",
"one",
"log",
"dictionary"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/utils.py#L203-L212 |
15,257 | dogoncouch/logdissect | logdissect/output/log.py | OutputModule.write_output | def write_output(self, data, args=None, filename=None, label=None):
"""Write log data to a log file"""
if args:
if not args.outlog:
return 0
if not filename: filename=args.outlog
lastpath = ''
with open(str(filename), 'w') as output_file:
f... | python | def write_output(self, data, args=None, filename=None, label=None):
"""Write log data to a log file"""
if args:
if not args.outlog:
return 0
if not filename: filename=args.outlog
lastpath = ''
with open(str(filename), 'w') as output_file:
f... | [
"def",
"write_output",
"(",
"self",
",",
"data",
",",
"args",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"if",
"args",
":",
"if",
"not",
"args",
".",
"outlog",
":",
"return",
"0",
"if",
"not",
"filename",
":",
... | Write log data to a log file | [
"Write",
"log",
"data",
"to",
"a",
"log",
"file"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/output/log.py#L37-L58 |
15,258 | dogoncouch/logdissect | logdissect/output/sojson.py | OutputModule.write_output | def write_output(self, data, args=None, filename=None, pretty=False):
"""Write log data to a single JSON object"""
if args:
if not args.sojson:
return 0
pretty = args.pretty
if not filename: filename = args.sojson
if pretty:
logstring =... | python | def write_output(self, data, args=None, filename=None, pretty=False):
"""Write log data to a single JSON object"""
if args:
if not args.sojson:
return 0
pretty = args.pretty
if not filename: filename = args.sojson
if pretty:
logstring =... | [
"def",
"write_output",
"(",
"self",
",",
"data",
",",
"args",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"pretty",
"=",
"False",
")",
":",
"if",
"args",
":",
"if",
"not",
"args",
".",
"sojson",
":",
"return",
"0",
"pretty",
"=",
"args",
".",
... | Write log data to a single JSON object | [
"Write",
"log",
"data",
"to",
"a",
"single",
"JSON",
"object"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/output/sojson.py#L38-L53 |
15,259 | dogoncouch/logdissect | logdissect/output/linejson.py | OutputModule.write_output | def write_output(self, data, filename=None, args=None):
"""Write log data to a file with one JSON object per line"""
if args:
if not args.linejson:
return 0
if not filename: filename = args.linejson
entrylist = []
for entry in data['entries']:
... | python | def write_output(self, data, filename=None, args=None):
"""Write log data to a file with one JSON object per line"""
if args:
if not args.linejson:
return 0
if not filename: filename = args.linejson
entrylist = []
for entry in data['entries']:
... | [
"def",
"write_output",
"(",
"self",
",",
"data",
",",
"filename",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
":",
"if",
"not",
"args",
".",
"linejson",
":",
"return",
"0",
"if",
"not",
"filename",
":",
"filename",
"=",
"args",
"... | Write log data to a file with one JSON object per line | [
"Write",
"log",
"data",
"to",
"a",
"file",
"with",
"one",
"JSON",
"object",
"per",
"line"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/output/linejson.py#L36-L48 |
15,260 | dogoncouch/logdissect | logdissect/parsers/type.py | ParseModule.parse_file | def parse_file(self, sourcepath):
"""Parse a file into a LogData object"""
# Get regex objects:
self.date_regex = re.compile(
r'{}'.format(self.format_regex))
if self.backup_format_regex:
self.backup_date_regex = re.compile(
r'{}'.format(se... | python | def parse_file(self, sourcepath):
"""Parse a file into a LogData object"""
# Get regex objects:
self.date_regex = re.compile(
r'{}'.format(self.format_regex))
if self.backup_format_regex:
self.backup_date_regex = re.compile(
r'{}'.format(se... | [
"def",
"parse_file",
"(",
"self",
",",
"sourcepath",
")",
":",
"# Get regex objects:",
"self",
".",
"date_regex",
"=",
"re",
".",
"compile",
"(",
"r'{}'",
".",
"format",
"(",
"self",
".",
"format_regex",
")",
")",
"if",
"self",
".",
"backup_format_regex",
... | Parse a file into a LogData object | [
"Parse",
"a",
"file",
"into",
"a",
"LogData",
"object"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/parsers/type.py#L46-L122 |
15,261 | dogoncouch/logdissect | logdissect/parsers/type.py | ParseModule.parse_line | def parse_line(self, line):
"""Parse a line into a dictionary"""
match = re.findall(self.date_regex, line)
if match:
fields = self.fields
elif self.backup_format_regex and not match:
match = re.findall(self.backup_date_regex, line)
fields = self.backup... | python | def parse_line(self, line):
"""Parse a line into a dictionary"""
match = re.findall(self.date_regex, line)
if match:
fields = self.fields
elif self.backup_format_regex and not match:
match = re.findall(self.backup_date_regex, line)
fields = self.backup... | [
"def",
"parse_line",
"(",
"self",
",",
"line",
")",
":",
"match",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"date_regex",
",",
"line",
")",
"if",
"match",
":",
"fields",
"=",
"self",
".",
"fields",
"elif",
"self",
".",
"backup_format_regex",
"and",
... | Parse a line into a dictionary | [
"Parse",
"a",
"line",
"into",
"a",
"dictionary"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/parsers/type.py#L125-L167 |
15,262 | dogoncouch/logdissect | logdissect/parsers/tcpdump.py | ParseModule.post_parse_action | def post_parse_action(self, entry):
"""separate hosts and ports after entry is parsed"""
if 'source_host' in entry.keys():
host = self.ip_port_regex.findall(entry['source_host'])
if host:
hlist = host[0].split('.')
entry['source_host'] = '.'.join(h... | python | def post_parse_action(self, entry):
"""separate hosts and ports after entry is parsed"""
if 'source_host' in entry.keys():
host = self.ip_port_regex.findall(entry['source_host'])
if host:
hlist = host[0].split('.')
entry['source_host'] = '.'.join(h... | [
"def",
"post_parse_action",
"(",
"self",
",",
"entry",
")",
":",
"if",
"'source_host'",
"in",
"entry",
".",
"keys",
"(",
")",
":",
"host",
"=",
"self",
".",
"ip_port_regex",
".",
"findall",
"(",
"entry",
"[",
"'source_host'",
"]",
")",
"if",
"host",
":... | separate hosts and ports after entry is parsed | [
"separate",
"hosts",
"and",
"ports",
"after",
"entry",
"is",
"parsed"
] | 426b50264cbfa9665c86df3781e1e415ba8dbbd3 | https://github.com/dogoncouch/logdissect/blob/426b50264cbfa9665c86df3781e1e415ba8dbbd3/logdissect/parsers/tcpdump.py#L42-L57 |
15,263 | vtraag/louvain-igraph | src/functions.py | find_partition_multiplex | def find_partition_multiplex(graphs, partition_type, **kwargs):
""" Detect communities for multiplex graphs.
Each graph should be defined on the same set of vertices, only the edges may
differ for different graphs. See
:func:`Optimiser.optimise_partition_multiplex` for a more detailed
explanation.
Paramet... | python | def find_partition_multiplex(graphs, partition_type, **kwargs):
""" Detect communities for multiplex graphs.
Each graph should be defined on the same set of vertices, only the edges may
differ for different graphs. See
:func:`Optimiser.optimise_partition_multiplex` for a more detailed
explanation.
Paramet... | [
"def",
"find_partition_multiplex",
"(",
"graphs",
",",
"partition_type",
",",
"*",
"*",
"kwargs",
")",
":",
"n_layers",
"=",
"len",
"(",
"graphs",
")",
"partitions",
"=",
"[",
"]",
"layer_weights",
"=",
"[",
"1",
"]",
"*",
"n_layers",
"for",
"graph",
"in... | Detect communities for multiplex graphs.
Each graph should be defined on the same set of vertices, only the edges may
differ for different graphs. See
:func:`Optimiser.optimise_partition_multiplex` for a more detailed
explanation.
Parameters
----------
graphs : list of :class:`ig.Graph`
List of :cla... | [
"Detect",
"communities",
"for",
"multiplex",
"graphs",
"."
] | 8de2c3bad736a9deea90b80f104d8444769d331f | https://github.com/vtraag/louvain-igraph/blob/8de2c3bad736a9deea90b80f104d8444769d331f/src/functions.py#L81-L136 |
15,264 | vtraag/louvain-igraph | src/functions.py | find_partition_temporal | def find_partition_temporal(graphs, partition_type,
interslice_weight=1,
slice_attr='slice', vertex_id_attr='id',
edge_type_attr='type', weight_attr='weight',
**kwargs):
""" Detect communities for temporal ... | python | def find_partition_temporal(graphs, partition_type,
interslice_weight=1,
slice_attr='slice', vertex_id_attr='id',
edge_type_attr='type', weight_attr='weight',
**kwargs):
""" Detect communities for temporal ... | [
"def",
"find_partition_temporal",
"(",
"graphs",
",",
"partition_type",
",",
"interslice_weight",
"=",
"1",
",",
"slice_attr",
"=",
"'slice'",
",",
"vertex_id_attr",
"=",
"'id'",
",",
"edge_type_attr",
"=",
"'type'",
",",
"weight_attr",
"=",
"'weight'",
",",
"*"... | Detect communities for temporal graphs.
Each graph is considered to represent a time slice and does not necessarily
need to be defined on the same set of vertices. Nodes in two consecutive
slices are identified on the basis of the ``vertex_id_attr``, i.e. if two
nodes in two consecutive slices have an identica... | [
"Detect",
"communities",
"for",
"temporal",
"graphs",
"."
] | 8de2c3bad736a9deea90b80f104d8444769d331f | https://github.com/vtraag/louvain-igraph/blob/8de2c3bad736a9deea90b80f104d8444769d331f/src/functions.py#L138-L245 |
15,265 | vtraag/louvain-igraph | setup.py | BuildConfiguration.build_ext | def build_ext(self):
"""Returns a class that can be used as a replacement for the
``build_ext`` command in ``distutils`` and that will download and
compile the C core of igraph if needed."""
try:
from setuptools.command.build_ext import build_ext
except ImportError:
... | python | def build_ext(self):
"""Returns a class that can be used as a replacement for the
``build_ext`` command in ``distutils`` and that will download and
compile the C core of igraph if needed."""
try:
from setuptools.command.build_ext import build_ext
except ImportError:
... | [
"def",
"build_ext",
"(",
"self",
")",
":",
"try",
":",
"from",
"setuptools",
".",
"command",
".",
"build_ext",
"import",
"build_ext",
"except",
"ImportError",
":",
"from",
"distutils",
".",
"command",
".",
"build_ext",
"import",
"build_ext",
"buildcfg",
"=",
... | Returns a class that can be used as a replacement for the
``build_ext`` command in ``distutils`` and that will download and
compile the C core of igraph if needed. | [
"Returns",
"a",
"class",
"that",
"can",
"be",
"used",
"as",
"a",
"replacement",
"for",
"the",
"build_ext",
"command",
"in",
"distutils",
"and",
"that",
"will",
"download",
"and",
"compile",
"the",
"C",
"core",
"of",
"igraph",
"if",
"needed",
"."
] | 8de2c3bad736a9deea90b80f104d8444769d331f | https://github.com/vtraag/louvain-igraph/blob/8de2c3bad736a9deea90b80f104d8444769d331f/setup.py#L353-L405 |
15,266 | vtraag/louvain-igraph | src/VertexPartition.py | CPMVertexPartition.Bipartite | def Bipartite(graph, resolution_parameter_01,
resolution_parameter_0 = 0, resolution_parameter_1 = 0,
degree_as_node_size=False, types='type', **kwargs):
""" Create three layers for bipartite partitions.
This creates three layers for bipartite partition necessary for detecting
... | python | def Bipartite(graph, resolution_parameter_01,
resolution_parameter_0 = 0, resolution_parameter_1 = 0,
degree_as_node_size=False, types='type', **kwargs):
""" Create three layers for bipartite partitions.
This creates three layers for bipartite partition necessary for detecting
... | [
"def",
"Bipartite",
"(",
"graph",
",",
"resolution_parameter_01",
",",
"resolution_parameter_0",
"=",
"0",
",",
"resolution_parameter_1",
"=",
"0",
",",
"degree_as_node_size",
"=",
"False",
",",
"types",
"=",
"'type'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
... | Create three layers for bipartite partitions.
This creates three layers for bipartite partition necessary for detecting
communities in bipartite networks. These three layers should be passed to
:func:`Optimiser.optimise_partition_multiplex` with
``layer_weights=[1,-1,-1]``.
Parameters
--------... | [
"Create",
"three",
"layers",
"for",
"bipartite",
"partitions",
"."
] | 8de2c3bad736a9deea90b80f104d8444769d331f | https://github.com/vtraag/louvain-igraph/blob/8de2c3bad736a9deea90b80f104d8444769d331f/src/VertexPartition.py#L865-L1009 |
15,267 | vinta/pangu.py | pangu.py | spacing_file | def spacing_file(path):
"""
Perform paranoid text spacing from file.
"""
# TODO: read line by line
with open(os.path.abspath(path)) as f:
return spacing_text(f.read()) | python | def spacing_file(path):
"""
Perform paranoid text spacing from file.
"""
# TODO: read line by line
with open(os.path.abspath(path)) as f:
return spacing_text(f.read()) | [
"def",
"spacing_file",
"(",
"path",
")",
":",
"# TODO: read line by line",
"with",
"open",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
")",
"as",
"f",
":",
"return",
"spacing_text",
"(",
"f",
".",
"read",
"(",
")",
")"
] | Perform paranoid text spacing from file. | [
"Perform",
"paranoid",
"text",
"spacing",
"from",
"file",
"."
] | 89407cf08dedf9d895c13053dd518d11a20f6c95 | https://github.com/vinta/pangu.py/blob/89407cf08dedf9d895c13053dd518d11a20f6c95/pangu.py#L156-L162 |
15,268 | EventRegistry/event-registry-python | eventregistry/EventForText.py | GetEventForText.compute | def compute(self,
text, # text for which to find the most similar event
lang = "eng"): # language in which the text is written
"""
compute the list of most similar events for the given text
"""
params = { "lang": lang, "text": text, "topClusters... | python | def compute(self,
text, # text for which to find the most similar event
lang = "eng"): # language in which the text is written
"""
compute the list of most similar events for the given text
"""
params = { "lang": lang, "text": text, "topClusters... | [
"def",
"compute",
"(",
"self",
",",
"text",
",",
"# text for which to find the most similar event",
"lang",
"=",
"\"eng\"",
")",
":",
"# language in which the text is written",
"params",
"=",
"{",
"\"lang\"",
":",
"lang",
",",
"\"text\"",
":",
"text",
",",
"\"topClu... | compute the list of most similar events for the given text | [
"compute",
"the",
"list",
"of",
"most",
"similar",
"events",
"for",
"the",
"given",
"text"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/EventForText.py#L42-L57 |
15,269 | EventRegistry/event-registry-python | eventregistry/Analytics.py | Analytics.annotate | def annotate(self, text, lang = None, customParams = None):
"""
identify the list of entities and nonentities mentioned in the text
@param text: input text to annotate
@param lang: language of the provided document (can be an ISO2 or ISO3 code). If None is provided, the language will be ... | python | def annotate(self, text, lang = None, customParams = None):
"""
identify the list of entities and nonentities mentioned in the text
@param text: input text to annotate
@param lang: language of the provided document (can be an ISO2 or ISO3 code). If None is provided, the language will be ... | [
"def",
"annotate",
"(",
"self",
",",
"text",
",",
"lang",
"=",
"None",
",",
"customParams",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"lang\"",
":",
"lang",
",",
"\"text\"",
":",
"text",
"}",
"if",
"customParams",
":",
"params",
".",
"update",
"("... | identify the list of entities and nonentities mentioned in the text
@param text: input text to annotate
@param lang: language of the provided document (can be an ISO2 or ISO3 code). If None is provided, the language will be automatically detected
@param customParams: None or a dict with custom p... | [
"identify",
"the",
"list",
"of",
"entities",
"and",
"nonentities",
"mentioned",
"in",
"the",
"text"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/Analytics.py#L25-L36 |
15,270 | EventRegistry/event-registry-python | eventregistry/Analytics.py | Analytics.sentiment | def sentiment(self, text, method = "vocabulary"):
"""
determine the sentiment of the provided text in English language
@param text: input text to categorize
@param method: method to use to compute the sentiment. possible values are "vocabulary" (vocabulary based sentiment analysis)
... | python | def sentiment(self, text, method = "vocabulary"):
"""
determine the sentiment of the provided text in English language
@param text: input text to categorize
@param method: method to use to compute the sentiment. possible values are "vocabulary" (vocabulary based sentiment analysis)
... | [
"def",
"sentiment",
"(",
"self",
",",
"text",
",",
"method",
"=",
"\"vocabulary\"",
")",
":",
"assert",
"method",
"==",
"\"vocabulary\"",
"or",
"method",
"==",
"\"rnn\"",
"endpoint",
"=",
"method",
"==",
"\"vocabulary\"",
"and",
"\"sentiment\"",
"or",
"\"senti... | determine the sentiment of the provided text in English language
@param text: input text to categorize
@param method: method to use to compute the sentiment. possible values are "vocabulary" (vocabulary based sentiment analysis)
and "rnn" (neural network based sentiment classification)
... | [
"determine",
"the",
"sentiment",
"of",
"the",
"provided",
"text",
"in",
"English",
"language"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/Analytics.py#L50-L60 |
15,271 | EventRegistry/event-registry-python | eventregistry/Analytics.py | Analytics.semanticSimilarity | def semanticSimilarity(self, text1, text2, distanceMeasure = "cosine"):
"""
determine the semantic similarity of the two provided documents
@param text1: first document to analyze
@param text2: second document to analyze
@param distanceMeasure: distance measure to use for compari... | python | def semanticSimilarity(self, text1, text2, distanceMeasure = "cosine"):
"""
determine the semantic similarity of the two provided documents
@param text1: first document to analyze
@param text2: second document to analyze
@param distanceMeasure: distance measure to use for compari... | [
"def",
"semanticSimilarity",
"(",
"self",
",",
"text1",
",",
"text2",
",",
"distanceMeasure",
"=",
"\"cosine\"",
")",
":",
"return",
"self",
".",
"_er",
".",
"jsonRequestAnalytics",
"(",
"\"/api/v1/semanticSimilarity\"",
",",
"{",
"\"text1\"",
":",
"text1",
",",... | determine the semantic similarity of the two provided documents
@param text1: first document to analyze
@param text2: second document to analyze
@param distanceMeasure: distance measure to use for comparing two documents. Possible values are "cosine" (default) or "jaccard"
@returns: dict | [
"determine",
"the",
"semantic",
"similarity",
"of",
"the",
"two",
"provided",
"documents"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/Analytics.py#L63-L71 |
15,272 | EventRegistry/event-registry-python | eventregistry/Analytics.py | Analytics.extractArticleInfo | def extractArticleInfo(self, url, proxyUrl = None, headers = None, cookies = None):
"""
extract all available information about an article available at url `url`. Returned information will include
article title, body, authors, links in the articles, ...
@param url: article url to extract... | python | def extractArticleInfo(self, url, proxyUrl = None, headers = None, cookies = None):
"""
extract all available information about an article available at url `url`. Returned information will include
article title, body, authors, links in the articles, ...
@param url: article url to extract... | [
"def",
"extractArticleInfo",
"(",
"self",
",",
"url",
",",
"proxyUrl",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"cookies",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"url\"",
":",
"url",
"}",
"if",
"proxyUrl",
":",
"params",
"[",
"\"proxyUrl\""... | extract all available information about an article available at url `url`. Returned information will include
article title, body, authors, links in the articles, ...
@param url: article url to extract article information from
@param proxyUrl: proxy that should be used for downloading article inf... | [
"extract",
"all",
"available",
"information",
"about",
"an",
"article",
"available",
"at",
"url",
"url",
".",
"Returned",
"information",
"will",
"include",
"article",
"title",
"body",
"authors",
"links",
"in",
"the",
"articles",
"..."
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/Analytics.py#L83-L104 |
15,273 | EventRegistry/event-registry-python | eventregistry/Analytics.py | Analytics.trainTopicOnTweets | def trainTopicOnTweets(self, twitterQuery, useTweetText=True, useIdfNormalization=True,
normalization="linear", maxTweets=2000, maxUsedLinks=500, ignoreConceptTypes=[],
maxConcepts = 20, maxCategories = 10, notifyEmailAddress = None):
"""
create a new topic and train it using the... | python | def trainTopicOnTweets(self, twitterQuery, useTweetText=True, useIdfNormalization=True,
normalization="linear", maxTweets=2000, maxUsedLinks=500, ignoreConceptTypes=[],
maxConcepts = 20, maxCategories = 10, notifyEmailAddress = None):
"""
create a new topic and train it using the... | [
"def",
"trainTopicOnTweets",
"(",
"self",
",",
"twitterQuery",
",",
"useTweetText",
"=",
"True",
",",
"useIdfNormalization",
"=",
"True",
",",
"normalization",
"=",
"\"linear\"",
",",
"maxTweets",
"=",
"2000",
",",
"maxUsedLinks",
"=",
"500",
",",
"ignoreConcept... | create a new topic and train it using the tweets that match the twitterQuery
@param twitterQuery: string containing the content to search for. It can be a Twitter user account (using "@" prefix or user's Twitter url),
a hash tag (using "#" prefix) or a regular keyword.
@param useTweetTex... | [
"create",
"a",
"new",
"topic",
"and",
"train",
"it",
"using",
"the",
"tweets",
"that",
"match",
"the",
"twitterQuery"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/Analytics.py#L116-L144 |
15,274 | EventRegistry/event-registry-python | eventregistry/Analytics.py | Analytics.trainTopicGetTrainedTopic | def trainTopicGetTrainedTopic(self, uri, maxConcepts = 20, maxCategories = 10,
ignoreConceptTypes=[], idfNormalization = True):
"""
retrieve topic for the topic for which you have already finished training
@param uri: uri of the topic (obtained by calling trainTopicCreateTopic method... | python | def trainTopicGetTrainedTopic(self, uri, maxConcepts = 20, maxCategories = 10,
ignoreConceptTypes=[], idfNormalization = True):
"""
retrieve topic for the topic for which you have already finished training
@param uri: uri of the topic (obtained by calling trainTopicCreateTopic method... | [
"def",
"trainTopicGetTrainedTopic",
"(",
"self",
",",
"uri",
",",
"maxConcepts",
"=",
"20",
",",
"maxCategories",
"=",
"10",
",",
"ignoreConceptTypes",
"=",
"[",
"]",
",",
"idfNormalization",
"=",
"True",
")",
":",
"return",
"self",
".",
"_er",
".",
"jsonR... | retrieve topic for the topic for which you have already finished training
@param uri: uri of the topic (obtained by calling trainTopicCreateTopic method)
@param maxConcepts: number of top concepts to retrieve in the topic
@param maxCategories: number of top categories to retrieve in the topic
... | [
"retrieve",
"topic",
"for",
"the",
"topic",
"for",
"which",
"you",
"have",
"already",
"finished",
"training"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/Analytics.py#L172-L183 |
15,275 | EventRegistry/event-registry-python | eventregistry/examples/TopicPagesExamples.py | createTopicPage1 | def createTopicPage1():
"""
create a topic page directly
"""
topic = TopicPage(er)
topic.addKeyword("renewable energy", 30)
topic.addConcept(er.getConceptUri("biofuel"), 50)
topic.addConcept(er.getConceptUri("solar energy"), 50)
topic.addCategory(er.getCategoryUri("renewable"), 50)
... | python | def createTopicPage1():
"""
create a topic page directly
"""
topic = TopicPage(er)
topic.addKeyword("renewable energy", 30)
topic.addConcept(er.getConceptUri("biofuel"), 50)
topic.addConcept(er.getConceptUri("solar energy"), 50)
topic.addCategory(er.getCategoryUri("renewable"), 50)
... | [
"def",
"createTopicPage1",
"(",
")",
":",
"topic",
"=",
"TopicPage",
"(",
"er",
")",
"topic",
".",
"addKeyword",
"(",
"\"renewable energy\"",
",",
"30",
")",
"topic",
".",
"addConcept",
"(",
"er",
".",
"getConceptUri",
"(",
"\"biofuel\"",
")",
",",
"50",
... | create a topic page directly | [
"create",
"a",
"topic",
"page",
"directly"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/examples/TopicPagesExamples.py#L6-L26 |
15,276 | EventRegistry/event-registry-python | eventregistry/examples/TopicPagesExamples.py | createTopicPage2 | def createTopicPage2():
"""
create a topic page directly, set the article threshold, restrict results to set concepts and keywords
"""
topic = TopicPage(er)
topic.addCategory(er.getCategoryUri("renewable"), 50)
topic.addKeyword("renewable energy", 30)
topic.addConcept(er.getConceptUri("bio... | python | def createTopicPage2():
"""
create a topic page directly, set the article threshold, restrict results to set concepts and keywords
"""
topic = TopicPage(er)
topic.addCategory(er.getCategoryUri("renewable"), 50)
topic.addKeyword("renewable energy", 30)
topic.addConcept(er.getConceptUri("bio... | [
"def",
"createTopicPage2",
"(",
")",
":",
"topic",
"=",
"TopicPage",
"(",
"er",
")",
"topic",
".",
"addCategory",
"(",
"er",
".",
"getCategoryUri",
"(",
"\"renewable\"",
")",
",",
"50",
")",
"topic",
".",
"addKeyword",
"(",
"\"renewable energy\"",
",",
"30... | create a topic page directly, set the article threshold, restrict results to set concepts and keywords | [
"create",
"a",
"topic",
"page",
"directly",
"set",
"the",
"article",
"threshold",
"restrict",
"results",
"to",
"set",
"concepts",
"and",
"keywords"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/examples/TopicPagesExamples.py#L30-L63 |
15,277 | EventRegistry/event-registry-python | eventregistry/QueryEvent.py | QueryEventArticlesIter.count | def count(self, eventRegistry):
"""
return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data
"""
self.setRequestedResult(RequestEventArticles(**self.queryParams))
res = eventRegistry.exe... | python | def count(self, eventRegistry):
"""
return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data
"""
self.setRequestedResult(RequestEventArticles(**self.queryParams))
res = eventRegistry.exe... | [
"def",
"count",
"(",
"self",
",",
"eventRegistry",
")",
":",
"self",
".",
"setRequestedResult",
"(",
"RequestEventArticles",
"(",
"*",
"*",
"self",
".",
"queryParams",
")",
")",
"res",
"=",
"eventRegistry",
".",
"execQuery",
"(",
"self",
")",
"if",
"\"erro... | return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data | [
"return",
"the",
"number",
"of",
"articles",
"that",
"match",
"the",
"criteria"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryEvent.py#L150-L160 |
15,278 | EventRegistry/event-registry-python | eventregistry/QueryArticles.py | QueryArticles.initWithComplexQuery | def initWithComplexQuery(query):
"""
create a query using a complex article query
"""
q = QueryArticles()
# provided an instance of ComplexArticleQuery
if isinstance(query, ComplexArticleQuery):
q._setVal("query", json.dumps(query.getQuery()))
# provid... | python | def initWithComplexQuery(query):
"""
create a query using a complex article query
"""
q = QueryArticles()
# provided an instance of ComplexArticleQuery
if isinstance(query, ComplexArticleQuery):
q._setVal("query", json.dumps(query.getQuery()))
# provid... | [
"def",
"initWithComplexQuery",
"(",
"query",
")",
":",
"q",
"=",
"QueryArticles",
"(",
")",
"# provided an instance of ComplexArticleQuery",
"if",
"isinstance",
"(",
"query",
",",
"ComplexArticleQuery",
")",
":",
"q",
".",
"_setVal",
"(",
"\"query\"",
",",
"json",... | create a query using a complex article query | [
"create",
"a",
"query",
"using",
"a",
"complex",
"article",
"query"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryArticles.py#L218-L235 |
15,279 | EventRegistry/event-registry-python | eventregistry/QueryArticles.py | QueryArticlesIter._getNextArticleBatch | def _getNextArticleBatch(self):
"""download next batch of articles based on the article uris in the uri list"""
# try to get more uris, if none
self._articlePage += 1
# if we have already obtained all pages, then exit
if self._totalPages != None and self._articlePage > self._tota... | python | def _getNextArticleBatch(self):
"""download next batch of articles based on the article uris in the uri list"""
# try to get more uris, if none
self._articlePage += 1
# if we have already obtained all pages, then exit
if self._totalPages != None and self._articlePage > self._tota... | [
"def",
"_getNextArticleBatch",
"(",
"self",
")",
":",
"# try to get more uris, if none",
"self",
".",
"_articlePage",
"+=",
"1",
"# if we have already obtained all pages, then exit",
"if",
"self",
".",
"_totalPages",
"!=",
"None",
"and",
"self",
".",
"_articlePage",
">"... | download next batch of articles based on the article uris in the uri list | [
"download",
"next",
"batch",
"of",
"articles",
"based",
"on",
"the",
"article",
"uris",
"in",
"the",
"uri",
"list"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryArticles.py#L317-L335 |
15,280 | EventRegistry/event-registry-python | eventregistry/QueryEvents.py | QueryEvents.initWithComplexQuery | def initWithComplexQuery(query):
"""
create a query using a complex event query
"""
q = QueryEvents()
# provided an instance of ComplexEventQuery
if isinstance(query, ComplexEventQuery):
q._setVal("query", json.dumps(query.getQuery()))
# provided query... | python | def initWithComplexQuery(query):
"""
create a query using a complex event query
"""
q = QueryEvents()
# provided an instance of ComplexEventQuery
if isinstance(query, ComplexEventQuery):
q._setVal("query", json.dumps(query.getQuery()))
# provided query... | [
"def",
"initWithComplexQuery",
"(",
"query",
")",
":",
"q",
"=",
"QueryEvents",
"(",
")",
"# provided an instance of ComplexEventQuery",
"if",
"isinstance",
"(",
"query",
",",
"ComplexEventQuery",
")",
":",
"q",
".",
"_setVal",
"(",
"\"query\"",
",",
"json",
"."... | create a query using a complex event query | [
"create",
"a",
"query",
"using",
"a",
"complex",
"event",
"query"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryEvents.py#L183-L201 |
15,281 | EventRegistry/event-registry-python | eventregistry/QueryEvents.py | QueryEventsIter.count | def count(self, eventRegistry):
"""
return the number of events that match the criteria
"""
self.setRequestedResult(RequestEventsInfo())
res = eventRegistry.execQuery(self)
if "error" in res:
print(res["error"])
count = res.get("events", {}).get("total... | python | def count(self, eventRegistry):
"""
return the number of events that match the criteria
"""
self.setRequestedResult(RequestEventsInfo())
res = eventRegistry.execQuery(self)
if "error" in res:
print(res["error"])
count = res.get("events", {}).get("total... | [
"def",
"count",
"(",
"self",
",",
"eventRegistry",
")",
":",
"self",
".",
"setRequestedResult",
"(",
"RequestEventsInfo",
"(",
")",
")",
"res",
"=",
"eventRegistry",
".",
"execQuery",
"(",
"self",
")",
"if",
"\"error\"",
"in",
"res",
":",
"print",
"(",
"... | return the number of events that match the criteria | [
"return",
"the",
"number",
"of",
"events",
"that",
"match",
"the",
"criteria"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryEvents.py#L211-L220 |
15,282 | EventRegistry/event-registry-python | eventregistry/ReturnInfo.py | ReturnInfoFlagsBase._setFlag | def _setFlag(self, name, val, defVal):
"""set the objects property propName if the dictKey key exists in dict and it is not the same as default value defVal"""
if not hasattr(self, "flags"):
self.flags = {}
if val != defVal:
self.flags[name] = val | python | def _setFlag(self, name, val, defVal):
"""set the objects property propName if the dictKey key exists in dict and it is not the same as default value defVal"""
if not hasattr(self, "flags"):
self.flags = {}
if val != defVal:
self.flags[name] = val | [
"def",
"_setFlag",
"(",
"self",
",",
"name",
",",
"val",
",",
"defVal",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"flags\"",
")",
":",
"self",
".",
"flags",
"=",
"{",
"}",
"if",
"val",
"!=",
"defVal",
":",
"self",
".",
"flags",
"[",
... | set the objects property propName if the dictKey key exists in dict and it is not the same as default value defVal | [
"set",
"the",
"objects",
"property",
"propName",
"if",
"the",
"dictKey",
"key",
"exists",
"in",
"dict",
"and",
"it",
"is",
"not",
"the",
"same",
"as",
"default",
"value",
"defVal"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/ReturnInfo.py#L15-L20 |
15,283 | EventRegistry/event-registry-python | eventregistry/ReturnInfo.py | ReturnInfoFlagsBase._setVal | def _setVal(self, name, val, defVal = None):
"""set value of name to val in case the val != defVal"""
if val == defVal:
return
if not hasattr(self, "vals"):
self.vals = {}
self.vals[name] = val | python | def _setVal(self, name, val, defVal = None):
"""set value of name to val in case the val != defVal"""
if val == defVal:
return
if not hasattr(self, "vals"):
self.vals = {}
self.vals[name] = val | [
"def",
"_setVal",
"(",
"self",
",",
"name",
",",
"val",
",",
"defVal",
"=",
"None",
")",
":",
"if",
"val",
"==",
"defVal",
":",
"return",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"vals\"",
")",
":",
"self",
".",
"vals",
"=",
"{",
"}",
"self",
... | set value of name to val in case the val != defVal | [
"set",
"value",
"of",
"name",
"to",
"val",
"in",
"case",
"the",
"val",
"!",
"=",
"defVal"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/ReturnInfo.py#L30-L36 |
15,284 | EventRegistry/event-registry-python | eventregistry/ReturnInfo.py | ReturnInfoFlagsBase._getVals | def _getVals(self, prefix = ""):
"""
return the values in the vals dict
in case prefix is "", change the first letter of the name to lowercase, otherwise use prefix+name as the new name
"""
if not hasattr(self, "vals"):
self.vals = {}
dict = {}
for key... | python | def _getVals(self, prefix = ""):
"""
return the values in the vals dict
in case prefix is "", change the first letter of the name to lowercase, otherwise use prefix+name as the new name
"""
if not hasattr(self, "vals"):
self.vals = {}
dict = {}
for key... | [
"def",
"_getVals",
"(",
"self",
",",
"prefix",
"=",
"\"\"",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"vals\"",
")",
":",
"self",
".",
"vals",
"=",
"{",
"}",
"dict",
"=",
"{",
"}",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"vals... | return the values in the vals dict
in case prefix is "", change the first letter of the name to lowercase, otherwise use prefix+name as the new name | [
"return",
"the",
"values",
"in",
"the",
"vals",
"dict",
"in",
"case",
"prefix",
"is",
"change",
"the",
"first",
"letter",
"of",
"the",
"name",
"to",
"lowercase",
"otherwise",
"use",
"prefix",
"+",
"name",
"as",
"the",
"new",
"name"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/ReturnInfo.py#L39-L55 |
15,285 | EventRegistry/event-registry-python | eventregistry/ReturnInfo.py | ReturnInfo.loadFromFile | def loadFromFile(fileName):
"""
load the configuration for the ReturnInfo from a fileName
@param fileName: filename that contains the json configuration to use in the ReturnInfo
"""
assert os.path.exists(fileName), "File " + fileName + " does not exist"
conf = json.load(o... | python | def loadFromFile(fileName):
"""
load the configuration for the ReturnInfo from a fileName
@param fileName: filename that contains the json configuration to use in the ReturnInfo
"""
assert os.path.exists(fileName), "File " + fileName + " does not exist"
conf = json.load(o... | [
"def",
"loadFromFile",
"(",
"fileName",
")",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"fileName",
")",
",",
"\"File \"",
"+",
"fileName",
"+",
"\" does not exist\"",
"conf",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"fileName",
")",
")",
... | load the configuration for the ReturnInfo from a fileName
@param fileName: filename that contains the json configuration to use in the ReturnInfo | [
"load",
"the",
"configuration",
"for",
"the",
"ReturnInfo",
"from",
"a",
"fileName"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/ReturnInfo.py#L453-L470 |
15,286 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.loadTopicPageFromER | def loadTopicPageFromER(self, uri):
"""
load an existing topic page from Event Registry based on the topic page URI
@param uri: uri of the topic page saved in your Event Registry account
"""
params = {
"action": "getTopicPageJson",
"includeConceptDescripti... | python | def loadTopicPageFromER(self, uri):
"""
load an existing topic page from Event Registry based on the topic page URI
@param uri: uri of the topic page saved in your Event Registry account
"""
params = {
"action": "getTopicPageJson",
"includeConceptDescripti... | [
"def",
"loadTopicPageFromER",
"(",
"self",
",",
"uri",
")",
":",
"params",
"=",
"{",
"\"action\"",
":",
"\"getTopicPageJson\"",
",",
"\"includeConceptDescription\"",
":",
"True",
",",
"\"includeTopicPageDefinition\"",
":",
"True",
",",
"\"includeTopicPageOwner\"",
":"... | load an existing topic page from Event Registry based on the topic page URI
@param uri: uri of the topic page saved in your Event Registry account | [
"load",
"an",
"existing",
"topic",
"page",
"from",
"Event",
"Registry",
"based",
"on",
"the",
"topic",
"page",
"URI"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L51-L65 |
15,287 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.loadTopicPageFromFile | def loadTopicPageFromFile(self, fname):
"""
load topic page from an existing file
"""
assert os.path.exists(fname)
f = open(fname, "r", encoding="utf-8")
self.topicPage = json.load(f) | python | def loadTopicPageFromFile(self, fname):
"""
load topic page from an existing file
"""
assert os.path.exists(fname)
f = open(fname, "r", encoding="utf-8")
self.topicPage = json.load(f) | [
"def",
"loadTopicPageFromFile",
"(",
"self",
",",
"fname",
")",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
"f",
"=",
"open",
"(",
"fname",
",",
"\"r\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"self",
".",
"topicPage",
"=",
"... | load topic page from an existing file | [
"load",
"topic",
"page",
"from",
"an",
"existing",
"file"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L76-L82 |
15,288 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.saveTopicPageDefinitionToFile | def saveTopicPageDefinitionToFile(self, fname):
"""
save the topic page definition to a file
"""
open(fname, "w", encoding="utf-8").write(json.dumps(self.topicPage, indent = 4, sort_keys = True)) | python | def saveTopicPageDefinitionToFile(self, fname):
"""
save the topic page definition to a file
"""
open(fname, "w", encoding="utf-8").write(json.dumps(self.topicPage, indent = 4, sort_keys = True)) | [
"def",
"saveTopicPageDefinitionToFile",
"(",
"self",
",",
"fname",
")",
":",
"open",
"(",
"fname",
",",
"\"w\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
".",
"write",
"(",
"json",
".",
"dumps",
"(",
"self",
".",
"topicPage",
",",
"indent",
"=",
"4",
",... | save the topic page definition to a file | [
"save",
"the",
"topic",
"page",
"definition",
"to",
"a",
"file"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L92-L96 |
15,289 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.setArticleThreshold | def setArticleThreshold(self, value):
"""
what is the minimum total weight that an article has to have in order to get it among the results?
@param value: threshold to use
"""
assert isinstance(value, int)
assert value >= 0
self.topicPage["articleTreshWgt"] = valu... | python | def setArticleThreshold(self, value):
"""
what is the minimum total weight that an article has to have in order to get it among the results?
@param value: threshold to use
"""
assert isinstance(value, int)
assert value >= 0
self.topicPage["articleTreshWgt"] = valu... | [
"def",
"setArticleThreshold",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"int",
")",
"assert",
"value",
">=",
"0",
"self",
".",
"topicPage",
"[",
"\"articleTreshWgt\"",
"]",
"=",
"value"
] | what is the minimum total weight that an article has to have in order to get it among the results?
@param value: threshold to use | [
"what",
"is",
"the",
"minimum",
"total",
"weight",
"that",
"an",
"article",
"has",
"to",
"have",
"in",
"order",
"to",
"get",
"it",
"among",
"the",
"results?"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L102-L109 |
15,290 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.setEventThreshold | def setEventThreshold(self, value):
"""
what is the minimum total weight that an event has to have in order to get it among the results?
@param value: threshold to use
"""
assert isinstance(value, int)
assert value >= 0
self.topicPage["eventTreshWgt"] = value | python | def setEventThreshold(self, value):
"""
what is the minimum total weight that an event has to have in order to get it among the results?
@param value: threshold to use
"""
assert isinstance(value, int)
assert value >= 0
self.topicPage["eventTreshWgt"] = value | [
"def",
"setEventThreshold",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"int",
")",
"assert",
"value",
">=",
"0",
"self",
".",
"topicPage",
"[",
"\"eventTreshWgt\"",
"]",
"=",
"value"
] | what is the minimum total weight that an event has to have in order to get it among the results?
@param value: threshold to use | [
"what",
"is",
"the",
"minimum",
"total",
"weight",
"that",
"an",
"event",
"has",
"to",
"have",
"in",
"order",
"to",
"get",
"it",
"among",
"the",
"results?"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L112-L119 |
15,291 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.setMaxDaysBack | def setMaxDaysBack(self, maxDaysBack):
"""
what is the maximum allowed age of the results?
"""
assert isinstance(maxDaysBack, int), "maxDaysBack value has to be a positive integer"
assert maxDaysBack >= 1
self.topicPage["maxDaysBack"] = maxDaysBack | python | def setMaxDaysBack(self, maxDaysBack):
"""
what is the maximum allowed age of the results?
"""
assert isinstance(maxDaysBack, int), "maxDaysBack value has to be a positive integer"
assert maxDaysBack >= 1
self.topicPage["maxDaysBack"] = maxDaysBack | [
"def",
"setMaxDaysBack",
"(",
"self",
",",
"maxDaysBack",
")",
":",
"assert",
"isinstance",
"(",
"maxDaysBack",
",",
"int",
")",
",",
"\"maxDaysBack value has to be a positive integer\"",
"assert",
"maxDaysBack",
">=",
"1",
"self",
".",
"topicPage",
"[",
"\"maxDaysB... | what is the maximum allowed age of the results? | [
"what",
"is",
"the",
"maximum",
"allowed",
"age",
"of",
"the",
"results?"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L164-L170 |
15,292 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.addConcept | def addConcept(self, conceptUri, weight, label = None, conceptType = None):
"""
add a relevant concept to the topic page
@param conceptUri: uri of the concept to be added
@param weight: importance of the provided concept (typically in range 1 - 50)
"""
assert isinstance(w... | python | def addConcept(self, conceptUri, weight, label = None, conceptType = None):
"""
add a relevant concept to the topic page
@param conceptUri: uri of the concept to be added
@param weight: importance of the provided concept (typically in range 1 - 50)
"""
assert isinstance(w... | [
"def",
"addConcept",
"(",
"self",
",",
"conceptUri",
",",
"weight",
",",
"label",
"=",
"None",
",",
"conceptType",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"weight",
",",
"(",
"float",
",",
"int",
")",
")",
",",
"\"weight value has to be a posit... | add a relevant concept to the topic page
@param conceptUri: uri of the concept to be added
@param weight: importance of the provided concept (typically in range 1 - 50) | [
"add",
"a",
"relevant",
"concept",
"to",
"the",
"topic",
"page"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L211-L221 |
15,293 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.addKeyword | def addKeyword(self, keyword, weight):
"""
add a relevant keyword to the topic page
@param keyword: keyword or phrase to be added
@param weight: importance of the provided keyword (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weight value has t... | python | def addKeyword(self, keyword, weight):
"""
add a relevant keyword to the topic page
@param keyword: keyword or phrase to be added
@param weight: importance of the provided keyword (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weight value has t... | [
"def",
"addKeyword",
"(",
"self",
",",
"keyword",
",",
"weight",
")",
":",
"assert",
"isinstance",
"(",
"weight",
",",
"(",
"float",
",",
"int",
")",
")",
",",
"\"weight value has to be a positive or negative integer\"",
"self",
".",
"topicPage",
"[",
"\"keyword... | add a relevant keyword to the topic page
@param keyword: keyword or phrase to be added
@param weight: importance of the provided keyword (typically in range 1 - 50) | [
"add",
"a",
"relevant",
"keyword",
"to",
"the",
"topic",
"page"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L224-L231 |
15,294 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.addCategory | def addCategory(self, categoryUri, weight):
"""
add a relevant category to the topic page
@param categoryUri: uri of the category to be added
@param weight: importance of the provided category (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weigh... | python | def addCategory(self, categoryUri, weight):
"""
add a relevant category to the topic page
@param categoryUri: uri of the category to be added
@param weight: importance of the provided category (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weigh... | [
"def",
"addCategory",
"(",
"self",
",",
"categoryUri",
",",
"weight",
")",
":",
"assert",
"isinstance",
"(",
"weight",
",",
"(",
"float",
",",
"int",
")",
")",
",",
"\"weight value has to be a positive or negative integer\"",
"self",
".",
"topicPage",
"[",
"\"ca... | add a relevant category to the topic page
@param categoryUri: uri of the category to be added
@param weight: importance of the provided category (typically in range 1 - 50) | [
"add",
"a",
"relevant",
"category",
"to",
"the",
"topic",
"page"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L234-L241 |
15,295 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.addSource | def addSource(self, sourceUri, weight):
"""
add a news source to the topic page
@param sourceUri: uri of the news source to add to the topic page
@param weight: importance of the news source (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weight ... | python | def addSource(self, sourceUri, weight):
"""
add a news source to the topic page
@param sourceUri: uri of the news source to add to the topic page
@param weight: importance of the news source (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weight ... | [
"def",
"addSource",
"(",
"self",
",",
"sourceUri",
",",
"weight",
")",
":",
"assert",
"isinstance",
"(",
"weight",
",",
"(",
"float",
",",
"int",
")",
")",
",",
"\"weight value has to be a positive or negative integer\"",
"self",
".",
"topicPage",
"[",
"\"source... | add a news source to the topic page
@param sourceUri: uri of the news source to add to the topic page
@param weight: importance of the news source (typically in range 1 - 50) | [
"add",
"a",
"news",
"source",
"to",
"the",
"topic",
"page"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L244-L251 |
15,296 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.addSourceLocation | def addSourceLocation(self, sourceLocationUri, weight):
"""
add a list of relevant sources by identifying them by their geographic location
@param sourceLocationUri: uri of the location where the sources should be geographically located
@param weight: importance of the provided list of s... | python | def addSourceLocation(self, sourceLocationUri, weight):
"""
add a list of relevant sources by identifying them by their geographic location
@param sourceLocationUri: uri of the location where the sources should be geographically located
@param weight: importance of the provided list of s... | [
"def",
"addSourceLocation",
"(",
"self",
",",
"sourceLocationUri",
",",
"weight",
")",
":",
"assert",
"isinstance",
"(",
"weight",
",",
"(",
"float",
",",
"int",
")",
")",
",",
"\"weight value has to be a positive or negative integer\"",
"self",
".",
"topicPage",
... | add a list of relevant sources by identifying them by their geographic location
@param sourceLocationUri: uri of the location where the sources should be geographically located
@param weight: importance of the provided list of sources (typically in range 1 - 50) | [
"add",
"a",
"list",
"of",
"relevant",
"sources",
"by",
"identifying",
"them",
"by",
"their",
"geographic",
"location"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L254-L261 |
15,297 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.addSourceGroup | def addSourceGroup(self, sourceGroupUri, weight):
"""
add a list of relevant sources by specifying a whole source group to the topic page
@param sourceGroupUri: uri of the source group to add
@param weight: importance of the provided list of sources (typically in range 1 - 50)
""... | python | def addSourceGroup(self, sourceGroupUri, weight):
"""
add a list of relevant sources by specifying a whole source group to the topic page
@param sourceGroupUri: uri of the source group to add
@param weight: importance of the provided list of sources (typically in range 1 - 50)
""... | [
"def",
"addSourceGroup",
"(",
"self",
",",
"sourceGroupUri",
",",
"weight",
")",
":",
"assert",
"isinstance",
"(",
"weight",
",",
"(",
"float",
",",
"int",
")",
")",
",",
"\"weight value has to be a positive or negative integer\"",
"self",
".",
"topicPage",
"[",
... | add a list of relevant sources by specifying a whole source group to the topic page
@param sourceGroupUri: uri of the source group to add
@param weight: importance of the provided list of sources (typically in range 1 - 50) | [
"add",
"a",
"list",
"of",
"relevant",
"sources",
"by",
"specifying",
"a",
"whole",
"source",
"group",
"to",
"the",
"topic",
"page"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L264-L271 |
15,298 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.addLocation | def addLocation(self, locationUri, weight):
"""
add relevant location to the topic page
@param locationUri: uri of the location to add
@param weight: importance of the provided location (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weight value... | python | def addLocation(self, locationUri, weight):
"""
add relevant location to the topic page
@param locationUri: uri of the location to add
@param weight: importance of the provided location (typically in range 1 - 50)
"""
assert isinstance(weight, (float, int)), "weight value... | [
"def",
"addLocation",
"(",
"self",
",",
"locationUri",
",",
"weight",
")",
":",
"assert",
"isinstance",
"(",
"weight",
",",
"(",
"float",
",",
"int",
")",
")",
",",
"\"weight value has to be a positive or negative integer\"",
"self",
".",
"topicPage",
"[",
"\"lo... | add relevant location to the topic page
@param locationUri: uri of the location to add
@param weight: importance of the provided location (typically in range 1 - 50) | [
"add",
"relevant",
"location",
"to",
"the",
"topic",
"page"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L274-L281 |
15,299 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.setLanguages | def setLanguages(self, languages):
"""
restrict the results to the list of specified languages
"""
if isinstance(languages, six.string_types):
languages = [languages]
for lang in languages:
assert len(lang) == 3, "Expected to get language in ISO3 code"
... | python | def setLanguages(self, languages):
"""
restrict the results to the list of specified languages
"""
if isinstance(languages, six.string_types):
languages = [languages]
for lang in languages:
assert len(lang) == 3, "Expected to get language in ISO3 code"
... | [
"def",
"setLanguages",
"(",
"self",
",",
"languages",
")",
":",
"if",
"isinstance",
"(",
"languages",
",",
"six",
".",
"string_types",
")",
":",
"languages",
"=",
"[",
"languages",
"]",
"for",
"lang",
"in",
"languages",
":",
"assert",
"len",
"(",
"lang",... | restrict the results to the list of specified languages | [
"restrict",
"the",
"results",
"to",
"the",
"list",
"of",
"specified",
"languages"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L284-L292 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.