ci_mapping/run_pipeline.py
def fos_groups(self):
        """Tag Fields of Study as Core Collective Intelligence and AI+CI.
        This method could be extended to divide a dataset to core and control
        group.
        """
        # Connect to postgresql
        s = self._create_session()
        # Delete rows in CoreControlGroup
        s.query(CoreControlGroup).delete()
        s.commit()

        # Fetch postgres tables
        fos = pd.read_sql(s.query(FieldOfStudy).statement, s.bind)
        pfos = pd.read_sql(s.query(PaperFieldsOfStudy).statement, s.bind)

        # Merge and groupby so that FoS are in a list
        pfos = pfos.merge(fos, left_on="field_of_study_id", right_on="id")
        pfos = pd.DataFrame(pfos.groupby("paper_id")["norm_name"].apply(list))

        # Allocate papers in CI, AI+CI groups based on Fields of Study.
        pfos["type"] = pfos.norm_name.apply(allocate_in_group, args=([self.fos_subset]))
        logger.info(f"CI papers: {pfos[pfos['type']=='CI'].shape[0]}")
        logger.info(f"AI+CI papers: {pfos[pfos['type']=='AI_CI'].shape[0]}")

        for idx, row in pfos.iterrows():
            s.add(CoreControlGroup(id=idx, type=row["type"]))
            s.commit()

        # self.next(self.open_access_journals)
        self.next(self.geocode_affiliation)
Tag Fields of Study as Core Collective Intelligence and AI+CI.
        This method could be extended to divide a dataset to core and control
        group.
        
Tag Fields of Study as Core Collective Intelligence and AI+CI.
This method could be extended to divide a dataset to core and control
group.
Tag Fields of Study as Core Collective Intelligence and AI + CI . This method could be extended to divide a dataset to core and control group .
def fos_groups(self):
        s = self._create_session()
        s.query(CoreControlGroup).delete()
        s.commit()
        fos = pd.read_sql(s.query(FieldOfStudy).statement, s.bind)
        pfos = pd.read_sql(s.query(PaperFieldsOfStudy).statement, s.bind)
        pfos = pfos.merge(fos, left_on="field_of_study_id", right_on="id")
        pfos = pd.DataFrame(pfos.groupby("paper_id")["norm_name"].apply(list))
        pfos["type"] = pfos.norm_name.apply(allocate_in_group, args=([self.fos_subset]))
        logger.info(f"CI papers: {pfos[pfos['type']=='CI'].shape[0]}")
        logger.info(f"AI+CI papers: {pfos[pfos['type']=='AI_CI'].shape[0]}")
        for idx, row in pfos.iterrows():
            s.add(CoreControlGroup(id=idx, type=row["type"]))
            s.commit()
        self.next(self.geocode_affiliation)
def fos_groups ( self ) : s = self . _create_session ( ) s . query ( CoreControlGroup ) . delete ( ) s . commit ( ) fos = pd . read_sql ( s . query ( FieldOfStudy ) . statement , s . bind ) pfos = pd . read_sql ( s . query ( PaperFieldsOfStudy ) . statement , s . bind ) pfos = pfos . merge ( fos , left_on = "field_of_study_id" , right_on = "id" ) pfos = pd . DataFrame ( pfos . groupby ( "paper_id" ) [ "norm_name" ] . apply ( list ) ) pfos [ "type" ] = pfos . norm_name . apply ( allocate_in_group , args = ( [ self . fos_subset ] ) ) logger . info ( f"CI papers: {pfos[pfos['type']=='CI'].shape[0]}" ) logger . info ( f"AI+CI papers: {pfos[pfos['type']=='AI_CI'].shape[0]}" ) for idx , row in pfos . iterrows ( ) : s . add ( CoreControlGroup ( id = idx , type = row [ "type" ] ) ) s . commit ( ) self . next ( self . geocode_affiliation )
Tag Fields of Study as Core Collective Intelligence and AI+CI.
Tag Fields of Study as Core Collective Intelligence and AI + CI .
"""Tag Fields of Study as Core Collective Intelligence and AI+CI.
        This method could be extended to divide a dataset to core and control
        group.
        """ # Connect to postgresql # Delete rows in CoreControlGroup # Fetch postgres tables # Merge and groupby so that FoS are in a list # Allocate papers in CI, AI+CI groups based on Fields of Study. # self.next(self.open_access_journals)
self