-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitQuerySearchExport.R
More file actions
153 lines (126 loc) · 4.35 KB
/
BitQuerySearchExport.R
File metadata and controls
153 lines (126 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
createD3_PreJSON_CRAN = function(meta_list, gh_org, full_link, cl_topic_vec = NULL, cluster = NULL, debug = FALSE) {
export_l = list()
for (i in 1:length(meta_list)) {
meta = meta_list[[i]]
if (!is.null(cl_topic_vec) && !is.null(cluster)) {
artist_str = cl_topic_vec[cluster[i]]
} else {
# artist_str = expandBook(yaml.getQField(meta, "p"))
artist_str = gh_org[i]
}
new_el = list(
name = meta.getDField(meta, cran_dfield_list, "p"),
artist = artist_str,
#canonical enumeration
id = i,
#size of the metainfo file (Byte)
playcount = sum(nchar(meta)),
description = paste(meta.getDField(meta, cran_dfield_list, "p"),
meta.getDField(meta, cran_dfield_list, "d"),
meta.getDField(meta, cran_dfield_list, "t"),
meta.getDField(meta, cran_dfield_list, "a")),
# multi SW mode
software = "r",
book = gh_org[i],
full_link = full_link[i]
)
if (debug) { print(new_el) }
export_l = c(export_l, list(new_el))
}
return(export_l)
}
createD3_PreJSON_Gitenberg = function(meta_list, gh_org, full_link, cl_topic_vec = NULL, cluster = NULL, debug = FALSE) {
export_l = list()
for (i in 1:length(meta_list)) {
meta = meta_list[[i]]
if (!is.null(cl_topic_vec) && !is.null(cluster)) {
artist_str = cl_topic_vec[cluster[i]]
} else {
artist_str = gh_org[i]
}
new_el = list(
name = meta.getDField(meta, gitenberg_dfield_list, "t"),
artist = artist_str,
#canonical enumeration
id = i,
#size of the metainfo file (Byte)
playcount = sum(nchar(meta)),
description = paste(meta.getDField(meta, gitenberg_dfield_list, "t"),
meta.getDField(meta, gitenberg_dfield_list, "d"),
meta.getDField(meta, gitenberg_dfield_list, "s"),
meta.getDField(meta, gitenberg_dfield_list, "c")),
# multi SW mode
software = "gitenberg",
book = gh_org[i],
full_link = full_link[i]
)
if (debug) { print(new_el) }
export_l = c(export_l, list(new_el))
}
return(export_l)
}
createD3_PreJSON_NPM_PHP = function(meta_list, meta_dfield_list, gh_org, full_link, cl_topic_vec = NULL, cluster = NULL, debug = FALSE) {
export_l = list()
for (i in 1:length(meta_list)) {
meta = meta_list[[i]]
if (!is.null(cl_topic_vec) && !is.null(cluster)) {
artist_str = cl_topic_vec[cluster[i]]
} else {
artist_str = gh_org[i]
}
if (class(meta_dfield_list) == "php") {software_str = "php"} else
if (class(meta_dfield_list) == "npm") {software_str = "npm"} else {software_str = "npm"}
new_el = list(
name = meta.getDField(meta, meta_dfield_list, "n"),
artist = artist_str,
#canonical enumeration
id = i,
#size of the metainfo file (Byte)
playcount = sum(nchar(meta)),
description = paste(meta.getDField(meta, meta_dfield_list, "n"),
meta.getDField(meta, meta_dfield_list, "d"),
meta.getDField(meta, meta_dfield_list, "k"),
meta.getDField(meta, meta_dfield_list, "a")),
# multi SW mode
software = software_str,
book = gh_org[i],
full_link = full_link[i]
)
if (debug) { print(new_el) }
export_l = c(export_l, list(new_el))
}
return(export_l)
}
createD3_PreJSON_MD = function(meta_list, gh_path, gh_org, full_link, cl_topic_vec = NULL, cluster = NULL, debug = FALSE) {
export_l = list()
for (i in 1:length(meta_list)) {
meta = meta_list[[i]]
if (!is.null(cl_topic_vec) && !is.null(cluster)) {
artist_str = cl_topic_vec[cluster[i]]
} else {
# artist_str = expandBook(yaml.getQField(meta, "p"))
artist_str = gh_org[i]
}
meta_cleaned = gsub("[^A-Za-z0-9]", " ", meta)
playcount_cleaned = sum(nchar(meta))
if (is.na(playcount_cleaned) | playcount_cleaned <= 0 ) {playcount_cleaned = 1}
new_el = list(
name = gh_path[i],
artist = artist_str,
#canonical enumeration
id = i,
#size of the metainfo file (Byte)
playcount = playcount_cleaned,
# description = meta,
# description = str_replace_all(meta, "[^[:alnum:]]", " "),
description = paste(gh_path[i], artist_str, meta_cleaned),
# multi SW mode
software = "md",
book = gh_org[i],
full_link = full_link[i]
)
if (debug) { print(new_el) }
export_l = c(export_l, list(new_el))
}
return(export_l)
}