-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d68f156
commit 3edf4d7
Showing
9 changed files
with
268 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ __pycache__/ | |
*$py.class | ||
|
||
.ipynb_checkpoints | ||
.idea/ | ||
*.pyc | ||
*_.ipynb | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import argonaut.utils.io as io | ||
import argonaut.utils.common_utils as utils | ||
|
||
|
||
def user_nodes_to_lines(Graph, sep=','): | ||
lines = [] | ||
for node_id in Graph.nodes: | ||
text = list_to_string(Graph.node[node_id].get('text', '')) | ||
lines += user_node_to_text(node_id, text, sep=sep) | ||
return lines | ||
|
||
def comment_nodes_to_lines(Graph, sep=','): | ||
lines = [] | ||
for node_id in Graph.nodes: | ||
text = Graph.node[node_id].get('text', '') | ||
user = Graph.node[node_id].get('user', '') | ||
lines += comment_node_to_text(node_id, text, user, sep=sep) | ||
return lines | ||
|
||
def edges_to_lines(Graph, sep=','): | ||
lines = [] | ||
for source, dest, data in Graph.edges(data=True): | ||
weight = str(data['weight']) if 'weight' in data else '' | ||
lines += edge_to_text(source, dest, weight, sep=sep) | ||
return lines | ||
|
||
|
||
|
||
def user_node_to_text(node_id, text, sep=','): | ||
return f'{node_id}{sep}{text}' | ||
|
||
def comment_node_to_text(node_id, text, user, sep=','): | ||
return f'{node_id}{sep}{text}{sep}{user}' | ||
|
||
def edge_to_text(source, dest, weight, sep=','): | ||
return f'{source}{sep}{dest}{sep}{weight}' | ||
|
||
|
||
def list_to_string(l, sep=' --- '): | ||
return sep.join(l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.