-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
executable file
·109 lines (98 loc) · 3.81 KB
/
server.R
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
library(shiny)
library(DT)
library(lingtypology)
library(dplyr)
library(leaflet)
function(input, output) {
# by sound ------------------------------------------------------------
database <- read.csv("/app/database.csv", sep = "\t", stringsAsFactors = FALSE)
final_sound <- unique(database[, c(1, 2, 5)])
final_sound$segments <- "—"
output$sound_map <- renderLeaflet({
database[,-7] %>%
distinct() %>%
group_by(language) %>%
filter(segments_IPA %in% input$sound_search_without) %>%
count() %>%
filter(n == length(input$sound_search_without)) %>%
select(language) ->
remove_languages
database[,-7] %>%
distinct() %>%
group_by(language) %>%
filter(segments_IPA %in% input$sound_search) %>%
arrange(segments_IPA) %>%
mutate(segments = paste(segments_IPA, collapse = ", ")) %>%
count(language, segments, source, branch) %>%
full_join(., anti_join(final_sound, ., by = "language")) %>%
select(-n) %>%
anti_join(., remove_languages) ->
final_sound
table <- final_sound
table$language <- lingtypology::url.lang(table$language)
output$sound_table <- DT::renderDataTable(
table,
filter = 'top',
rownames = FALSE,
options = list(pageLength = 7, autoWidth = FALSE, dom = 'tip'),
escape = FALSE)
map.feature(final_sound$language,
features = final_sound$branch,
stroke.features = final_sound$segments,
stroke.color = "Set3",
label = final_sound$language,
popup = paste(final_sound$source),
label.hide = T)
})
# by feature ------------------------------------------------------------
database <- read.csv("/app/database.csv", sep = "\t", stringsAsFactors = FALSE)
final_features <- unique(database[, c(1, 2, 5)])
final_features$features <- "—"
output$feature_map <- renderLeaflet({
database %>%
distinct(segments_IPA, features) %>%
group_by(segments_IPA) %>%
filter(features %in% input$feature_search_without) %>%
count() %>%
filter(n == length(input$feature_search_without)) %>%
select(segments_IPA) ->
remove_segments
database %>%
filter(features %in% input$feature_search) %>%
distinct(language, segments_IPA, source, features, branch) %>%
arrange(features) %>%
mutate(features = paste(unique(features), collapse = ", ")) %>%
count(language, segments_IPA, features, source, branch) %>%
filter(n == length(input$feature_search)) %>%
full_join(., anti_join(final_features, ., by = "language")) %>%
select(-n) %>%
anti_join(., remove_segments) ->
final_features
table <- final_features
table$language <- lingtypology::url.lang(table$language)
output$feature_table <- DT::renderDataTable(
table,
filter = 'top',
rownames = FALSE,
options = list(pageLength = 7, autoWidth = FALSE, dom = 'tip'),
escape = FALSE)
map.feature(final_features$language,
features = final_features$branch,
stroke.features = final_features$features,
stroke.color = "Set3",
label = final_features$language,
popup = paste(final_features$source),
label.hide = T)
})
# bibliography ------------------------------------------------------------
bibliography <- read.csv("/app/bibliography.csv", sep = "\t", stringsAsFactors = FALSE)
bibliography$language <- lingtypology::url.lang(bibliography$language)
bibliography$language
output$bibliography <- DT::renderDataTable(
bibliography,
filter = 'top',
rownames = FALSE,
options = list(pageLength = 7, autoWidth = FALSE, dom = 'tip'),
escape = FALSE
)
}