hollywood_social_network_analysis
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
hollywood_social_network_analysis [2019/09/15 14:11] – hkimscil | hollywood_social_network_analysis [2024/11/14 10:26] (current) – hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | obsolete |
- | </ | + | |
- | Now load the packages by calling: | + | |
- | + | ||
- | < | + | |
- | library(igraph) | + | |
- | library(network) | + | |
- | library(ergm)</ | + | |
- | + | ||
- | Define the endpoint that will provide you with the triples by | + | |
- | + | ||
- | < | + | |
- | + | ||
- | State that there are no further options to send to the SPARQL server. These options are sent as HTTP parameters and differ per end point. For example, Jena Fuseki can take the option " | + | |
- | + | ||
- | < | + | |
- | </ | + | |
- | For a local Jena Fuseki installation hosting the same data in the LOP graph you can use the following options (uncommented, | + | |
- | + | ||
- | < | + | |
- | # options <- " | + | |
- | + | ||
- | To shorten the URIs of the data that we get back, use some namespace declarations like this | + | |
- | + | ||
- | < | + | |
- | sparql_prefix <- " | + | |
- | PREFIX dc: < | + | |
- | PREFIX rdfs: < | + | |
- | PREFIX xsd: < | + | |
- | "</ | + | |
- | The data you will now be able to access follows the DBpedia schema. An example of the structure of the graphs in the triple store is shown below. | + | |
- | + | ||
- | dbpedia_movie_schema | + | |
- | The queries will match parts of this graph. | + | |
- | + | ||
- | Let's write a query that gets all actors, the movies they star in, and the director and release date of those movies. Also, we only want American movies, names in english, and dates that are correct XML Schema dates (ISO dates). If you use the SPARQL function to fire the query, you will get back an R data frame that contains the results. Every variable in the SPARQL query will correspond to a column in a result table data frame. | + | |
- | + | ||
- | < | + | |
- | ' | + | |
- | WHERE { | + | |
- | ?m dc:subject < | + | |
- | ?m rdfs:label ?movie . | + | |
- | | + | |
- | ?m dbp: | + | |
- | | + | |
- | ?m dbp: | + | |
- | ?a rdfs:label ?actor . | + | |
- | | + | |
- | ?m dbp: | + | |
- | ?d rdfs:label ?director . | + | |
- | | + | |
- | | + | |
- | + | ||
- | Sys.setenv(TZ = " | + | |
- | res <- SPARQL(endpoint, | + | |
- | + | ||
- | res</ | + | |
- | < | + | |
- | # output: | + | |
- | # | + | |
- | # 1 " | + | |
- | # 2 " | + | |
- | # 3 " | + | |
- | # 4 " | + | |
- | # 5 " | + | |
- | # ...</ | + | |
- | + | ||
- | + | ||
- | < | + | |
- | </ | + | |
- | + | ||
- | < | + | |
- | # | + | |
- | # 1 " | + | |
- | # 2 " | + | |
- | # 3 " | + | |
- | # 4 " | + | |
- | # 5 " | + | |
- | # ... | + | |
- | </ | + | |
- | + |
hollywood_social_network_analysis.1568524300.txt.gz · Last modified: 2019/09/15 14:11 by hkimscil