jueves, 27 de octubre de 2022

Detecció de duplicats en llistes - FuzzyWuzzy (Python)

from fuzzywuzzy import fuzz

with open('C:/Users/JF/Desktop/llistaNoms.txt','r',encoding='utf-8') as f:
    my_list = list(f)

for i in range(len(my_list)-1):
    for j in range(i+1,len(my_list)):
        Str1=(my_list[i])
        Str2=(my_list[j])
        Ratio = fuzz.ratio(Str1.lower(),Str2.lower())
        Partial_Ratio = fuzz.partial_ratio(Str1.lower(),Str2.lower())
        Token_Sort_Ratio = fuzz.token_sort_ratio(Str1,Str2)
        Token_Set_Ratio = fuzz.token_set_ratio(Str1,Str2)
        
        if (Ratio>80)|(Partial_Ratio>80)|(Token_Sort_Ratio>80)|(Token_Set_Ratio>80):
            print(i+1,j+1, Ratio, Partial_Ratio,Token_Sort_Ratio,Token_Set_Ratio)

viernes, 21 de octubre de 2022

Combinació de valors de dues columnes ABCD... i abcd... resultant Aa Ab Ac Ad... Ba Bb Bc Bd... (Excel VBA) Alt+F11

 Sub Macro1()

Dim CantFilaCol1 As Long
Dim CantFilaCol2 As Long
Dim m As Single

CantFilaCol1 = Cells(Rows.Count, 1).End(xlUp).Row
CantFilaCol2 = Cells(Rows.Count, 2).End(xlUp).Row

m = CantFilaCol1 + 2

For fCol1 = 1 To CantFilaCol1 Step 1
    For fCol2 = 1 To CantFilaCol2 Step 1
        Cells(m, 1).Value = Cells(fCol1, 1).Value & " " & Cells(fCol2, 2).Value
        m = m + 1
    Next fCol2
Next fCol1

End Sub

jueves, 6 de octubre de 2022

Afegir text en un vídeo - OBS + OpenShot Video + Processing

Amb l'OBS hem gravat un vídeo-tutorial. 

Volem anotar textos al vídeo. Són frases curtes que volem sobreescriure al vídeo.

Utilitzem el programa OpenShot Video. Allà podem descarregar els textos en format SVG

Per tal d'agilitzar la creació dels textos, automatitzem el procés amb Processing. El programa desa els frames.

El fitxer list.txt conté el text que volem que aparegui. És una matriu amb frases. El processing crearà tantes imatges SVG com linies que contingui el fitxer list.txt .

import processing.svg.*;
int i,iLast,llargada;

void setup() {
size(400, 400);
}

void draw() {
    beginRecord(SVG, "C:/.../frame-####.svg");
    String[] lines = loadStrings("C:/.../list.txt");
    int llargada=lines.length;
    textSize(60); fill(0, 408, 612);
    text(lines[iLast], 40, 150, 280, 320);
    if (iLast+1==llargada){
      endRecord();
      exit();
    }
    iLast++;
}