Commit ff0e3844 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update base to add to_initial from recordpubli

parent 652ca92c
......@@ -140,3 +140,35 @@ def is_thesis(recjson):
return True
return False
def to_initial(name):
"""Help function to extract initial from a first name:
+------------------+----------+
| name | initial |
+------------------+----------+
| Albert | A. |
| Antonio Augusto | A. A. |
| Kristof Antoon M | K. A. M. |
| Jean-Pierre | J.-P. |
| Marie-Hélène | M.-H. |
+------------------+----------+
Args:
name (str):
Returns:
str
"""
if len(name) == 0:
return ""
li = []
for el in re.finditer(r"(\w+|-)", name, re.UNICODE):
val = el.group(1)[0:1]
val = (val if val == "-" else "%s." % val)
li.append(val)
return ("".join(li) if "-" in li else " ".join(li))
......@@ -4,17 +4,17 @@
import numpy as np
import re
from store_tools import (ARXIV,
ARXIV_PDF,
REG_ARXIV_NUMBER,
REG_YEAR)
from .base import to_initial
from .exception import RecordException
from filters import CLEAN_COLLABORATION
from numpy import NaN
from pandas import concat, DataFrame
from plugin_dbui import as_list, CLEAN_SPACES
from .record import Record
from store_tools import (ARXIV,
ARXIV_PDF,
REG_ARXIV_NUMBER,
REG_YEAR)
AUTHOR_FORMATS = [
"First, Last",
......@@ -29,38 +29,6 @@ MSG_INVALID_FMT = "Invalid format for author"
PAPER_REFERENCE_KEYS = {"pagination", "title", "volume", "year"}
def to_initial(name):
"""Help function to extract initial from a first name:
+------------------+----------+
| name | initial |
+------------------+----------+
| Albert | A. |
| Antonio Augusto | A. A. |
| Kristof Antoon M | K. A. M. |
| Jean-Pierre | J.-P. |
| Marie-Hélène | M.-H. |
+------------------+----------+
Args:
name (str):
Returns:
str
"""
if len(name) == 0:
return ""
li = []
for el in re.finditer(r"(\w+|-)", name, re.UNICODE):
val = el.group(1)[0:1]
val = (val if val == "-" else "%s." % val)
li.append(val)
return ("".join(li) if "-" in li else " ".join(li))
def to_str(x):
return ("|".join(x) if isinstance(x, list) else x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment