Python Forum
how can rectify error from the below code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how can rectify error from the below code
#1
Dear ALL,

import numpy

def gettingc1©:
    c1= []
    mystr = c.strip(' ').split()
    for i in mystr[:1]:
        c1.append(i)    
    return c1
    


def frequency1(c1, d):
    from collections import Counter

    termslist = Counter(i for i in d if i==c1).items()
    
    for k, v in termslist:
       
        return v
            
def maximum_frequence1(d):
    from collections import Counter 
    list0 = []
    terms= Counter(word for word in d).most_common()
    if terms[0][1] > terms[1][1]:
         list0.append([0][0])
    for k, v in terms:
        print(k)
        print(v)
        return v



def single_term_p1(c, d): 
    c1= gettingc1©
    return (frequency1 (c1, d)/ maximum_frequence1(d))

d=['biomedical informatics community', 'utility', 'domain ontologies', 'many barriers', 'effective use', 'important requirement', 'domain ontologies', 'high degree', 'coverage', 'domain concepts', 'concept relationships', 'development', u'ontology', 'prone process', 'limited resources result', u'concept', u'relationship', 'difficulty', 'ontology', 'knowledge changes', u'methodology', u'field', 'natural language processing', 'information extraction', 'information retrieval', 'machine', u'technique', 'enrichment', 'ontology', 'text documents', 'article', u'methodology', 'developed systems', 'existing methods', 'development', 'biomedical ontologies']

c= "domain ontologies"

print(single_term_p1(c, d))

OUTPUT

 File "C:/Users/user/example.py", line 49, in <module>
    print(single_term_p1(c, d))

  File "C:/Users/user/example.py", line 43, in single_term_p1
    return (frequency1 (c1, d)/ maximum_frequence1(d))

TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
Reply


Messages In This Thread
how can rectify error from the below code - by desul - Feb-28-2017, 08:45 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020