c# – Inheriting from Dictionary class with tuple as value

I have a class that inherits from Dictionary<Tkey, TValue>.

I need my Value part of the KeyValue pair to be a a Tuple (int, bool )

public class IssueRowValidationDictionary :
        Dictionary<string, (int, bool)>
    {
        public IssueRowValidationDictionary() : base() { }

        internal void Add(string issueReference, int rawRowNumber, bool v)
        {
            Add(issueReference, (rawRowNumber, v));
        }
    }

In my code there are cases where I need to get the int Value part of the dictionary Element

             var intValue = issueRowValidationDictionary('keyRef').Item1;

Is there a more elegant way for Example to create a specific property that will only return the int part of the value. Any suggestions for improvement of my code are welcomed

python 3.x – After parsing, it is not possible to form data in the dictionary in a certain format

Help me understand how to compose an algorithm.
I take tags <p>, <ul> in the source, trying to insert a list with the key ‘ParametersVariants’

part of html from source

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<tbody>

<tr>
    <td colspan="1" class="confluenceTd">
        <div class="content-wrapper"><p>1100a, 1100b, 1100c</p>
            </div>
    </td>
    <td colspan="1" class="confluenceTd">Увидел экран "Весь портфель"</td>
    <td colspan="1" class="confluenceTd"><br></td>
    <td colspan="1" class="confluenceTd">11000_Portf_Group_Show</td>
    <td colspan="1" class="confluenceTd"><p><span style="color: rgb(0,0,0);"><strong><u style="text-align: left;">ListAccID:&nbsp;</u></strong>перечень ID счетов, по которым ВКЛЮЧЕНЫ активы через&nbsp;, (запятую) в квадратных скобках, каждое значение в кавычках. Например,&nbsp;("321322","432432")</span>
    </p>
        <p><s><u><strong>AcсType:</strong></u></s>&nbsp;Не передаем, так как тут показывают весь портфель&nbsp;по всем
            счетам</p>
        <ul>
            <li><strong>Основной</strong></li>
            <li><strong>ИИС</strong></li>
        </ul>
        <p><u><strong>Section: </strong></u>(Где находится)</p>
        <ul>
            <li><strong>Position&nbsp;</strong>- Активы, позиции&nbsp;(экран 1102)</li>
            <li><strong>Order&nbsp;</strong>- Заявки (экран 1102)</li>
            <li><strong>History</strong> - История (экран 1501/экран 1601)</li>
            <li><s><strong>Operation</strong></s> - Операции</li>
        </ul>
        <p><span
                style="color: rgb(255,0,0);">--Так мы записываем комментарии, которые не являются доп параметром.</span>
        </p></td>
    <td colspan="1" class="confluenceTd"><br></td>
    <td colspan="1" class="confluenceTd"><br></td>
    <td colspan="1" class="confluenceTd"><br></td>
    <td colspan="1" class="confluenceTd"><br></td>
</tr>
</tbody>
</body>
</html>

as a result, an extra line – ‘ParameterName’ and an empty list ‘ParametersVariants’ are duplicated,
but the list should be opposite the corresponding ‘ParameterName’ parameter, and not on a separate line

(out):

{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'ListAccID:', 'ParametersVariants': ()}
{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'AcсType:', 'ParametersVariants': ()}
{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'AcсType:', 'ParametersVariants': ('Основной', 'ИИС')}
{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'Section: ', 'ParametersVariants': ()}
{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'Section: ', 'ParametersVariants': ('Position', {'EventName': '11000_Portf_Group_Show', 'ParameterName': 'Section: ', 'ParametersVariants': ()}

should be

{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'ListAccID:', 'ParametersVariants': ()}
{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'AcсType:', 'ParametersVariants': ('Основной', 'ИИС')}
{'EventName': '11000_Portf_Group_Show', 'ParameterName': 'Section: ', 'ParametersVariants': ('Position', 'Order', 'History ', 'Operation ')}

my code

# -*- coding: UTF-8 -*-

import csv
import os
import pprint
import re
from bs4 import BeautifulSoup

tbody_2 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tbody_2.html')


def prepare_events():
    html_part = open(tbody_2, 'r', encoding='utf-8').read()
    soup = BeautifulSoup(html_part, features='html.parser')
    rows = soup.find_all('tr')
    data = {}
    for row in rows:
        try:
            td = row.find_all(('th', 'td'))
            event_name = cleanhtml(td(3)).strip()
            data('EventName') = event_name

            tags = td(4).find_all(('p', 'ul'))
            for tag in tags:
                param_name = tag.find('u')
                if param_name:
                    data('ParameterName') = cleanhtml(param_name)

                data('ParametersVariants') = (cleanhtml(li).split('-')(0) for li in tag.find_all('li'))
                # data('ParametersVarDescription') = (cleanhtml(li).split('-')(1) for li in tag.find_all('li'))
                print(data)


        except IndexError:
            pass


def cleanhtml(html):
    return re.compile('<.*?>').sub('', str(html)).replace('xa0', '')


if __name__ == '__main__':
    prepare_events()

Sorry for my google language!

algorithm – Assessing BigO/small o for forming a dynamic dictionary based on searched key and values pair

I am trying to create a dictionary with a file containing text based on a matched pattern. Lines containing key_str should become keys and subsequent lines not matching key_str should become values and get associated with keys in the dictionary. so i have below code working: But I need help and getting the Big O analysis. How could i say my logic is worth case, Best Case or good case? Also, which case is small o and which is big O

File: file2dict.result-soa1

ml1
/var
/home

cpuml2
/var
/home


Output

my_dict: {ml1: ('/var','/home'), cpuml2: ('/var','/home')}

Code:

import os
homedir = os.environ.get('HOME')

key_str = "ml"
my_dict = {}
val_list = ()
key = ''
with open(homedir + '/backup/file2dict.result-soa1') as file2dict:
    for line in file2dict:
        words = line.split()
        for aWord in words:
            if key_str in aWord:
                if key:
                    my_dict(key) = val_list
                    val_list = ()
                    key = aWord
                else:
                    key = aWord
            else:
                val_list.append(aWord)
    my_dict(key) = val_list
print(my_dict)

Is there any way to mirror an entire Online Dictionary website?

I want to mirror https://dictionary.cambridge.org/us/ to my local directory to read the definitions offline. Is there any way to do it with the wget command?

dictionary look up highlighted word NOT mouse hover

I am going to ask this question again because I haven’t been able to get this to work yet. Is there a way for looking up words that are highlighted only without hovering the mouse?

I am using macos Catalina currently.

brute force – Dictionary Attack Calculation

If I have a dictionary of passwords and have gained knowledge of usernames of a target site, how long will it take me to check all the passwords against the usernames if I have a computer that can test 1 billion combinations a second?

What formula should I use? Say I have 1 million dictionary passwords and know 500 000 usernames.

Need help on how to delete certain type of lists in a dictionary using phython, jupyter notebook

enter image description here

Hey guys so my question is that I need to get rid of the second dispositionid out of the nested list and I tried doing del[15][0] however it deletes it all? do you guys know how to get rid of the second dispositionid since there is 2?

this is what I got and this is wrong. Thanksenter image description here

nt.number theory – Dictionary of arithmetic symmetries and Langlands

This question has been on my mind for some time and Sunday seems to be a good day for asking an intuition-begging/confirming question.

To a number theorist automorphic forms appear to be adelic point-counting generating functions for arithmetic schemes. This is what the conjectured equality of their L functions tells us.

The fact that these generating functions are highly symmetric (Hecke action) seems to correspond to the fact that arithmetic schemes are highly symmetric (Galois action). That is why we try to match up Hecke symmetries with Galois symmetries when proving their relationship.

If we think of algebraic groups together with their arithmetic subgroups as the repository of all the arithmetic symmetries that can arise in nature, it seems reasonable that when a new source of these symmetries shows up in the form of Galois action on an arithmetic scheme, we want to look up this comprehensive dictionary of arithmetic symmetries to understand it.

Is this a good clue to the awesome mystery that is arithemetic Langlands correspondence? Would this count as a moral justification for the conjecture, Langlands’ achievement being not only intuiting this, but also providing an indexing for the dictionary for this purpose?

Even if the intuition is valid as far as it goes, it leaves big questions to think about, starting with “why only reductive groups?”, which I’d love to understand.

Provided there is something to it, does this kind of thinking (algebraic groups+arithmetic subgroups as all possible arithmetic symmetries and Langlands as a program for finding Galois symmetries among them) available somewhere to read? Thanks!

vb.net – Are good practice to use SKPointI as key for dictionary

In my application I using SKPoinI as a key to store some small objects in Dictionary. SkiaSharp already used in this project for drawing and not need to be referred to only to allow SKPointI to be used as a key.

At first look, it’s a good and simple solution, but I not sure because as I presume that the SkiaSharp library primarily optimized for graphics.

Maybe better create a structure that has two Int32 as coordinates and implementation of IEqitable, or create combined Int64 via BitConverter to be used as the key

key = BitConverter.ToInt64(BitConverter.GetBytes(x).Concat(BitConverter.GetBytes(y)).ToArray)

and get x and y from a key with code like:

With BitConverter.GetBytes(key)
    x = BitConverter.ToInt32(.Take(4).ToArray)
    y = BitConverter.ToInt32(.Skip(4).ToArray)
End With

What way is better if the application will add objects only once on the initial stage and then accesses them frequently?

I already using the key for 3D-storage:

Public Structure Adr3D
    Implements IEquatable(Of Adr3D)

#Region "Public Constructors"

    Public Sub New(x As Integer, y As Integer, z As Integer)
        Me.X = x
        Me.Y = y
        Me.Z = z
    End Sub

#End Region

#Region "Public Properties"

    Public ReadOnly Property X As Integer

    Public ReadOnly Property Y As Integer

    Public ReadOnly Property Z As Integer

#End Region

#Region "Public Methods"

    Public Shared Operator <>(left As Adr3D, right As Adr3D) As Boolean
        Return Not left.Equals(right)
    End Operator

    Public Shared Operator =(left As Adr3D, right As Adr3D) As Boolean
        Return left.Equals(right)
    End Operator

    Public Overrides Function Equals(obj As Object) As Boolean
        Return TypeOf obj Is Adr3D AndAlso Equals(DirectCast(obj, Adr3D))
    End Function

    Public Overloads Function Equals(other As Adr3D) As Boolean Implements IEquatable(Of Adr3D).Equals
        Return X = other.X AndAlso Y = other.Y AndAlso Z = other.Z
    End Function

    Public Overrides Function GetHashCode() As Integer
        Return HashCode.Combine(X, Y, Z)
    End Function

    Public Overrides Function ToString() As String
        Return $"{{X = {X}, Y = {Y}, Z = {Z}}}"
    End Function

#End Region

End Structure

In fact, it is not a question of “How to implement?”, but “What is more efficient?”

Thanks for any advice!

python – Create dictionary from CSV where column names are keys

I’m trying to read a csv file (actually a tsv, but nvm) and set it as a dictionary where its key are the column names of said csv and the rest of the rows are values for those keys.
I also have some comments marked by the “https://stackoverflow.com/#” character, which I intend to ignore:

csv_in.csv

##Some comments
##Can ignore these lines
Location   Form                  Range         <-- This would be the header
North      Dodecahedron          Limited       <---|
East       Toroidal polyhedron   Flexible      <------ These lines would be lists
South      Icosidodecahedron     Limited       <---| 

The main idea is to store them like this:

final_dict = {'Location': ('North','East','South'), 
'Form': ('Dodecahedron','Toroidal polyhedron','Icosidodecahedron'),
'Range': ('Limited','Flexible','Limited')}

So far I could come close like so:

tryercode.py

import csv
dct = {}

# Open csv file
with open(tsvfile) as file_in:
# Open reader instance with tab delimeter
reader = csv.reader(file_in, delimiter='t')
# Iterate through rows 
for row in reader:
    # First I skip those rows that start with "https://stackoverflow.com/#"
    if row(0).startswith("https://stackoverflow.com/#"):
        pass
    elif row(0).startswith('L'):
        # Here I try to keep the first row that starts with the letter 'L' in a separate list
        # and insert this first row values as keys with empty lists inside
        dictkeys_list = ()
        for i in range(len(row)):
            dictkeys_list.append(row(i))
            dct(row(i)) = ()
    else:
        # Insert each row indexes as values by the quantity of rows
        print('¿?')

So far, the dictionary’s skeleton looks fine:

print(dct)
{'Location': (), 'Form': (), 'Range': ()}

But everything I tried so far failed to append the values to the keys’ empty lists the way it is intended. Only could do so for the first row.

        (...)
    else:
        # Insert each row indexes as values by the quantity of rows
        print('¿?')
        for j in range(len(row)):
            dct(dictkeys_list(j)) = row(j)   # Here I indicate the intented key of the dict through the preoviously list of key names

I searched far and wide stackoverflow but couldn’t find it for this way (the code template is inspired by an answer at this post, but the dictionary is of a different structure.