Skip to content

Commit ad45ecf

Browse files
author
sabaanwar
committed
bug fixes
1 parent 3ee7a2e commit ad45ecf

File tree

7 files changed

+62
-73
lines changed

7 files changed

+62
-73
lines changed

src_vue/persistence/db.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,9 @@ def get_features(self, word1: str, time_id: int, is_frequency_required=False) ->
696696
else:
697697
for row in f:
698698
features[str(row['feature'])] = {'score': float(row['score']),
699-
'freq': float(row['freq'])}
699+
'freq': float(row['freq'])}
700700

701+
# 'norm_freq': float(row['norm_freq'])
701702
return features
702703

703704
def get_feature_target_filter_set(self, word1: str, time_ids: List[int]) -> Set[str]:
@@ -852,7 +853,7 @@ def get_wordfeature_counts(self, word1: str, feature:str) -> Dict[int, int]:
852853
"""
853854
f = self.db.query(query)
854855
for row in f:
855-
feature_scores[int(row['time_id'])] = int(row['freq'])
856+
feature_scores[int(row['time_id'])] = float(row['freq'])
856857
# print("--------------------------------------")
857858

858859
return feature_scores

src_vue/scot.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_config():
4444
"local": 'config/config_local.json', # local
4545
}
4646

47-
server = "ltdocker"
47+
server = "local"
4848
available_collections = "dev"
4949

5050
config_path = CONFIG_PATHS[server]
@@ -202,5 +202,5 @@ def wordfeaturecounts_get(collection="default"):
202202
# this is not permanent (this is why we do it again and again ...)
203203
sys.path.append(str(Path(__file__).parent.absolute()))
204204
# use the config file to get host and database parameters
205-
# app.run(host=get_config()['flask_host'])
206-
app.run(port=5001, debug=True)
205+
app.run(host=get_config()['flask_host'], debug=True)
206+
# app.run(port=5001, debug=False)

src_vue/static/l2_d3_graph.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1180,18 +1180,17 @@ function skip_through_time_slices_d3() {
11801180
let in_target_interval = false;
11811181

11821182
let interval = parseInt(vueData.interval_id);
1183-
11841183
// check if source time ids of a link include the time slice id of the selected interval
1185-
if (source_time_ids.includes(interval)) {
1186-
in_source_interval = true;
1187-
}
1184+
if (!(source_time_ids === null || typeof source_time_ids === "undefined") &&
1185+
source_time_ids.includes(interval)) {
11881186

1187+
in_source_interval = true;
1188+
}q
11891189
// check if the target time ids of a link include the time slice if of the selected interval
1190-
if (
1191-
!(target_time_ids === null || typeof target_time_ids === "undefined") &&
1192-
target_time_ids.includes(interval)
1193-
) {
1194-
in_target_interval = true;
1190+
if (!(target_time_ids === null || typeof target_time_ids === "undefined") &&
1191+
target_time_ids.includes(interval)) {
1192+
1193+
in_target_interval = true;
11951194
}
11961195

11971196
// the link only has opacity 1.0 if both source and target are in the selected time slice

src_vue/static/l2_vue_frame_sidebarclustertime.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ Vue.component("frame-sidebarclustertime", {
163163
from axios
164164
*/
165165
get_cluster_information_filtered(cluster) {
166-
vueApp.selected_cluster = cluster
166+
vueApp.selected_cluster = cluster
167+
vueApp.selected_contexts_cluster_all = new Map()
167168
graph.props.cluster_target_filter = true;
168169
get_cluster_information_axios(cluster);
169170
},
170171
get_cluster_information(cluster) {
171-
vueApp.selected_cluster = cluster
172+
vueApp.selected_cluster = cluster
173+
vueApp.selected_contexts_cluster_all = new Map()
172174
graph.props.cluster_target_filter = false;
173175
get_cluster_information_axios(cluster);
174176
},

src_vue/static/l2_vue_frame_sidebargraph.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Vue.component("frame-sidebargraph", {
246246
<!-- h5 class="sidebar-section__title"> Hello </h5-->
247247
<b-form-group class="ml-2 mr-2 mb-2">
248248
<b-form-radio-group size="sm" v-model="left_selected" :options="left_options" buttons
249-
button-variant="info" name="radios-btn-default"></b-form-radio-group>
249+
button-variant="info" name="radios-btn-default" ></b-form-radio-group>
250250
</b-form-group>
251251
<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX SIDEBAR-LEFT CREATE GRAPH XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-->
252252
<div class="ml-2 mr-2 mb-2" v-if="left_selected === 'graph_data'">

src_vue/static/l3_connector.js

+41-56
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ async function getCollections_io() {
1515
vueApp.collections = res.data;
1616
vueApp.collections_names = Object.keys(vueApp.collections);
1717
vueApp.collection_name = vueApp.collections_names[0];
18+
vueApp.collection_name_short = vueApp.collection_name.split('--').slice(0,-1).join('--')
19+
1820
vueApp.is_ES_available = vueApp.collections[vueApp.collection_name].is_ES_available;
1921

2022
vueApp.getGraphTypes();
@@ -465,6 +467,37 @@ function docSearch_io(wort1, wort2) {
465467
/**
466468
* LOAD AND SAVE GRAPH TO JSON --------------------------------------------------------------------------------------
467469
*/
470+
function timediff_info(){
471+
let interval_timediff_info = ""
472+
if (vueApp.interval_start != 0){
473+
interval_timediff_info += '-interval-' +
474+
vueApp.interval_start + "_" + vueApp.interval_end
475+
}
476+
if (vueApp.interval_id != 0){
477+
interval_timediff_info += '-timeslice-' +
478+
vueApp.start_years[vueApp.interval_id-1].text + "_" + vueApp.end_years[vueApp.interval_id-1].text
479+
}
480+
481+
if (interval_timediff_info != ""){
482+
interval_timediff_info = '--timediff' + interval_timediff_info
483+
}
484+
return interval_timediff_info
485+
}
486+
487+
function base_filename(){
488+
const filename = vueApp.collection_name_short + '--' +
489+
graph.props.start_year + "-" + graph.props.end_year + '--' +
490+
graph.props.target_word +
491+
"_" +
492+
graph.props.n_nodes +
493+
"_" +
494+
graph.props.density +
495+
"_" +
496+
graph.props.graph_type;
497+
// "_" +
498+
// graph.props.start_year + "_" + graph.props.end_year +
499+
return filename;
500+
}
468501

469502
function saveGraph_io() {
470503
// harmonize all cluster colors
@@ -478,17 +511,7 @@ function saveGraph_io() {
478511
const url = window.URL.createObjectURL(blob);
479512
console.log(url)
480513
a.href = url;
481-
a.download = vueApp.collection_name + '--'+
482-
graph.props.target_word +
483-
"_" +
484-
graph.props.n_nodes +
485-
"_" +
486-
graph.props.density +
487-
"_" +
488-
graph.props.graph_type +
489-
'_' +
490-
graph.props.start_year + "_" + graph.props.end_year +
491-
".json";
514+
a.download = base_filename() + ".json";
492515
a.click();
493516
setTimeout(() => {
494517
window.URL.revokeObjectURL(url);
@@ -509,26 +532,8 @@ function loadGraph_io() {
509532
}
510533

511534
function saveGraphSVG_io() {
512-
const filename = vueApp.collection_name + '--'+
513-
graph.props.target_word +
514-
"_" +
515-
graph.props.n_nodes +
516-
"_" +
517-
graph.props.density +
518-
"_" +
519-
graph.props.graph_type +
520-
"_" +
521-
graph.props.start_year + "_" + graph.props.end_year
522-
;
523-
// svgExport.downloadSvg(document.querySelector("#svg"),
524-
// filename,
525-
// {
526-
// width: svg_width,
527-
// height: svg_height,
528-
// scale: 0.95,
529-
// }
530-
// );
531535

536+
const filename = base_filename() + timediff_info() ;
532537
saveSvg(document.querySelector("#svg"), filename + ".svg",
533538
{
534539
left: viewbox_pan_horizontal,
@@ -542,29 +547,8 @@ function saveGraphSVG_io() {
542547
}
543548

544549
function saveGraphPNG_io() {
545-
const filename = vueApp.collection_name + '--'+
546-
graph.props.target_word +
547-
"_" +
548-
graph.props.n_nodes +
549-
"_" +
550-
graph.props.density +
551-
"_" +
552-
graph.props.graph_type +
553-
"_" +
554-
graph.props.start_year + "_" + graph.props.end_year
555-
;
556-
557-
// svgExport.downloadPng(document.querySelector("#svg"),
558-
// filename,
559-
// {
560-
// width: svg_width,
561-
// height: svg_height,
562-
// scale: 5,
563-
// transparentBackgroundReplace: 'white',
564-
// transparent: false,
565-
// }
566-
// );
567550

551+
const filename = base_filename() + timediff_info() ;
568552
saveSvgAsPng(document.querySelector("#svg"), filename + ".png",
569553
{
570554
left: viewbox_pan_horizontal,
@@ -604,10 +588,11 @@ function saveDocs_io(jo, bim) {
604588
document.body.appendChild(a);
605589
const url2 = window.URL.createObjectURL(blob);
606590
a.href = url2;
607-
a.download = vueApp.bim_fields[0]["label"] + '_' + bim + '_' + vueApp.bim_fields[2]["label"]
608-
+ '_'
609-
+ graph.props.start_year + "_" + graph.props.end_year
610-
+ ".tsv";
591+
a.download = vueApp.collection_name_short + '--' +
592+
graph.props.start_year + "-" + graph.props.end_year + '--' +
593+
vueApp.bim_fields[0]["label"] + '_' + bim + '_' + vueApp.bim_fields[2]["label"]
594+
+ '_' + 'Sentences'
595+
+ ".tsv";
611596

612597
a.click();
613598
setTimeout(() => {

src_vue/static/l3_data.js

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ let vueData = {
105105
// stored in background: The key is unique identifier of the collection and is used for querying data from the backend
106106
collection_key: "0",
107107
is_ES_available: false,
108+
// short name for io functions purpose
109+
collection_name_short: "",
108110
// Selected start-year out of all possible start years for the selected collection
109111
start_year: 0,
110112
// dropdown list: all possible start years per selected collection queried from the database after selection of collection

0 commit comments

Comments
 (0)