Analiza začetkov priimkov / Python

Uporabil sem rešitve iz Analiza končnic priimkov / Python.

s = "poskus"
v =  ""
for z in s:
    u = v+"_"; v = v+z    
    print(u,v if v==s else v+"_")
_ p_
p_ po_
po_ pos_
pos_ posk_
posk_ posku_
posku_ poskus

Izgradnja drevesa končnic

Uporabil sem podatke priimki2.zip opisane v Priimek Batagelj.

t1 = datetime.now(); print("started: ",t1.ctime(),"\n")
Q = N(); Q.addNode("_")
with open('priimki2.csv', newline='',encoding='windows-1250') as csvfile:
   csvR = csv.reader(csvfile, delimiter=';', quotechar='"')
   r = 0; print("header:",csvR.__next__())
   for row in csvR:
      r = r+1; w = row[1]
      p = row[0].lower(); t = ""; v = "_"
      for z in p:
         u = v; t = t+z; v = t if t==p else t+"_"  
         if not(v in Q.nodes()): Q.addNode(v)    
         a = Q.addArc(u,v,{'w':w})
t2 = datetime.now(); print("\nconverted to network: ",t2.ctime(),"\ntime used: ", t2-t1)
print(i,'records processed')

setXY(Q,'_')
Q.savePajek('priimkiZ.net',ini="",coord=True)
started:  Sun Oct  3 02:19:05 2021 

header: ['priimek', 'N']

converted to network:  Sun Oct  3 02:34:49 2021 
time used:  0:15:43.922032
31796 records processed

==============================================================================
27. Simplification (NUM) of N25 (92468)
==============================================================================
Number of vertices (n): 92468
----------------------------------------------------------
                                       Arcs          Edges
----------------------------------------------------------
Number of lines with value=1          75785              0
Number of lines with value#1          16682              0
----------------------------------------------------------
Total number of lines                 92467              0
----------------------------------------------------------
Number of loops                           0              0
Number of multiple lines                  0              0
----------------------------------------------------------
spomin/vlado/rod/init.txt · Last modified: 2021/10/03 03:14 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki