has anyone used collusion API for creating graphs?
I want to create graphs with using collusion API from annotated text has anyone used the api? do you have any better suggestion too? -- https://mail.python.org/mailman/listinfo/python-list
Regular Expression
I have a text as follows: "#D{#C[Health] #P[Information] - means any information, including #ST[genetic information], whether #C[oral | (recorded in (any form | medium))], that (1)#C[Is created or received by] a #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse]; (2)#C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] | #C[the provision of health care to an individual] | #C[the past, present, or future payment for the provision of health care to an individual].}" I want to get all elements that start with #C and are [] and put it in an array. For example #C[Health], I try with regex but it doesn't work: import re import tkinter.filedialog import readfile j = 0 text = [ ] content = readfile.pattread() while j < len(content): constraint = re.compile(r'(#C\[\w*\]')) result = constraint.search(content[j],re.MULTILINE) text.append(result) print(text) j = j+1 -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > On 2015-04-12 23:49, Pippo wrote: > > I have a text as follows: > > > > "#D{#C[Health] #P[Information] - > > means any information, including #ST[genetic information], > > whether #C[oral | (recorded in (any form | medium))], that > > (1)#C[Is created or received by] a > > #A[health care provider | health plan | public health authority | employer > > | life insurer | school | university | or health care clearinghouse]; > > (2)#C[Relates to] #C[the past, present, or future physical | mental health > > | condition of an individual] | > > #C[the provision of health care to an individual] | > > #C[the past, present, or future payment for the provision of health care to > > an individual].}" > > > > I want to get all elements that start with #C and are [] and put it in an > > array. For example #C[Health], I try with regex but it doesn't work: > > > "... it doesn't work"? In what way doesn't it work? > > > import re > > import tkinter.filedialog > > import readfile > > > > > > > > j = 0 > > > > text = [ ] > > > > > > content = readfile.pattread() > > > > while j < len(content): > > > There's a syntax error here: > > > constraint = re.compile(r'(#C\[\w*\]')) > > result = constraint.search(content[j],re.MULTILINE) > > text.append(result) > > print(text) > > j = j+1 > > result is empty! Although it should have a content. What is the syntax error? -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > > On 2015-04-12 23:49, Pippo wrote: > > > I have a text as follows: > > > > > > "#D{#C[Health] #P[Information] - > > > means any information, including #ST[genetic information], > > > whether #C[oral | (recorded in (any form | medium))], that > > > (1)#C[Is created or received by] a > > > #A[health care provider | health plan | public health authority | > > > employer | life insurer | school | university | or health care > > > clearinghouse]; > > > (2)#C[Relates to] #C[the past, present, or future physical | mental > > > health | condition of an individual] | > > > #C[the provision of health care to an individual] | > > > #C[the past, present, or future payment for the provision of health care > > > to an individual].}" > > > > > > I want to get all elements that start with #C and are [] and put it in > > > an array. For example #C[Health], I try with regex but it doesn't work: > > > > > "... it doesn't work"? In what way doesn't it work? > > > > > import re > > > import tkinter.filedialog > > > import readfile > > > > > > > > > > > > j = 0 > > > > > > text = [ ] > > > > > > > > > content = readfile.pattread() > > > > > > while j < len(content): > > > > > There's a syntax error here: > > > > > constraint = re.compile(r'(#C\[\w*\]')) > > > result = constraint.search(content[j],re.MULTILINE) > > > text.append(result) > > > print(text) > > > j = j+1 > > > > > result is empty! Although it should have a content. > > What is the syntax error? I fixed the syntax error but the result shows: >>> [None] [None, None] [None, None, None] [None, None, None, None] [None, None, None, None, None] [None, None, None, None, None, None] [None, None, None, None, None, None, None] [None, None, None, None, None, None, None, None] >>> No error but if I don't call the content I posted up and call this as a content: #content = "#C[Health] #P[Information]" result gives me #C[Health] -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
On Sunday, 12 April 2015 19:47:09 UTC-4, Pippo wrote: > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > > On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > > > On 2015-04-12 23:49, Pippo wrote: > > > > I have a text as follows: > > > > > > > > "#D{#C[Health] #P[Information] - > > > > means any information, including #ST[genetic information], > > > > whether #C[oral | (recorded in (any form | medium))], that > > > > (1)#C[Is created or received by] a > > > > #A[health care provider | health plan | public health authority | > > > > employer | life insurer | school | university | or health care > > > > clearinghouse]; > > > > (2)#C[Relates to] #C[the past, present, or future physical | mental > > > > health | condition of an individual] | > > > > #C[the provision of health care to an individual] | > > > > #C[the past, present, or future payment for the provision of health > > > > care to an individual].}" > > > > > > > > I want to get all elements that start with #C and are [] and put it in > > > > an array. For example #C[Health], I try with regex but it doesn't work: > > > > > > > "... it doesn't work"? In what way doesn't it work? > > > > > > > import re > > > > import tkinter.filedialog > > > > import readfile > > > > > > > > > > > > > > > > j = 0 > > > > > > > > text = [ ] > > > > > > > > > > > > content = readfile.pattread() > > > > > > > > while j < len(content): > > > > > > > There's a syntax error here: > > > > > > > constraint = re.compile(r'(#C\[\w*\]')) > > > > result = constraint.search(content[j],re.MULTILINE) > > > > text.append(result) > > > > print(text) > > > > j = j+1 > > > > > > > > result is empty! Although it should have a content. > > > > What is the syntax error? > > I fixed the syntax error but the result shows: > > >>> > [None] > [None, None] > [None, None, None] > [None, None, None, None] > [None, None, None, None, None] > [None, None, None, None, None, None] > [None, None, None, None, None, None, None] > [None, None, None, None, None, None, None, None] > >>> > > > No error but if I don't call the content I posted up and call this as a > content: #content = "#C[Health] #P[Information]" > > result gives me #C[Health] what is the best way to separate the elements in the [] from the text? -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
On Sunday, 12 April 2015 20:06:08 UTC-4, MRAB wrote: > On 2015-04-13 00:47, Pippo wrote: > > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > >> On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > >> > On 2015-04-12 23:49, Pippo wrote: > >> > > I have a text as follows: > >> > > > >> > > "#D{#C[Health] #P[Information] - > >> > > means any information, including #ST[genetic information], > >> > > whether #C[oral | (recorded in (any form | medium))], that > >> > > (1)#C[Is created or received by] a > >> > > #A[health care provider | health plan | public health authority | > >> > > employer | life insurer | school | university | or health care > >> > > clearinghouse]; > >> > > (2)#C[Relates to] #C[the past, present, or future physical | mental > >> > > health | condition of an individual] | > >> > > #C[the provision of health care to an individual] | > >> > > #C[the past, present, or future payment for the provision of health > >> > > care to an individual].}" > >> > > > >> > > I want to get all elements that start with #C and are [] and put it > >> > > in an array. For example #C[Health], I try with regex but it doesn't > >> > > work: > >> > > > >> > "... it doesn't work"? In what way doesn't it work? > >> > > >> > > import re > >> > > import tkinter.filedialog > >> > > import readfile > >> > > > >> > > > >> > > > >> > > j = 0 > >> > > > >> > > text = [ ] > >> > > > >> > > > >> > > content = readfile.pattread() > >> > > > >> > > while j < len(content): > >> > > > >> > There's a syntax error here: > >> > > >> > > constraint = re.compile(r'(#C\[\w*\]')) > >> > > result = constraint.search(content[j],re.MULTILINE) > >> > > text.append(result) > >> > > print(text) > >> > > j = j+1 > >> > > > >> > >> result is empty! Although it should have a content. > >> > >> What is the syntax error? > > > > I fixed the syntax error but the result shows: > > > >>>> > > [None] > > [None, None] > > [None, None, None] > > [None, None, None, None] > > [None, None, None, None, None] > > [None, None, None, None, None, None] > > [None, None, None, None, None, None, None] > > [None, None, None, None, None, None, None, None] > >>>> > > > > > > No error but if I don't call the content I posted up and call this as a > > content: #content = "#C[Health] #P[Information]" > > > > result gives me #C[Health] > > > What does 'readfile.pattread()' return? Does it return a list of > strings? I'm guessing it does. yes it reads a file of string similar to the one I posted above > > Try printing each string you're trying to match using 'repr', i.e.: > > print(repr(content[j])) > > Do any look like they should match? print(repr(content[j])) gives me the following: [None] '#D{#C[Health] #P[Information] - \n' [None, None] 'means any information, including #ST[genetic information], \n' [None, None, None] 'whether #C[oral | (recorded in (any form | medium))], that \n' [None, None, None, None] '(1)#C[Is created or received by] a \n' [None, None, None, None, None] '#A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse]; \n' [None, None, None, None, None, None] '(2)#C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] | \n' [None, None, None, None, None, None, None] '#C[the provision of health care to an individual] | \n' [None, None, None, None, None, None, None, None] '#C[the past, present, or future payment for the provision of health care to an individual].}\n' shouldn't it match "#C[Health]" in the first row? If not, what is the best way to fetch these items in an array? > > If one doesn't, but you think it should, post it here so that someone > can tell you why it doesn't! :-) -- https://mail.python.org/mailman/listinfo/python-list
calling an api in python code
I am new in this matter.. I need some help to understand how do I call an api in python code? -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> >> > > constraint = re.compile(r'(#C\[\w*\]')) > >> >> > > result = constraint.search(content[j],re.MULTILINE) > >> >> > > text.append(result) > >> >> > > print(text) > [...] > >> >> result is empty! Although it should have a content. > [...] > >> > I fixed the syntax error but the result shows: > >> > [None] > >> > [None, None] > [...] > > Note that "None" is not "empty", though in this case more or less means what > you think. > > You're getting None because the regexp fails to match. > > >> Try printing each string you're trying to match using 'repr', i.e.: > >> print(repr(content[j])) > >> > >> Do any look like they should match? > > print(repr(content[j])) gives me the following: > > > >[None] > >'#D{#C[Health] #P[Information] - \n' > [...] > >shouldn't it match "#C[Health]" in the first row? > > It looks like it should, unless you have mangled your regular expression. You > mentioned earlier that you fixed the syntax error, but you never actually > recited the line after fixing it. Please cut/paste the _exact_ line where you > compile the regexp as it is now. Superficially I would expect your regexp to > work, but we would like to see it as it current is. > > Also note that you can print the regexp's .pattern attribute: > > print(constraint.pattern) > > as a check that what was compiled is what you intended to compile. > > >If not, what is the best way to fetch these items in an array? > > What you've got is ok. I would point out that as you're processing each line > on > its own you should not need "re.MULTILINE" in your .compile() call. > > Cheers, > Cameron Simpson > > The upside of PHP is that it lets non-programmers create complex > applications. The downside of PHP is that it lets non-programmers create > complex applications. - Elliot Lee This is the complete code: import re import tkinter.filedialog import readfile j = 0 text = [] #content = "#C[Health] #P[Information]" content = readfile.pattread() while j < len(content): constraint = re.compile(r'(#C\[\w*\])') result = constraint.search(content[j]) text.append(result) print(constraint.pattern) print(text) print(repr(content[j])) j = j+1 This is the result I get: (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>] '#D{#C[Health] #P[Information] - \n' (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>, None] 'means any information, including #ST[genetic information], \n' (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>, None, None] 'whether #C[oral | (recorded in (any form | medium))], that \n' (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>, None, None, None] '(1)#C[Is created or received by] a \n' (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None] '#A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse]; \n' (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None, None] '(2)#C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] | \n' (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None, None, None] '#C[the provision of health care to an individual] | \n' (#C\[\w*\]) [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None, None, None, None] '#C[the past, present, or future payment for the provision of health care to an individual].}\n' -- https://mail.python.org/mailman/listinfo/python-list
Re: calling an api in python code
On Sunday, 12 April 2015 20:50:51 UTC-4, Steven D'Aprano wrote: > On Mon, 13 Apr 2015 10:31 am, Pippo wrote: > > > I am new in this matter.. I need some help to understand how do I call an > > api in python code? > > Your question is too general. It is like: > > > "I am new to carpentry and wood-working. How do I use a tool?" > > Which tool? Hammer, electric drill, hand saw, electric saw, screwdriver, > crowbar, something else? > > > The API tells you how to use a library. That's what API means: "Application > Programming Interface". > > The API for integers includes: > > - add integers using the + operator: 1 + 2 > - multiply integers using the * operator: 3 * 4 > > The API for strings include: > > - use either single quotes to create a string: 'hello world' > - or double quotes: "hello world" > - call the upper() method with no arguments to return an uppercase > version of the string: 'hello'.upper() -> 'HELLO' > - call the split() method with no arguments to split the string > on whitespace: 'hello world'.split() -> ['hello', 'world'] > - call the split() method with a string argument to split the string > on that string: 'hello world'.split('o') -> ['hell', 'w', 'rld'] > > and so on and so on and so on. Can you ask a more specific question? > > > -- > Steven This is what I want to use: https://github.com/mbrubeck/collusion No proper documentation for it! Is there an API for creating network graphs in python? I want to create network for my text files. -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
On Sunday, 12 April 2015 21:07:09 UTC-4, MRAB wrote: > On 2015-04-13 01:55, Pippo wrote: > > On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> >> >> > > constraint = re.compile(r'(#C\[\w*\]')) > >> >> >> > > result = constraint.search(content[j],re.MULTILINE) > >> >> >> > > text.append(result) > >> >> >> > > print(text) > >> [...] > >> >> >> result is empty! Although it should have a content. > >> [...] > >> >> > I fixed the syntax error but the result shows: > >> >> > [None] > >> >> > [None, None] > >> [...] > >> > >> Note that "None" is not "empty", though in this case more or less means > >> what > >> you think. > >> > >> You're getting None because the regexp fails to match. > >> > >> >> Try printing each string you're trying to match using 'repr', i.e.: > >> >> print(repr(content[j])) > >> >> > >> >> Do any look like they should match? > >> > print(repr(content[j])) gives me the following: > >> > > >> >[None] > >> >'#D{#C[Health] #P[Information] - \n' > >> [...] > >> >shouldn't it match "#C[Health]" in the first row? > >> > >> It looks like it should, unless you have mangled your regular expression. > >> You > >> mentioned earlier that you fixed the syntax error, but you never actually > >> recited the line after fixing it. Please cut/paste the _exact_ line where > >> you > >> compile the regexp as it is now. Superficially I would expect your regexp > >> to > >> work, but we would like to see it as it current is. > >> > >> Also note that you can print the regexp's .pattern attribute: > >> > >> print(constraint.pattern) > >> > >> as a check that what was compiled is what you intended to compile. > >> > >> >If not, what is the best way to fetch these items in an array? > >> > >> What you've got is ok. I would point out that as you're processing each > >> line on > >> its own you should not need "re.MULTILINE" in your .compile() call. > >> > >> Cheers, > >> Cameron Simpson > >> > >> The upside of PHP is that it lets non-programmers create complex > >> applications. The downside of PHP is that it lets non-programmers create > >> complex applications. - Elliot Lee > > > > This is the complete code: > > > > import re > > import tkinter.filedialog > > import readfile > > > > > > > > j = 0 > > > > text = [] > > > > > > #content = "#C[Health] #P[Information]" > > > > content = readfile.pattread() > > > > while j < len(content): > > > > constraint = re.compile(r'(#C\[\w*\])') > > result = constraint.search(content[j]) > > text.append(result) > > print(constraint.pattern) > > print(text) > > print(repr(content[j])) > > j = j+1 > > > > This is the result I get: > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>] > > '#D{#C[Health] #P[Information] - \n' > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>, None] > > 'means any information, including #ST[genetic information], \n' > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>, None, None] > > 'whether #C[oral | (recorded in (any form | medium))], that \n' > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>, None, None, None] > > '(1)#C[Is created or received by] a \n' > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None] > > '#A[health care provider | health plan | public health authority | employer > > | life insurer | school | university | or health care clearinghouse]; \n' > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None, None] > > '(2)#C[Relates to] #C[the past, present, or future physical | mental health > > | condition of an individual] | \n' > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None, None, None] > > '#C[the provision of health care to an individual] | \n' > > (#C\[\w*\]) > > [<_sre.SRE_Match object at 0x10292ee40>, None, None, None, None, None, > > None, None] > > '#C[the past, present, or future payment for the provision of health care > > to an individual].}\n' > > > The search returns a match object. If you want the text that it found, > use the match object's .group method. If I add the print it gives me error: import re import tkinter.filedialog import readfile j = 0 text = [] content = readfile.pattread() constraint = re.compile(r'(#C\[\w*\])') while j < len(content): result = constraint.search(content[j]) text.append(result) print(constraint.pattern) print(result.group(0)) print(text) print(repr(content[j])) j = j+1 (#C\[\w*\]) #C[Health] [<_sre.SRE_Match object at 0x10215de40>] '#D{#C[Health] #P[Information] - \n' (#C\[\w*\]) Traceback (most recent call last): File "/Users/sepidehghanavati/Desktop/Programs/python/Python3.3/Main Modules/testpattern.py", line 23, in print(result.group(0)) AttributeError: 'NoneType' object has no attribute 'group' -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
On Sunday, 12 April 2015 21:21:48 UTC-4, Cameron Simpson wrote: > On 12Apr2015 17:55, Pippo wrote: > >On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> It looks like it should, unless you have mangled your regular expression. > [...] > >> Also note that you can print the regexp's .pattern attribute: > >> print(constraint.pattern) > >> as a check that what was compiled is what you intended to compile. > [...] > >This is the complete code: > [...] > > Thank you. > > >while j < len(content): > >constraint = re.compile(r'(#C\[\w*\])') > >result = constraint.search(content[j]) > > I notice you seem to have incorporated MRAB's suggestion that the > re.MULTILINE > is a parameter for re.compile, not re.search, and also my suggestion that you > don't need it at all. > > >text.append(result) > >print(constraint.pattern) > >print(text) > >print(repr(content[j])) > >j = j+1 > > > >This is the result I get: > >(#C\[\w*\]) > >[<_sre.SRE_Match object at 0x10292ee40>] > >'#D{#C[Health] #P[Information] - \n' > >(#C\[\w*\]) > >[<_sre.SRE_Match object at 0x10292ee40>, None] > > I think you've missed the first line, but the above output looks correct to > me > at this point. > > You may want to modify your code to say something like this: > > if result is not None: > text.append(result) > > so that you only accrue matches in your text list. > > Then there are assorted things that can be done to improve the code in > general, > but could you see if you actual bugs are now fixed? > > Cheers, > Cameron Simpson > > A program in conformance will not tend to stay in conformance, because even if > it doesn't change, the standard will. - Norman Diamond Thanks Cameron, I added the if statement but I still get this error: Traceback (most recent call last): File "/Users/sepidehghanavati/Desktop/Programs/python/Python3.3/Main Modules/testpattern.py", line 24, in print(result.group(0)) AttributeError: 'NoneType' object has no attribute 'group' -- https://mail.python.org/mailman/listinfo/python-list
Anyone used snap.py for drawing a graph?
Hi, Any guide on this? http://snap.stanford.edu/snappy/#download -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
> Put the print inside the "if"; you don't really care when result is None, and > anyway you can't access .group when it is None - it is not an 're.match" > object, because there was no match. Thanks Cameron, this worked. > > Once you're happy you should consider what happens when there is more than > one > "C#[blah]" in a line (if that happens; you know the data better than we). Now I have this input data: #D{#C[Health] #P[Information] - means any information, including #ST[genetic information], whether #C[oral | (recorded in (any form | medium))], that (1)#C[Is created or received by] a #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse]; (2)#C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] | #C[the provision of health care to an individual] | #C[the past, present, or future payment for the provision of health care to an individual].} The result of my code is this: #C[Health] [<_sre.SRE_Match object at 0x10212ee40>] [<_sre.SRE_Match object at 0x10212ee40>] [<_sre.SRE_Match object at 0x10212ee40>] [<_sre.SRE_Match object at 0x10212ee40>] [<_sre.SRE_Match object at 0x10212ee40>] [<_sre.SRE_Match object at 0x10212ee40>] [<_sre.SRE_Match object at 0x10212ee40>] [<_sre.SRE_Match object at 0x10212ee40>] The code itself: import re import tkinter.filedialog import readfile j = 0 text = [] content = readfile.pattread() constraint = re.compile(r'(#C\[\w*\])') while j < len(content): result = constraint.search(content[j]) if result is not None: text.append(result) print(result.group(0)) print(text) j = j+1 I know that "[<_sre.SRE_Match object at 0x10212ee40>]" is the result of print(text). Does this mean that we ONLY found one match object? What about if I want the code finds also this one? #C[Is created or received by]? or this one? #C[the past, present, or future physical | mental health | condition of an individual] Is it because of the space and other characters that it doesn't match them? -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
Sweet! Thanks all of you! I matched everything except these ones... trying to find the best way > whether #C[oral | (recorded in (any form | medium))], that #C[the past, present, or future physical | mental health | condition of an individual] | > #C[the past, present, or future payment for the provision of health care to > an individual].} -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
I fixed all! Thanks. This is the result: #C[Health] #P[Information] #ST[genetic information] #C[oral | (recorded in (any form | medium))] #C[Is created or received by] #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse] #C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] #C[the provision of health care to an individual] #C[the past, present, or future payment for the provision of health care to an individual] Now I want to save them in array and then create a graph for them... anyone has any suggestion? For example if the node starts with #P then this is the central node with the name P. All other nodes have to connect to this one or have a node that is connected to this one Also, how can I capture "or" in my node graphs? -- https://mail.python.org/mailman/listinfo/python-list
installing matplotlib
Hi guys, I am trying to install matplotlib and I keep getting error: Traceback (most recent call last): File "setup.py", line 155, in result = package.check() File "/Users/sepidehghanavati/Desktop/Programs/python/matplotlib-1.4.3/setupext.py", line 961, in check min_version='2.3', version=version) File "/Users/sepidehghanavati/Desktop/Programs/python/matplotlib-1.4.3/setupext.py", line 445, in _check_for_pkg_config if (not is_min_version(version, min_version)): File "/Users/sepidehghanavati/Desktop/Programs/python/matplotlib-1.4.3/setupext.py", line 173, in is_min_version return found_version >= expected_version File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/version.py", line 76, in __ge__ c = self._cmp(other) File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/version.py", line 343, in _cmp if self.version < other.version: TypeError: unorderable types: str() < int() any idea? -- https://mail.python.org/mailman/listinfo/python-list
Re: installing matplotlib
On Monday, 13 April 2015 15:58:58 UTC-4, Ned Deily wrote: > In article <176d49d3-6ff8-4d35-b8ec-647f13250...@googlegroups.com>, > Pippo wrote: > > I am trying to install matplotlib and I keep getting error: > [...] > > File > > > > "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/v > > ersion.py", line 343, in _cmp > > if self.version < other.version: > > TypeError: unorderable types: str() < int() > > > > any idea? > > If you are running on OS X 10.10 (Yosemite), try upgrading to a current > Python 3.4.x. 3.3.x is no longer supported and was released long before > Yosemite was. > > http://bugs.python.org/issue21811 > > -- > Ned Deily, > n...@acm.org Thanks -- https://mail.python.org/mailman/listinfo/python-list
showing a graph
Hi, I want to show the graph for this code: import re from Tkinter import * import tkFileDialog import testpattern import networkx as nx import matplotlib.pyplot as plt patternresult =[] nodes = {} edges = {} pattern = ['(#P\[\w*\])', '(#C\[\w*[\s\(\w\,\s\|\)]+\])', '(#ST\[\w*[\s\(\w\,\s\|\)]+\])', '(#A\[\w*[\s\(\w\,\s\|\)]+\])'] patternresult = testpattern.patternfinder() G=nx.Graph() for patres in patternresult: G.add_node(patres) if patres[1] == "P": first_node = patres for patres in patternresult: if patres[1:3] == "ST": G.add_edge(first_node, patres, label="Sub-type") elif patres[1:2] == "C": G.add_edge(first_node, patres, label="Constraint_by") elif patres[1:3] == "A": G.add_edge(first_node, patres, label="Created_by") #graph = G.edge() pos = nx.shell_layout(G) #nx.draw(G, pos) nx.draw_networkx_nodes(G, pos, nodelist=None, node_size=300, node_color='r', node_shape='o', alpha=1.0, cmap=None, vmin=None, vmax=None, ax=None, linewidths=None) nx.draw_networkx_edges(G, pos, edgelist=None, width=1.0, edge_color='k', style='solid',alpha=None, edge_cmap=None, edge_vmin=None, edge_vmax=None,ax=None, arrows=True) nx.draw_networkx_labels(G, pos,font_size=10, font_family='sans-serif') plt.show() #plt.savefig("path.png") But when I run the code, only a bar is shown on my desktop without showing the proper graph. Note that I checked the number of edges and the number of nodes and they are correct and this output also has been shown: #C[Health] #P[Information] #ST[genetic information] #C[oral | (recorded in (any form | medium))] #C[Is created or received by] #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse] #C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] #C[the provision of health care to an individual] #C[the past, present, or future payment for the provision of health care to an individual] I don't get any error. Just that I don't see any graph! -- https://mail.python.org/mailman/listinfo/python-list
Using Dictionary
How can I use dictionary to save the following information? #C[Health] #P[Information] #ST[genetic information] #C[oral | (recorded in (any form | medium))] #C[Is created or received by] #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse] #C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] #C[the provision of health care to an individual] #C[the past, present, or future payment for the provision of health care to an individual] -- https://mail.python.org/mailman/listinfo/python-list
creating a graph out of text
Hi, I am not sure why my code doesn't show the graph. It clearly creates the right nodes and edges but it doesn't show them. Any idea? mport re from Tkinter import * import tkFileDialog import testpattern import networkx as nx import matplotlib.pyplot as plt patternresult =[] nodes = {} edges = {} pattern = ['(#P\[\w*\])', '(#C\[\w*[\s\(\w\,\s\|\)]+\])', '(#ST\[\w*[\s\(\w\,\s\|\)]+\])', '(#A\[\w*[\s\(\w\,\s\|\)]+\])'] patternresult = testpattern.patternfinder() G=nx.Graph() for patres in patternresult: G.add_node(patres) if patres[1] == "P": first_node = patres for patres in patternresult: if patres[1:3] == "ST": G.add_edge(first_node, patres, label="Sub-type") elif patres[1:2] == "C": G.add_edge(first_node, patres, label="Constraint_by") elif patres[1:3] == "A": G.add_edge(first_node, patres, label="Created_by") #graph = G.edge() pos = nx.shell_layout(G) #nx.draw(G, pos) nx.draw_networkx_nodes(G, pos, nodelist=None, node_size=300, node_color='r', node_shape='o', alpha=1.0, cmap=None, vmin=None, vmax=None, ax=None, linewidths=None) nx.draw_networkx_edges(G, pos, edgelist=None, width=1.0, edge_color='k', style='solid',alpha=None, edge_cmap=None, edge_vmin=None, edge_vmax=None,ax=None, arrows=True) nx.draw_networkx_labels(G, pos,font_size=10, font_family='sans-serif') plt.show() #plt.savefig("path.png") I think the problem starts from nx.draw This is what I want to create graph for: #C[Health] #P[Information] #ST[genetic information] #C[oral | (recorded in (any form | medium))] #C[Is created or received by] #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse] #C[Relates to] #C[the past, present, or future physical | mental health | condition of an individual] #C[the provision of health care to an individual] #C[the past, present, or future payment for the provision of health care to an individual] This also shows all of the edges that are created... {'#C[the past, present, or future payment for the provision of health care to an individual]': 1, '#A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health care clearinghouse]': 0, '#C[Relates to]': 1, '#C[the past, present, or future physical | mental health | condition of an individual]': 1, '#C[Is created or received by]': 1, '#C[the provision of health care to an individual]': 1, '#C[Health]': 1, '#C[oral | (recorded in (any form | medium))]': 1, '#ST[genetic information]': 1, '#P[Information]': 8} -- https://mail.python.org/mailman/listinfo/python-list
Re: Using Dictionary
On Tuesday, 14 April 2015 09:54:46 UTC-4, Michiel Overtoom wrote: > On Apr 14, 2015, at 15:34, Pippo wrote: > > > How can I use dictionary to save the following information? > > What a curious question. The purpose of a dictionary is not to save > information, but to store data as a key -> value mapping: > > telbook = {} > telbook["jan"] = "0627832873" > telbook["mary"] = "050-932390" > > Or do you mean 'store' when you mention 'save'? > > ...and to store a bunch of lines you don't need a dictionary either. A list > would do: > > info = [ > "#C[Health]", > "#P[Information]", > "#ST[genetic information]", > ] > > Greetings, > > -- > "You can't actually make computers run faster, you can only make them do > less." - RiderOfGiraffes Thanks. I wanted to store them. -- https://mail.python.org/mailman/listinfo/python-list