semasioFlow.utils module¶
- semasioFlow.utils.booleanize(mtx, include_negative=True)¶
Transform matrix into matrix of 1’s and 0’s.
- Parameters
mtx (
TypeTokenMatrix
) –include_negative (bool) – Whether negative values should be transformed to 1’s.
- Returns
- Return type
TypeTokenMatrix
- semasioFlow.utils.countCws(tokens)¶
Count the context words co-occurring with each token in a matrix.
- Parameters
tokens (
TypeTokenMatrix
) – (Boolean) token-level matrix to count context words from- Returns
Keys are token IDs and values are the number of context words with nonzero values in that matrix.
- Return type
dict
- semasioFlow.utils.fullMerge(df1, df2)¶
Wrapper for outer merge of pandas DataFrames by index.
- Parameters
df1 (
pandas.DataFrame
) –df2 (
pandas.DataFrame
) –
- Returns
Outer merge by index of both dataframes.
- Return type
pandas.DataFrame
- semasioFlow.utils.listCws(tokens)¶
List the context words co-occurring with each token in a matrix.
- Parameters
tokens (
TypeTokenMatrix
) – (Boolean) token-level matrix to count context words from- Returns
Keys are token IDs and values are ;-separated lists of context words with nonzero values in that matrix.
- Return type
dict
- semasioFlow.utils.plotPatterns(macros)¶
Visualize dependency macros as graphs.
- Parameters
macros (list of :class:~nephosem.core.graph.MacroGraph) – Can be obtained with SemasioFlow.load.loadMacro().