コード例 #1
0
ファイル: crossref.py プロジェクト: jilljenn/dissemin
def convert_to_name_pair(dct):
    """ Converts a dictionary {'family':'Last','given':'First'} to ('First','Last') """
    result = None
    if 'family' in dct and 'given' in dct:
        result = (dct['given'],dct['family'])
    elif 'family' in dct: # The 'Arvind' case
        result = ('',dct['family'])
    elif 'literal' in dct:
        result = parse_comma_name(dct['literal'])
    if result:
        result = (normalize_name_words(result[0]), normalize_name_words(result[1]))
    return result
コード例 #2
0
def convert_to_name_pair(dct):
    """ Converts a dictionary {'family':'Last','given':'First'} to ('First','Last') """
    result = None
    if 'family' in dct and 'given' in dct:
        result = (dct['given'],dct['family'])
    elif 'family' in dct: # The 'Arvind' case
        result = ('',dct['family'])
    elif 'literal' in dct:
        result = parse_comma_name(dct['literal'])
    if result:
        result = (normalize_name_words(result[0]), normalize_name_words(result[1]))
    return result
コード例 #3
0
ファイル: orcid.py プロジェクト: Lysxia/dissemin
 def name(self):
     """
     Returns a parsed version of the "credit name" in the ORCID profile.
     If there is no such name, returns the given and family names on the profile
     (they should exist)
     """
     name_item = jpath('orcid-profile/orcid-bio/personal-details', self.json)
     name = jpath('credit-name/value', name_item)
     if name is not None:
         return parse_comma_name(name)
     return (normalize_name_words(jpath('given-names/value', name_item, '')),
             normalize_name_words(jpath('family-name/value', name_item, '')))
コード例 #4
0
ファイル: orcid.py プロジェクト: tarsbase/dissemin
 def name(self):
     """
     Returns a parsed version of the "credit name" in the ORCID profile.
     If there is no such name, returns the given and family names on the profile
     (they should exist)
     """
     name_item = jpath('person/name', self.json)
     name = jpath('credit-name/value', name_item)
     if name:
         return parse_comma_name(name)
     return (normalize_name_words(jpath('given-names/value', name_item,
                                        '')),
             normalize_name_words(jpath('family-name/value', name_item,
                                        '')))
コード例 #5
0
def import_from_tsv(filename):
    f = open(filename, 'r', 'utf-8')

    for line in f:
        fields = line.strip().split('\t')
        print fields

        dept = fields[dept_f]
        (department, found) = Department.objects.get_or_create(name__iexact=dept,
                defaults={'name':dept.strip()})

        email = fields[email_f]
        if email == '':
            email = None

        first = fields[first_name_f]
        last = normalize_name_words(fields[last_name_f])
        homepage = fields[url_f]
        role = fields[role_f]
        if homepage == '':
            homepage = None

        try:
            researcher = Researcher.create_from_scratch(first, last, department, email, role, homepage)
        except ValueError:
            print "ValueError"
            continue
       
        group = fields[group_f]
        if group:
            g, created = ResearchGroup.objects.get_or_create(name=group)
            researcher.groups.add(g)
コード例 #6
0
ファイル: orcid.py プロジェクト: Lysxia/dissemin
 def other_names(self):
     """
     Returns the list of other names listed on the ORCiD profile.
     This includes the (given,family) name if a credit name was defined.
     """
     name_item = jpath('orcid-profile/orcid-bio/personal-details', self.json)
     names = []
     credit_name = jpath('credit-name/value', name_item)
     if credit_name is not None:
         names.append((normalize_name_words(jpath('given-names/value', name_item)),
             normalize_name_words(jpath('family-name/value', name_item))))
     other_names = jpath('other-names/other-name', name_item, default=[])
     for name in other_names:
         val = name.get('value')
         if val is not None:
             names.append(parse_comma_name(val))
     return names
コード例 #7
0
ファイル: ajax.py プロジェクト: jilljenn/dissemin
def newUnaffiliatedResearcher(request):
    form = AddUnaffiliatedResearcherForm(request.POST)
    researcher = None
    if form.is_valid():
        first = normalize_name_words(form.cleaned_data['first'])
        last = normalize_name_words(form.cleaned_data['last'])
        # Check that the researcher is not already known under a different name.
        if not form.cleaned_data.get('force'):
            name, created = Name.get_or_create(first, last)
            candidates = researcherCandidatesByName(name)
            if candidates:
                return {'disambiguation': candidates}

        researcher = Researcher.create_by_name(first, last)
        researcher.fetch_everything_if_outdated()
        return {'url': researcher.url}
    else:
        return form.errors, 403
コード例 #8
0
ファイル: ajax.py プロジェクト: jilljenn/dissemin
def newUnaffiliatedResearcher(request):
    form = AddUnaffiliatedResearcherForm(request.POST)
    researcher = None
    if form.is_valid():
        first = normalize_name_words(form.cleaned_data['first'])
        last = normalize_name_words(form.cleaned_data['last'])
        # Check that the researcher is not already known under a different name.
        if not form.cleaned_data.get('force'):
            name, created = Name.get_or_create(first, last)
            candidates = researcherCandidatesByName(name)
            if candidates:
                return {'disambiguation':candidates}

        researcher = Researcher.create_by_name(first, last)
        researcher.fetch_everything_if_outdated()
        return {'url':researcher.url}
    else:
        return form.errors, 403
コード例 #9
0
ファイル: orcid.py プロジェクト: tarsbase/dissemin
 def other_names(self):
     """
     Returns the list of other names listed on the ORCiD profile.
     This includes the (given,family) name if a credit name was defined.
     """
     person = jpath('person', self.json)
     names = []
     credit_name = jpath('name/credit-name/value', person)
     if credit_name is not None:
         names.append((normalize_name_words(
             jpath('name/given-names/value', person, '')),
                       normalize_name_words(
                           jpath('name/family-name/value', person, ''))))
     other_names = jpath('other-names/other-name', person, default=[])
     for name in other_names:
         val = name.get('content')
         if val is not None:
             names.append(parse_comma_name(val))
     return names
コード例 #10
0
ファイル: test_names.py プロジェクト: Phyks/dissemin
 def test_involutive(self):
     lst = [
             'Jean',
             'Jean-Pierre',
             'John Mark',
             'JEAN-PIERRE',
             'JOHN MARK',
             'JOSÉ',
             'JOSÉ-ALAIN',
             'José',
             'ÉMILIE',
             'Émilie',
             'John  Mark',
             'Jean - Pierre',
             'J.P. Morgan',
             'JP. Morgan',
             'Jp. Morgan',
           ]
     for sample in lst:
         normalized = normalize_name_words(sample)
         self.assertEqual(normalized, normalize_name_words(normalized))
コード例 #11
0
 def other_names(self):
     """
     Returns the list of other names listed on the ORCiD profile.
     This includes the (given,family) name if a credit name was defined.
     """
     name_item = jpath('orcid-profile/orcid-bio/personal-details',
                       self.json)
     names = []
     credit_name = jpath('credit-name/value', name_item)
     if credit_name is not None:
         names.append(
             (normalize_name_words(jpath('given-names/value', name_item,
                                         '')),
              normalize_name_words(jpath('family-name/value', name_item,
                                         ''))))
     other_names = jpath('other-names/other-name', name_item, default=[])
     for name in other_names:
         val = name.get('value')
         if val is not None:
             names.append(parse_comma_name(val))
     return names
コード例 #12
0
 def test_involutive(self):
     lst = [
         'Jean',
         'Jean-Pierre',
         'John Mark',
         'JEAN-PIERRE',
         'JOHN MARK',
         'JOSÉ',
         'JOSÉ-ALAIN',
         'José',
         'ÉMILIE',
         'Émilie',
         'John  Mark',
         'Jean - Pierre',
         'J.P. Morgan',
         'JP. Morgan',
         'Jp. Morgan',
     ]
     for sample in lst:
         normalized = normalize_name_words(sample)
         self.assertEqual(normalized, normalize_name_words(normalized))
コード例 #13
0
 def test_simple(self):
     self.assertEqual(normalize_name_words('Jean'), 'Jean')
     self.assertEqual(normalize_name_words('Jean-Pierre'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('Jean-pierre'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('John Mark'), 'John Mark')
     self.assertEqual(normalize_name_words('JEAN-PIERRE'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('JOHN MARK'), 'John Mark')
コード例 #14
0
ファイル: test_names.py プロジェクト: Phyks/dissemin
 def test_simple(self):
     self.assertEqual(normalize_name_words('Jean'), 'Jean')
     self.assertEqual(normalize_name_words('Jean-Pierre'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('Jean-pierre'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('John Mark'), 'John Mark')
     self.assertEqual(normalize_name_words('JEAN-PIERRE'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('JOHN MARK'), 'John Mark')
コード例 #15
0
ファイル: test_names.py プロジェクト: Phyks/dissemin
 def test_flattened(self):
     self.assertEqual(normalize_name_words('JP.'), 'J.-P.')
     self.assertEqual(normalize_name_words('Jp.'), 'J.-P.')
コード例 #16
0
 def test_comma(self):
     self.assertEqual(normalize_name_words('John, Mark'), 'John Mark')
     self.assertEqual(normalize_name_words('John,, Mark'), 'John Mark')
     self.assertEqual(normalize_name_words('John Mark,'), 'John Mark')
     self.assertEqual(normalize_name_words('John Mark,,'), 'John Mark')
     self.assertEqual(normalize_name_words('John, Mark,,'), 'John Mark')
コード例 #17
0
 def test_lower(self):
     self.assertEqual(normalize_name_words('catalin'), 'Catalin')
     self.assertEqual(normalize_name_words('Colin de Verdière'),
                      'Colin de Verdière')
コード例 #18
0
 def test_flattened(self):
     self.assertEqual(normalize_name_words('JP.'), 'J.-P.')
     self.assertEqual(normalize_name_words('Jp.'), 'J.-P.')
コード例 #19
0
 def test_spacing(self):
     self.assertEqual(normalize_name_words('John  Mark'), 'John Mark')
     self.assertEqual(normalize_name_words(' John  Mark'), 'John Mark')
     self.assertEqual(normalize_name_words(' John Mark \n'), 'John Mark')
     self.assertEqual(normalize_name_words('Jean - Pierre'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('J.P.'), 'J. P.')
コード例 #20
0
 def test_unicode(self):
     self.assertEqual(normalize_name_words('JOSÉ'), 'José')
     self.assertEqual(normalize_name_words('JOSÉ-ALAIN'), 'José-Alain')
     self.assertEqual(normalize_name_words('José'), 'José')
     self.assertEqual(normalize_name_words('ÉMILIE'), 'Émilie')
     self.assertEqual(normalize_name_words('Émilie'), 'Émilie')
コード例 #21
0
ファイル: test_names.py プロジェクト: Phyks/dissemin
 def test_lower(self):
     self.assertEqual(normalize_name_words('catalin'), 'Catalin')
     self.assertEqual(normalize_name_words(
         'Colin de Verdière'), 'Colin de Verdière')
コード例 #22
0
ファイル: test_names.py プロジェクト: Phyks/dissemin
 def test_unicode(self):
     self.assertEqual(normalize_name_words('JOSÉ'), 'José')
     self.assertEqual(normalize_name_words('JOSÉ-ALAIN'), 'José-Alain')
     self.assertEqual(normalize_name_words('José'), 'José')
     self.assertEqual(normalize_name_words('ÉMILIE'), 'Émilie')
     self.assertEqual(normalize_name_words('Émilie'), 'Émilie')
コード例 #23
0
ファイル: test_names.py プロジェクト: Phyks/dissemin
 def test_spacing(self):
     self.assertEqual(normalize_name_words('John  Mark'), 'John Mark')
     self.assertEqual(normalize_name_words(' John  Mark'), 'John Mark')
     self.assertEqual(normalize_name_words(' John Mark \n'), 'John Mark')
     self.assertEqual(normalize_name_words('Jean - Pierre'), 'Jean-Pierre')
     self.assertEqual(normalize_name_words('J.P.'), 'J. P.')
コード例 #24
0
ファイル: test_names.py プロジェクト: Phyks/dissemin
 def test_comma(self):
     self.assertEqual(normalize_name_words('John, Mark'), 'John Mark')
     self.assertEqual(normalize_name_words('John,, Mark'), 'John Mark')
     self.assertEqual(normalize_name_words('John Mark,'), 'John Mark')
     self.assertEqual(normalize_name_words('John Mark,,'), 'John Mark')
     self.assertEqual(normalize_name_words('John, Mark,,'), 'John Mark')