Ejemplo n.º 1
0
        /// <summary>
        /// Get the author position from the PeoplePublications table
        /// </summary>
        /// <param name="publication">The Person to search for</param>
        /// <param name="PositionType">The value in PeoplePublications.PositionType</param>
        /// <returns>The author position (or 0 if not found)</returns>
        public static int GetAuthorPosition(Database DB, int PMID, Person person, out Harvester.AuthorPositions PositionType, string PeoplePublicationsTable)
        {
            ArrayList Parameters = new ArrayList();

            Parameters.Add(Database.Parameter(PMID));
            Parameters.Add(Database.Parameter(person.Setnb));
            DataTable Results = DB.ExecuteQuery(
                @"SELECT AuthorPosition, PositionType 
                    FROM " + PeoplePublicationsTable + @"
                   WHERE PMID = ? 
                     AND Setnb = ?", Parameters);

            if (Results.Rows.Count == 0)
            {
                PositionType = 0;
                return(0);
            }
            else
            {
                PositionType = (Harvester.AuthorPositions)Convert.ToInt32(Results.Rows[0]["PositionType"]);
                return(Convert.ToInt32(Results.Rows[0]["AuthorPosition"]));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get an author position entity node (extension method)
 /// </summary>
 /// <param name="g">Graph to use for creating the node</param>
 /// <param name="authorPosition">Author position to get</param>
 /// <returns>URI for the author position entity</returns>
 public static INode GetAuthorPositionEntityNode(this IGraph g, Harvester.AuthorPositions authorPosition)
 {
     return(g.CreateUriNode(GetAuthorPositionUri(authorPosition)));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Get the author position Uri for a Harvester.AuthorPositions value
 /// </summary>
 /// <param name="authorPosition">Harvester.AuthorPositions value</param>
 /// <returns>Prefixed URI for the author position</returns>
 public static string GetAuthorPositionUri(Harvester.AuthorPositions authorPosition)
 {
     return("author-position:" + authorPosition.ToString());
 }
        /// <summary>
        /// Updated the counts for a publication, given a row from the query in Generate().
        /// The counts are collected in a hashtable indexed by year. Each item in the
        /// hashtable is another hashtable, indexed by the report column category
        /// ("NTL2", "LM", etc.). This in turn contains the count. There are two master
        /// hashtables of these counts, one for weighted and the other for unweighted.
        /// </summary>
        /// <param name="reports">Reports object initialized with journal weights</param>
        /// <param name="Row">Row from the query in Generate()</param>
        /// <param name="CountsPerYear">Hashtable that contains the counts for each year</param>
        /// <param name="WeightsPerYear">Hashtable that containst he weights for each year</param>
        private static void UpdateCounts(Reports reports, DataRow Row, Hashtable CountsPerYear, Hashtable WeightsPerYear,
                                         Hashtable Nbcoauth1, Hashtable Wghtd_Nbcoauth1, Hashtable Nbcoauth2, Hashtable Wghtd_Nbcoauth2)
        {
            int Year = Convert.ToInt32(Row["Year"]);

            Harvester.AuthorPositions ColleaguePositionType =
                (Harvester.AuthorPositions)Convert.ToInt32(Row["ColleaguePositionType"]);
            Harvester.AuthorPositions StarPositionType =
                (Harvester.AuthorPositions)Convert.ToInt32(Row["StarPositionType"]);
            string Journal = Row["Journal"].ToString();

            // Use the Reports object to get the publication's journal weight.
            Single Weight;

            if (reports.Weights.ContainsKey(Journal))
            {
                Weight = (Single)reports.Weights[Journal];
            }
            else
            {
                Weight = 0;
            }

            // Create or retrieve the correct counts hashtable
            if (!CountsPerYear.ContainsKey(Year))
            {
                CountsPerYear[Year] = new Hashtable();
            }
            Hashtable Counts = (Hashtable)CountsPerYear[Year];

            // Create or retrieve the correct weights hashtables
            if (!WeightsPerYear.ContainsKey(Year))
            {
                WeightsPerYear[Year] = new Hashtable();
            }
            Hashtable Weights = (Hashtable)WeightsPerYear[Year];

            // Update Nbcoauth1 and Wghtd_Nbcoauth1 for every publication
            if (!Nbcoauth1.ContainsKey(Year))
            {
                Nbcoauth1[Year] = (int)0;
            }
            int Nbcoauth1_value = (int)Nbcoauth1[Year];

            Nbcoauth1_value++;
            Nbcoauth1[Year] = Nbcoauth1_value;
            if (!Wghtd_Nbcoauth1.ContainsKey(Year))
            {
                Wghtd_Nbcoauth1[Year] = (Single)0.0;
            }
            Single Wghtd_Nbcoauth1_value = (Single)Wghtd_Nbcoauth1[Year];

            Wghtd_Nbcoauth1_value += Weight;
            Wghtd_Nbcoauth1[Year]  = Wghtd_Nbcoauth1_value;


            // Update Nbcoauth2 and Wghtd_Nbcoauth2 for publications where either
            // the star or colleague are first or last
            if ((ColleaguePositionType == Harvester.AuthorPositions.First) ||
                (ColleaguePositionType == Harvester.AuthorPositions.Last) ||
                (StarPositionType == Harvester.AuthorPositions.First) ||
                (StarPositionType == Harvester.AuthorPositions.Last))
            {
                if (!Nbcoauth2.ContainsKey(Year))
                {
                    Nbcoauth2[Year] = (int)0;
                }
                int Nbcoauth2_value = (int)Nbcoauth2[Year];
                Nbcoauth2_value++;
                Nbcoauth2[Year] = Nbcoauth2_value;
                if (!Wghtd_Nbcoauth2.ContainsKey(Year))
                {
                    Wghtd_Nbcoauth2[Year] = (Single)0.0;
                }
                Single Wghtd_Nbcoauth2_value = (Single)Wghtd_Nbcoauth2[Year];
                Wghtd_Nbcoauth2_value += Weight;
                Wghtd_Nbcoauth2[Year]  = Wghtd_Nbcoauth2_value;
            }

            // Update the count and weight for each column
            for (int ColumnNum = 0; ColumnNum < ReportColumns.Length; ColumnNum++)
            {
                // Figure out which colleague position needs to be counted for the column.
                // The column will indicate which articles are to be counted, based
                // on author position: 1 (first), L (last), 2 (seond), NTL (next-to-last),
                // M (middle). The column starts with the colleague value, and ends
                // with the star value.
                string Column = ReportColumns[ColumnNum];
                Harvester.AuthorPositions ColleagueExpected;
                if (Column.StartsWith("NTL")) // look for NTL first to disambiguate from L
                {
                    ColleagueExpected = Harvester.AuthorPositions.NextToLast;
                }
                else if (Column.StartsWith("1"))
                {
                    ColleagueExpected = Harvester.AuthorPositions.First;
                }
                else if (Column.StartsWith("L"))
                {
                    ColleagueExpected = Harvester.AuthorPositions.Last;
                }
                else if (Column.StartsWith("2"))
                {
                    ColleagueExpected = Harvester.AuthorPositions.Second;
                }
                else
                {
                    ColleagueExpected = Harvester.AuthorPositions.Middle;
                }

                // Figure out which star position needs to be counted for the column.
                Harvester.AuthorPositions StarExpected;
                if (Column.EndsWith("NTL")) // look for NTL first to disambiguate from L
                {
                    StarExpected = Harvester.AuthorPositions.NextToLast;
                }
                else if (Column.EndsWith("1"))
                {
                    StarExpected = Harvester.AuthorPositions.First;
                }
                else if (Column.EndsWith("L"))
                {
                    StarExpected = Harvester.AuthorPositions.Last;
                }
                else if (Column.EndsWith("2"))
                {
                    StarExpected = Harvester.AuthorPositions.Second;
                }
                else
                {
                    StarExpected = Harvester.AuthorPositions.Middle;
                }


                // Only the weight to the correct hash for the star and colleague
                // position types.
                if ((ColleaguePositionType == ColleagueExpected) &&
                    (StarPositionType == StarExpected))
                {
                    // Retrieve or initialize the Counts and Weights hashes
                    if (!Counts.ContainsKey(Column))
                    {
                        Counts[Column] = (int)0;
                    }
                    if (!Weights.ContainsKey(Column))
                    {
                        Weights[Column] = (Single)0.0;
                    }

                    // Update the count and weight.
                    int ColumnCount = (int)Counts[Column];
                    ColumnCount++;
                    Counts[Column] = ColumnCount;

                    Single ColumnWeight = (Single)Weights[Column];
                    ColumnWeight   += Weight;
                    Weights[Column] = ColumnWeight;
                }
            }

            // Save the updated hashtables
            CountsPerYear[Year]  = Counts;
            WeightsPerYear[Year] = Weights;
        }