Commit c6a8c5d7 authored by Administrator's avatar Administrator

Modification donut

parent bd6003f3
......@@ -15,6 +15,9 @@ from itertools import *
from django.db import connection
from django import forms
from collections import defaultdict
# SOME FUNCTIONS
def query_to_dicts(query_string, *query_args):
......@@ -151,29 +154,25 @@ def corpus(request, project_id, corpus_id):
number = corpus.children.count()
try:
sources = dict()
# query_to_dicts('''select count(*), source
# from node_node as t1
# INNER JOIN documents_document_corpus as t2
# ON ( t1.id = t2.document_id )
# WHERE ( t1.user_id = %d AND t2.corpus_id = %d )
# GROUP BY source
# order by 1 DESC limit %d;''' % (request.user.pk, int(corpus_id), int(15)))
sources = defaultdict(int)
for document in documents.all():
sources[document.metadata['journal']] += 1
sources_donut = []
for source in sources.keys():
source_count = dict()
source_count['count'] = source['count']
try:
source_count['part'] = round(source_count['count'] * 100 / number)
except:
source_count['part'] = None
source_count['source'] = source['source']
sources_donut.append(source_count)
except:
pass
sources_donut = []
for s in sources:
ss = dict()
ss['count'] = s['count']
try:
ss['part'] = round(ss['count'] * 100 / number)
except:
ss['part'] = None
ss['source'] = s['source']
sources_donut.append(ss)
try:
first = documents.first().date
last = documents.last().date
......
{
"metadata": {
"name": "",
"signature": "sha256:f40cd0083a2e4ad7d01d7cd7be66a75e339a993999b0ff7b8207b089c8c3b4e9"
"signature": "sha256:6df2ce47b09a6203b244f7b4dc27f3346901261b85922dd46bc54d669d6469a6"
},
"nbformat": 3,
"nbformat_minor": 0,
......@@ -14,12 +14,13 @@
"input": [
"from node.models import Node, NodeType, Language\n",
"import parsing\n",
"from parsing.FileParsers import *"
"from parsing.FileParsers import *\n",
"from collections import defaultdict"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
"prompt_number": 23
},
{
"cell_type": "code",
......@@ -518,6 +519,49 @@
"outputs": [],
"prompt_number": 20
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"journal_count = defaultdict(int)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 29
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"for document in node.children.all():\n",
" journal_count[document.metadata['journal']] += 1"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 30
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"journal_count"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 31,
"text": [
"defaultdict(<class 'int'>, {'Annals of allergy, asthma & immunology : official publication of the American College of Allergy, Asthma, & Immunology': 2, 'PLoS pathogens': 4, 'Revista Argentina de microbiolog\u00eda': 2, 'Insect molecular biology': 2, 'BioEssays : news and reviews in molecular, cellular and developmental biology': 2, 'Neurochemistry international': 2, 'Insect biochemistry and molecular biology': 2, 'Science (New York, N.Y.)': 16, 'Experimental & applied acarology': 2, 'Trends in microbiology': 2, 'Current microbiology': 2, 'Journal of virology': 2, 'Scientific American': 4, 'Environmental microbiology': 2, 'Medical hypotheses': 2, 'Applied and environmental microbiology': 2, 'Die Naturwissenschaften': 2, 'Journal of agricultural and food chemistry': 2, 'The Veterinary quarterly': 2, 'Journal of invertebrate pathology': 22, 'Ecology letters': 2, 'Integrative and comparative biology': 2, 'PloS one': 28, 'Parasitology research': 4, 'Current biology : CB': 2, 'Molecular & cellular proteomics : MCP': 4, 'In vitro cellular & developmental biology. Animal': 2, 'Preventive veterinary medicine': 2, 'The Journal of general virology': 6, 'Veterinary microbiology': 2, 'Proceedings of the National Academy of Sciences of the United States of America': 6, 'Ecology and evolution': 2, 'Human and ecological risk assessment : HERA': 2, 'International journal of environmental research and public health': 2, 'Journal of economic entomology': 4, 'Environmental microbiology reports': 6, 'Environmental science & technology': 2, 'mBio': 2, 'Veterinary research': 2, 'Nature': 2})"
]
}
],
"prompt_number": 31
},
{
"cell_type": "code",
"collapsed": false,
......
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