Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Wiki Rasa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tm-chatbot
Wiki Rasa
Commits
ba8af03b
Commit
ba8af03b
authored
6 years ago
by
Lukas Gehrke
Browse files
Options
Downloads
Patches
Plain Diff
Fixt getter für ersten paragraph.
parent
6e1d902d
No related branches found
No related tags found
1 merge request
!21
Resolve "R-Skript für Birthdate erstellen"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
r/GetBirthdate.R
+10
-7
10 additions, 7 deletions
r/GetBirthdate.R
with
10 additions
and
7 deletions
r/GetBirthdate.R
+
10
−
7
View file @
ba8af03b
...
...
@@ -13,7 +13,7 @@ library(data.table)
### Try to extract birthdate from infobox
### If there is no infobox, try to extract from introduction text
getBirthdate
<-
function
(
article
)
{
# check
if vcard exists
# check
if
(
!
grepl
(
"vcard"
,
article
))
{
# check first paragraph
introduction
<-
getIntroduction
(
article
)
...
...
@@ -22,8 +22,6 @@ getBirthdate <- function(article) {
birthdate
<-
str_extract_all
(
introduction
,
"\\([^()]+\\)"
)[[
1
]]
# remove parentheses
birthdate
<-
substring
(
birthdate
,
2
,
nchar
(
birthdate
)
-1
)
return
(
birthdate
)
}
else
{
# retrun Null if there is no birthdate
return
(
0
)
...
...
@@ -87,11 +85,16 @@ getIntroduction <- function(article) {
xml_find_all
(
page
,
".//br"
)
%>%
xml_remove
# Get
first
paragraph
introduction
<-
page
%>%
# Get
all
paragraph
s
paragraphs
<-
page
%>%
html_nodes
(
"p"
)
%>%
html_text
()
%>%
.
[[
1
]]
html_text
()
# there will be some leading paragraphs containing only "\n"
# remove those leading paragraphs
remove
<-
c
(
"\n"
)
cleaned
<-
setdiff
(
paragraphs
,
remove
)
introduction
<-
cleaned
[
1
]
# Return first paragraph
return
(
introduction
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment