--- a/cms/app-client/app/mirage/config.js Sat May 07 15:15:01 2016 +0200
+++ b/cms/app-client/app/mirage/config.js Sun May 08 14:21:22 2016 +0200
@@ -41,6 +41,14 @@
return res;
});
+ this.get('/discourses', function(db) {
+ var res = {};
+ _.each(db.discourses, function(discourse) {
+ res[discourse.id] = {'label': discourse.label, 'count': discourse.count};
+ });
+ return res;
+ });
+
this.get('/lexvo/:ids', function(db, request) {
var langIds = decodeURIComponent(request.params.ids);
var resMap = _.reduce(langIds.split(','), function(res, id) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/mirage/fixtures/discourses.js Sun May 08 14:21:22 2016 +0200
@@ -0,0 +1,1 @@
+export default [];
\ No newline at end of file
--- a/cms/app-client/package.json Sat May 07 15:15:01 2016 +0200
+++ b/cms/app-client/package.json Sun May 08 14:21:22 2016 +0200
@@ -1,58 +1,59 @@
{
- "name": "app-client",
- "version": "0.0.1",
- "description": "Small description for app-client goes here",
- "private": true,
- "directories": {
- "doc": "doc",
- "test": "tests"
- },
- "scripts": {
- "build": "ember build",
- "start": "ember server",
- "test": "ember test",
- "dl-documents": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/documents/ -d app/mirage/fixtures/documents.js -t documents -p 2 -f es6",
- "dl-themes": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/themes/ -d app/mirage/fixtures/themes.js -t themes -f es6"
- },
- "repository": "",
- "engines": {
- "node": ">= 0.10.0"
- },
- "author": "",
- "license": "MIT",
- "devDependencies": {
- "bower": "^1.7.9",
- "broccoli-asset-rev": "^2.4.2",
- "broccoli-funnel": "^1.0.1",
- "broccoli-merge-trees": "^1.1.1",
- "broccoli-static-compiler": "^0.2.2",
- "corpus-common-addon": "file:../../common/corpus-common-addon",
- "ember-ajax": "^2.0.1",
- "ember-cli": "2.6.0-beta.2",
- "ember-cli-app-version": "^1.0.0",
- "ember-cli-babel": "^5.1.6",
- "ember-cli-d3": "1.1.6",
- "ember-cli-dependency-checker": "^1.2.0",
- "ember-cli-htmlbars": "^1.0.3",
- "ember-cli-htmlbars-inline-precompile": "^0.3.1",
- "ember-cli-inject-live-reload": "^1.4.0",
- "ember-cli-jshint": "^1.0.0",
- "ember-cli-mirage": "0.1.13",
- "ember-cli-qunit": "^1.4.0",
- "ember-cli-release": "1.0.0-beta.1",
- "ember-cli-sass": "5.3.1",
- "ember-cli-sri": "^2.1.0",
- "ember-cli-uglify": "^1.2.0",
- "ember-data": "^2.6.0-beta.1",
- "ember-data-fixture-adapter": "1.13.0",
- "ember-disable-proxy-controllers": "^1.0.1",
- "ember-export-application-global": "^1.0.5",
- "ember-font-awesome": "martndemus/ember-font-awesome#pull/91/head",
- "ember-load-initializers": "^0.5.1",
- "ember-lodash": "0.0.6",
- "ember-resolver": "^2.0.3",
- "ember-welcome-page": "^1.0.1",
- "ember-wormhole": "0.3.5",
- "loader.js": "^4.0.1"
- }
+ "name": "app-client",
+ "version": "0.0.1",
+ "description": "Small description for app-client goes here",
+ "private": true,
+ "directories": {
+ "doc": "doc",
+ "test": "tests"
+ },
+ "scripts": {
+ "build": "ember build",
+ "start": "ember server",
+ "test": "ember test",
+ "dl-documents": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/documents/ -d app/mirage/fixtures/documents.js -t documents -p 2 -f es6",
+ "dl-themes": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/themes/ -d app/mirage/fixtures/themes.js -t themes -f es6",
+ "dl-discourses": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/discourses/ -d app/mirage/fixtures/discourses.js -t discourses -f es6"
+ },
+ "repository": "",
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "author": "",
+ "license": "MIT",
+ "devDependencies": {
+ "bower": "^1.7.9",
+ "broccoli-asset-rev": "^2.4.2",
+ "broccoli-funnel": "^1.0.1",
+ "broccoli-merge-trees": "^1.1.1",
+ "broccoli-static-compiler": "^0.2.2",
+ "corpus-common-addon": "file:../../common/corpus-common-addon",
+ "ember-ajax": "^2.0.1",
+ "ember-cli": "2.6.0-beta.2",
+ "ember-cli-app-version": "^1.0.0",
+ "ember-cli-babel": "^5.1.6",
+ "ember-cli-d3": "1.1.6",
+ "ember-cli-dependency-checker": "^1.2.0",
+ "ember-cli-htmlbars": "^1.0.3",
+ "ember-cli-htmlbars-inline-precompile": "^0.3.1",
+ "ember-cli-inject-live-reload": "^1.4.0",
+ "ember-cli-jshint": "^1.0.0",
+ "ember-cli-mirage": "0.1.13",
+ "ember-cli-qunit": "^1.4.0",
+ "ember-cli-release": "1.0.0-beta.1",
+ "ember-cli-sass": "5.3.1",
+ "ember-cli-sri": "^2.1.0",
+ "ember-cli-uglify": "^1.2.0",
+ "ember-data": "^2.6.0-beta.1",
+ "ember-data-fixture-adapter": "1.13.0",
+ "ember-disable-proxy-controllers": "^1.0.1",
+ "ember-export-application-global": "^1.0.5",
+ "ember-font-awesome": "martndemus/ember-font-awesome#pull/91/head",
+ "ember-load-initializers": "^0.5.1",
+ "ember-lodash": "0.0.6",
+ "ember-resolver": "^2.0.3",
+ "ember-welcome-page": "^1.0.1",
+ "ember-wormhole": "0.3.5",
+ "loader.js": "^4.0.1"
+ }
}
--- a/common/corpus-common-addon/addon/utils/constants.js Sat May 07 15:15:01 2016 +0200
+++ b/common/corpus-common-addon/addon/utils/constants.js Sun May 08 14:21:22 2016 +0200
@@ -1,18 +1,46 @@
-export const LEXVO_BASE_URL = "http://lexvo.org/id/iso639-3/";
-export const VIAF_BASE_URL = "http://viaf.org/viaf/";
-export const BNF_BASE_URL = "http://data.bnf.fr/";
-export const BNF_ARK_BASE_URL = "http://ark.bnf.fr/";
-export const BNF_ARK_BASE_ID = "ark:/12148/";
+export const LEXVO_BASE_URL = 'http://lexvo.org/id/iso639-3/';
+
+export const VIAF_BASE_URL = 'http://viaf.org/viaf/';
+
+export const BNF_BASE_URL = 'http://data.bnf.fr/';
+
+export const BNF_ARK_BASE_URL = 'http://ark.bnf.fr/';
+export const BNF_ARK_BASE_ID = 'ark:/12148/';
+
+export const CORPUS_DISCOURSE_TYPES = {
+ 'http://ark.bnf.fr/ark:/12148/cb12083158d' : 'argumentation',
+ 'http://ark.bnf.fr/ark:/12148/cb119783362' : 'Bavardage',
+ 'http://ark.bnf.fr/ark:/12148/cb13319048g' : 'chansons',
+ 'http://ark.bnf.fr/ark:/12148/cb11931724n' : 'congrès et conférences',
+ 'http://ark.bnf.fr/ark:/12148/cb11936159v' : 'contes',
+ 'http://ark.bnf.fr/ark:/12148/cb119317924' : 'conversation',
+ 'http://ark.bnf.fr/ark:/12148/cb12481481z' : 'dialogue',
+ 'http://ark.bnf.fr/ark:/12148/cb11948542x' : 'discours',
+ 'http://ark.bnf.fr/ark:/12148/cb119341539' : 'discussion',
+ 'http://ark.bnf.fr/ark:/12148/cb120502737' : 'enquêtes linguistiques',
+ 'http://ark.bnf.fr/ark:/12148/cb11932135w' : 'entretiens',
+ 'http://ark.bnf.fr/ark:/12148/cb11953414d' : 'fables',
+ 'http://ark.bnf.fr/ark:/12148/cb11955657q' : 'lecture à haute voix',
+ 'http://ark.bnf.fr/ark:/12148/cb11957378b' : 'musique instrumentale',
+ 'http://ark.bnf.fr/ark:/12148/cb11937212q' : 'narration',
+ 'http://ark.bnf.fr/ark:/12148/cb11946100d' : 'paradigme (épistémologie)',
+ 'http://ark.bnf.fr/ark:/12148/cb119829234' : 'questionnaires',
+ 'http://ark.bnf.fr/ark:/12148/cb119834877' : 'récitation',
+ 'http://ark.bnf.fr/ark:/12148/cb11976851v' : 'récits personnels',
+ 'http://ark.bnf.fr/ark:/12148/cb11949715t' : 'réunions'
+};
+
export const DEFAULT_STORE_EXP = 3600000;
+
export const NOID_CHARS = [
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'm', 'n',
- 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z'
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'm', 'n',
+ 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z'
];
export const NOID_CHARS_POS = {
- '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
- 'b': 10, 'c': 11, 'd': 12, 'f': 13, 'g': 14, 'h': 15, 'j': 16, 'k': 17, 'm': 18, 'n': 19,
- 'p': 20, 'q': 21, 'r': 22, 's': 23, 't': 24, 'v': 25, 'w': 26, 'x': 27, 'z': 28
+ '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
+ 'b': 10, 'c': 11, 'd': 12, 'f': 13, 'g': 14, 'h': 15, 'j': 16, 'k': 17, 'm': 18, 'n': 19,
+ 'p': 20, 'q': 21, 'r': 22, 's': 23, 't': 24, 'v': 25, 'w': 26, 'x': 27, 'z': 28
};
--- a/common/corpus-common-addon/lib/commands/dl-fixtures.js Sat May 07 15:15:01 2016 +0200
+++ b/common/corpus-common-addon/lib/commands/dl-fixtures.js Sun May 08 14:21:22 2016 +0200
@@ -47,6 +47,9 @@
{ name: 'page', type: Number, default: 1 , aliases: ['p'], description: 'number of page to download'},
{ name: 'format', type: String, default: 'es6' , aliases: ['f'], description: 'Format for module export, es6 or require'}
],
+ dl_discourses: function(commandOptions) {
+ return this.dl_themes(commandOptions);
+ },
dl_themes: function(commandOptions) {
var done = Q.defer();
var that = this;
@@ -61,7 +64,6 @@
[]
);
var prefix = (that.format==='es6')?'export default ':'module.exports = ';
- console.log(that.dest);
fs.writeFile(that.dest, prefix + JSON.stringify(objectList,null,2) + ';', function(err) {
if(err) {
return done.reject(err);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/app/Http/Controllers/Api/DiscourseController.php Sun May 08 14:21:22 2016 +0200
@@ -0,0 +1,60 @@
+<?php
+
+namespace CorpusParole\Http\Controllers\Api;
+
+// use Illuminate\Http\Request;
+// use CorpusParole\Http\Requests;
+use CorpusParole\Http\Controllers\Controller;
+
+use Illuminate\Http\Request;
+use EasyRdf\Resource;
+use EasyRdf\Literal;
+
+use CorpusParole\Libraries\Sparql\SparqlClient;
+use CorpusParole\Services\LexvoResolverInterface;
+use CorpusParole\Services\BnfResolverInterface;
+
+
+class DiscourseController extends Controller
+{
+ private $sparqlClient = null;
+
+ public function __construct(SparqlClient $sparqlClient) {
+ $this->sparqlClient = $sparqlClient;
+ }
+
+ /**
+ * Display the specified resource.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function index(Request $request)
+ {
+
+ $query = preg_replace('/\s+/', ' ', "select (?o as ?res) (COUNT(?s) as ?count) where {
+ ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO>.
+ ?s <http://purl.org/dc/elements/1.1/type> ?o.
+ filter(uri(?o) in (<".implode('>,<', array_keys(config('corpusparole.corpus_discourse_type'))).">))
+ }
+ GROUP BY ?o
+ ORDER BY DESC(?count)");
+
+ $docs = $this->sparqlClient->query($query);
+
+ $discourses = [];
+
+ foreach ($docs as $row) {
+ $key = $row->res->getUri();
+ $count = $row->count->getValue();
+ $label = config('corpusparole.corpus_discourse_type')[$key];
+ $discourses[$key] = [
+ "label" => $label,
+ "count" => $count
+ ];
+ }
+
+ return response()->json(['discourses' => $discourses ]);
+
+ }
+
+}
--- a/server/src/app/Http/routes.php Sat May 07 15:15:01 2016 +0200
+++ b/server/src/app/Http/routes.php Sun May 08 14:21:22 2016 +0200
@@ -53,6 +53,8 @@
['only' => ['index']]);
Route::resource('themes', 'Api\ThemeController',
['only' => ['index']]);
+ Route::resource('discourses', 'Api\DiscourseController',
+ ['only' => ['index']]);
});
--- a/server/src/config/corpusparole.php Sat May 07 15:15:01 2016 +0200
+++ b/server/src/config/corpusparole.php Sun May 08 14:21:22 2016 +0200
@@ -31,6 +31,29 @@
'easyrdf_http_client_timeout' => env('EASYRDF_HTTP_CLIENT_TIMEOUT', 1000),
+ 'corpus_discourse_type' => [
+ "http://ark.bnf.fr/ark:/12148/cb12083158d" => "argumentation",
+ "http://ark.bnf.fr/ark:/12148/cb119783362" => "bavardage",
+ "http://ark.bnf.fr/ark:/12148/cb13319048g" => "chansons",
+ "http://ark.bnf.fr/ark:/12148/cb11931724n" => "congrès et conférences",
+ "http://ark.bnf.fr/ark:/12148/cb11936159v" => "contes",
+ "http://ark.bnf.fr/ark:/12148/cb119317924" => "conversation",
+ "http://ark.bnf.fr/ark:/12148/cb12481481z" => "dialogue",
+ "http://ark.bnf.fr/ark:/12148/cb11948542x" => "discours",
+ "http://ark.bnf.fr/ark:/12148/cb119341539" => "discussion",
+ "http://ark.bnf.fr/ark:/12148/cb120502737" => "enquêtes linguistiques",
+ "http://ark.bnf.fr/ark:/12148/cb11932135w" => "entretiens",
+ "http://ark.bnf.fr/ark:/12148/cb11953414d" => "fables",
+ "http://ark.bnf.fr/ark:/12148/cb11955657q" => "lecture à haute voix",
+ "http://ark.bnf.fr/ark:/12148/cb11957378b" => "musique instrumentale",
+ "http://ark.bnf.fr/ark:/12148/cb11937212q" => "narration",
+ "http://ark.bnf.fr/ark:/12148/cb11946100d" => "paradigme (épistémologie)",
+ "http://ark.bnf.fr/ark:/12148/cb119829234" => "questionnaires",
+ "http://ark.bnf.fr/ark:/12148/cb119834877" => "récitation",
+ "http://ark.bnf.fr/ark:/12148/cb11976851v" => "récits personnels",
+ "http://ark.bnf.fr/ark:/12148/cb11949715t" => "réunions"
+ ],
+
'olac_discourse_type' => [
'uri' => 'http://www.language-archives.org/OLAC/1.1/discourse-type',
'values' => [
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/tests/Controllers/DiscourseControllerTest.php Sun May 08 14:21:22 2016 +0200
@@ -0,0 +1,65 @@
+<?php
+
+use Mockery as m;
+
+use EasyRdf\Resource;
+use EasyRdf\Literal;
+
+/**
+ *
+ */
+class DiscourseControllerTest extends TestCase {
+
+ private $sparqlClient;
+
+ public function setUp() {
+
+ parent::setup();
+
+ // create a mock of the post repository interface and inject it into the
+ // IoC container
+ $this->sparqlClient = m::mock('CorpusParole\Libraries\Sparql\SparqlClient');
+ $this->app->instance('CorpusParole\Libraries\Sparql\SparqlClient', $this->sparqlClient);
+ }
+
+ public function tearDown() {
+ m::close();
+ parent::tearDown();
+ }
+
+ public function testIndexQuery() {
+
+ $query = preg_replace('/\s+/', ' ', "select (?o as ?res) (COUNT(?s) as ?count) where {
+ ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO>.
+ ?s <http://purl.org/dc/elements/1.1/type> ?o.
+ filter(uri(?o) in (<".implode('>,<', array_keys(config('corpusparole.corpus_discourse_type'))).">))
+ }
+ GROUP BY ?o
+ ORDER BY DESC(?count)");
+
+ $this->sparqlClient
+ ->shouldReceive('query')
+ ->with($query)
+ ->once()
+ ->andReturn(new \ArrayIterator([]));
+ $this->get('/api/v1/discourses/');
+ }
+
+ public function testIndex() {
+
+ $this->sparqlClient
+ ->shouldReceive('query')
+ ->once()
+ ->andReturn(new \ArrayIterator([
+ (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb12083158d'), 'count' => Literal::create(44)],
+ (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb119783362'), 'count' => Literal::create(33)],
+ (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb13319048g'), 'count' => Literal::create(22)],
+ ]));
+ $this->get('/api/v1/discourses/')->assertTrue($this->response->isOk(), $this->response->content());
+ $this->seeJsonEquals(["discourses" => [
+ "http://ark.bnf.fr/ark:/12148/cb12083158d" => ["label" => "argumentation", "count" => 44],
+ "http://ark.bnf.fr/ark:/12148/cb119783362" => ["label" => "bavardage", "count" => 33],
+ "http://ark.bnf.fr/ark:/12148/cb13319048g" => ["label" => "chansons", "count" => 22],
+ ]]);
+ }
+}
--- a/server/src/tests/Controllers/ThemeControllerTest.php Sat May 07 15:15:01 2016 +0200
+++ b/server/src/tests/Controllers/ThemeControllerTest.php Sun May 08 14:21:22 2016 +0200
@@ -29,7 +29,7 @@
public function testIndexQuery() {
- $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
+ $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> .
?s <http://purl.org/dc/elements/1.1/subject> ?o .
FILTER (isIRI(?o) && regex(str(?o), '^".config('corpusparole.bnf_ark_base_url')."')) .
@@ -47,7 +47,7 @@
public function testIndexQueryBnf() {
- $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
+ $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> .
?s <http://purl.org/dc/elements/1.1/subject> ?o .
FILTER (isIRI(?o) && regex(str(?o), '^".config('corpusparole.bnf_ark_base_url')."')) .
@@ -66,7 +66,7 @@
public function testIndexQueryAll() {
- $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
+ $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> .
?s <http://purl.org/dc/elements/1.1/subject> ?o .
}
@@ -82,9 +82,9 @@
}
- public function testIndexQueryNone() {
+ public function testIndexQueryNone() {
- $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
+ $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where {
?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> .
?s <http://purl.org/dc/elements/1.1/subject> ?o .
}
@@ -148,9 +148,9 @@
]));
$this->get('/api/v1/themes/')->assertTrue($this->response->isOk(), $this->response->content());
$this->seeJsonEquals(["themes" => [
- "http://lexvo.org/id/iso639-3/gsw" => ["url" => "http://lexvo.org/id/iso639-3/gsw", "label" => null, "count" => 44],
- "http://ark.bnf.fr/ark:/12148/cb119339867" => ["url" => "http://ark.bnf.fr/ark:/12148/cb119339867", "label" => null, "count" => 33],
- "Français" => ["url" => null, "label" => "Français", "count" => 22],
+ "http://lexvo.org/id/iso639-3/gsw" => ["label" => "alémanique", "count" => 44],
+ "http://ark.bnf.fr/ark:/12148/cb119339867" => ["label" => "famille", "count" => 33],
+ "Français" => ["label" => "Français", "count" => 22],
]]);
}
}