예제 #1
0
def main():
    cluster_rows = dict()
    for i in range(10):
        filereader = FileReader(f"./full_tweets/cluster_{i}.csv")
        cluster_rows[i] = filereader.get_rows()
        with codecs.open("cluster_rows.csv", "w+") as o:
            o.write("Cluster Number" + "," + "User Name" + "," + "user_id\t" + "," + "No of Tweets\t\t" + "," + "Tweet_id\t" + ","
                    "Retweet Count\t" + "," + "Inf Score\t" + "," + "Tweet\n")
            for key, value in cluster_rows.items():
                lines = ""
                for v in value:
                    line = str(key)
                    line += ","
                    line += ",".join(v)
                    line += "\n"
                    lines += line
                o.write(lines)
예제 #2
0
    def get_starter_template():
        # Init
        filereader = FileReader()
        weaponsdict = []
        weapons_read = []
        weapons = []
        information_number = 4 * 2

        # Scan Dir for Weapon Files
        files = [f for f in os.listdir("./") if isfile(join("./", f))]
        files.remove("WeaponTemplates.py")

        # Append File Content
        for i in range(len(files)):
            weapons_read.append(
                filereader.line(os.path.dirname(__file__) + "/" + files[i]))

        # Write Data to List
        for i in weapons_read:
            for _i in i:
                item = _i.split("=")

                for _item in item:
                    _item = _item.strip(' ')
                    if "??" in item:
                        _item.replace("??", "100")
                    weapons.append(_item)

        # Convert List to Dict
        weapon = []
        for item in weapons:
            weapon.append(item)
            if len(weapon) % information_number == 0:
                weaponsdict.append(Functions.list_to_dict(weapon))
                del weapon

        # Return Result
        return weaponsdict
예제 #3
0
def main():
    os.chdir("../step_9")
    reader = FileReader("step_9_output_inf_user_tweets.csv")
    user_n_tweets = reader.rows
    dict_of_users = RowSeperater(user_n_tweets).seperate_rows()
    tweet_dump = []
    dict_of_id_words = {}
    for key, value in dict_of_users.items():
        for k, v in value.items():
            words_list = TweetNormalizer(v).words
            words_list = StopWordsRemover(words_list).reduced_words
            stemmed_words = WordStemmer(words_list).implement_stemming()
            lem_words = WordLemmatizer(stemmed_words).implement_lemmatizing()
            lem_words = list(set(lem_words))
            dict_of_id_words[k] = lem_words
            tweet_dump += lem_words

    tweet_dump = list(set(tweet_dump))
    # print(len(tweet_dump))

    pprint(dict_of_id_words)
예제 #4
0
from Day2.InventorySystem import InventorySystem
from utils.FileReader import FileReader

list_of_ids = FileReader.read('../sources/day2.txt')

system = InventorySystem(list_of_ids)
print('Checksum       : ', system.checksum())
print('Common letters : ', system.find_boxes_common_letters())
예제 #5
0
from Day1.Chronal_Calibration import Device
from utils.FileReader import FileReader

sequence = FileReader.read('../sources/day1.txt')

device = Device()
device.calibrate(sequence)

print('Final frequency state        :', device.final_frequency)
print('Frequency that occured twice :', device.frequency)
예제 #6
0
 def test_read_should_return_array_of_lines(self, mock):
     lines = FileReader.read('./path/to/file.txt')
     assert lines == ['line1', 'line2']
예제 #7
0
from Day3.Claim import Claim
from Day3.Diplomat import Diplomat
from utils.FileReader import FileReader

list_of_claims_scheme = FileReader.read('../sources/day3.txt')

list_of_claims = [Claim.parse(claim) for claim in list_of_claims_scheme]

diplomate = Diplomat(list_of_claims)
print(diplomate.number_of_conflicts())
예제 #8
0
    def create_training_data(self):

        # reading Porosity
        porosityMatrices = FileReader.read("data/" + self.attributes_files[0],
                                           20)
        self.x_size, self.y_size = porosityMatrices[0].shape
        x = porosityMatrices[0].flatten()
        y = porosityMatrices[1].flatten()
        porosity = porosityMatrices[2].flatten()
        col = porosityMatrices[3].flatten()
        row = porosityMatrices[4].flatten()

        # reading Porosity-effective
        porosityEffectiveMatrix = FileReader.read(
            "data/" + self.attributes_files[1], 20)
        porosity_effective = porosityEffectiveMatrix[2].flatten()

        # reading ntglinear_model,
        ntgMatrix = FileReader.read("data/" + self.attributes_files[2], 20)
        ntg = ntgMatrix[2].flatten()

        # reading sw_base
        swBaseMatrix = FileReader.read("data/" + self.attributes_files[3], 20)
        sw_base = swBaseMatrix[2].flatten()

        # reading sg_base
        sgBaseMatrix = FileReader.read("data/" + self.attributes_files[4], 20)
        sg_base = sgBaseMatrix[2].flatten()

        # reading dsg
        dsgMatrix = FileReader.read("data/" + self.attributes_files[5], 20)
        dsg = dsgMatrix[2].flatten()

        # reading dsw
        dswMatrix = FileReader.read("data/" + self.attributes_files[6], 20)
        dsw = dswMatrix[2].flatten()

        # reading actual dRMS
        fair_int_dRMSMatrix_10m = FileReader.read(
            "data/" + self.attributes_files[7], 20)
        xdRMS = fair_int_dRMSMatrix_10m[0].flatten()
        ydRMS = fair_int_dRMSMatrix_10m[1].flatten()
        fair_int_dRMS_10m = fair_int_dRMSMatrix_10m[2].flatten()

        # reading actual dRMS
        fair_int_dRMSMatrix_20m = FileReader.read(
            "data/" + self.attributes_files[8], 20)
        xdRMS = fair_int_dRMSMatrix_20m[0].flatten()
        ydRMS = fair_int_dRMSMatrix_20m[1].flatten()
        fair_int_dRMS_20m = fair_int_dRMSMatrix_20m[2].flatten()

        # reading synthetic dRMS
        fair_int_dRMSMatrix = FileReader.read(
            "data/" + self.attributes_files[9], 20)
        xdRMS = fair_int_dRMSMatrix[0].flatten()
        ydRMS = fair_int_dRMSMatrix[1].flatten()
        fair_int_dRMS = fair_int_dRMSMatrix[2].flatten()

        for i in range(len(x)):
            if math.isnan(x[i]) or math.isnan(y[i]) or math.isnan(
                    dsg[i]) or math.isnan(dsw[i]) or math.isnan(
                        xdRMS[i]) or math.isnan(ydRMS[i]) or math.isnan(
                            fair_int_dRMS_10m[i]) or math.isnan(
                                fair_int_dRMS_20m[i]) or math.isnan(
                                    fair_int_dRMS[i]):
                #nothing
                print("")
            else:
                self.x.append(x[i])
                self.y.append(y[i])
                self.porosity.append(porosity[i])
                self.porosity_effective.append(porosity_effective[i])
                self.col.append(col[i])
                self.row.append(row[i])
                self.ntg.append(ntg[i])
                self.sw_base.append(sw_base[i])
                self.sg_base.append(sg_base[i])
                self.dsg.append(dsg[i])
                self.dsw.append(dsw[i])
                self.xdRMS.append(xdRMS[i])
                self.ydRMS.append(ydRMS[i])
                self.fair_int_dRMS_10m.append(fair_int_dRMS_10m[i])
                self.fair_int_dRMS_20m.append(fair_int_dRMS_20m[i])
                self.fair_int_dRMS.append(fair_int_dRMS[i])