Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openalex
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
crawlers
openalex
Commits
5aac73a7
Verified
Commit
5aac73a7
authored
Jun 28, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
document parsing works now
parent
72a4c71e
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
278 additions
and
18 deletions
+278
-18
README.md
README.md
+6
-0
Main.hs
app/Main.hs
+13
-1
pkgs.nix
nix/pkgs.nix
+2
-1
OpenAlex.hs
src/OpenAlex.hs
+9
-2
Client.hs
src/OpenAlex/Client.hs
+12
-2
Types.hs
src/OpenAlex/Types.hs
+236
-12
No files found.
README.md
View file @
5aac73a7
# Open Alex Database API Crawler for GarganText
## Compilation
For non-GHC stuff, use Nix.
For GHC, use ghcup and use GHC 8.10.7.
## Running
```
shell
...
...
app/Main.hs
View file @
5aac73a7
...
...
@@ -16,6 +16,10 @@ main = do
"Fetch OpenAlex concepts (https://docs.openalex.org/api-entities/concepts/concept-object)"
(
const
fetchConcepts
)
(
pure
()
)
addCommand
"works"
"Fetch OpenAlex works (https://docs.openalex.org/api-entities/works/work-object)"
(
const
fetchWorks
)
(
pure
()
)
runCmd
()
...
...
@@ -27,5 +31,13 @@ fetchConcepts _ = do
case
ec
of
Left
err
->
putText
$
"error: "
<>
show
err
Right
c
->
do
putText
"c"
putText
$
show
c
fetchWorks
::
()
->
IO
()
fetchWorks
_
=
do
-- ec <- OA.fetchConcepts (Just 1) (Just 1) Nothing
ew
<-
OA
.
fetchWorks
(
Just
1
)
(
Just
1
)
(
Just
"*"
)
case
ew
of
Left
err
->
putText
$
"error: "
<>
show
err
Right
w
->
do
putText
$
show
w
nix/pkgs.nix
View file @
5aac73a7
...
...
@@ -14,6 +14,7 @@ rec {
ps
.
tqdm
]);
nonhsBuildInputs
=
with
pkgs
;
[
gmp
jupyter
pythonEnv
zlib
...
...
@@ -21,6 +22,6 @@ rec {
#libPaths = pkgs.lib.makeLibraryPath nonhsBuildInputs;
shell
=
pkgs
.
mkShell
{
name
=
"openalex"
;
buildInputs
=
hsBuildInputs
++
nonhsBuildInputs
;
buildInputs
=
nonhsBuildInputs
;
};
}
src/OpenAlex.hs
View file @
5aac73a7
...
...
@@ -14,7 +14,9 @@ module OpenAlex
(
module
OpenAlex
.
Client
,
module
OpenAlex
.
Types
-- , fetchConcepts'
,
fetchConcepts
)
,
fetchConcepts
,
fetchWorks
)
where
-- import Data.Aeson
...
...
@@ -27,7 +29,7 @@ import Network.HTTP.Client.TLS (tlsManagerSettings)
import
Protolude
import
OpenAlex.Client
import
OpenAlex.ServantClientLogging
import
OpenAlex.Types
import
OpenAlex.Types
(
ListOf
(
..
),
Page
,
PerPage
,
Cursor
,
Concept
,
Work
)
import
Servant.Client
(
BaseUrl
(
..
),
ClientEnv
(
..
),
ClientError
,
Scheme
(
Https
),
defaultMakeClientRequest
,
mkClientEnv
,
runClientM
)
defaultClientEnv
::
IO
ClientEnv
...
...
@@ -46,6 +48,11 @@ fetchConcepts mPage mPerPage mCursor = do
env
<-
defaultClientEnv
runClientM
(
concepts
mPage
mPerPage
mCursor
)
env
fetchWorks
::
Maybe
Page
->
Maybe
PerPage
->
Maybe
Cursor
->
IO
(
Either
ClientError
(
ListOf
Work
))
fetchWorks
mPage
mPerPage
mCursor
=
do
env
<-
defaultClientEnv
runClientM
(
works
mPage
mPerPage
mCursor
)
env
-- fetchConcepts' :: IO (Either Text (ListOf Concept))
-- fetchConcepts' = do
-- manager <- newManager tlsManagerSettings
...
...
src/OpenAlex/Client.hs
View file @
5aac73a7
...
...
@@ -16,7 +16,7 @@ import Protolude
import
Servant.API
import
Servant.Client
import
OpenAlex.Types
import
OpenAlex.Types
(
Page
,
PerPage
,
Cursor
,
ListOf
(
..
),
Concept
,
Work
)
type
API_URL
=
Text
apiUrl
::
API_URL
...
...
@@ -37,9 +37,19 @@ type OpenAlexAPI =
-- TODO: filter, search, sort
:>
Get
'[
J
SON
]
(
ListOf
Concept
)
-- https://docs.openalex.org/api-entities/works
:<|>
"works"
:>
QueryParam
"page"
Page
:>
QueryParam
"per-page"
PerPage
:>
QueryParam
"cursor"
Cursor
-- TODO: filter, search, sort
:>
Get
'[
J
SON
]
(
ListOf
Work
)
openAlexApi
::
Proxy
OpenAlexAPI
openAlexApi
=
Proxy
concepts
::
Maybe
Page
->
Maybe
PerPage
->
Maybe
Cursor
->
ClientM
(
ListOf
Concept
)
concepts
{- :<|> fetch -}
=
client
openAlexApi
works
::
Maybe
Page
->
Maybe
PerPage
->
Maybe
Cursor
->
ClientM
(
ListOf
Work
)
concepts
:<|>
works
=
client
openAlexApi
src/OpenAlex/Types.hs
View file @
5aac73a7
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment