<svg viewBox="0 0 6 6" xmlns="http://www.w3.org/2000/svg">
<!-- Effect of the (default) "butt" value -->
<line x1="1" y1="1" x2="5" y2="1" stroke="black" stroke-linecap="butt" />
<!-- Effect of the "round" value -->
<line x1="1" y1="3" x2="5" y2="3" stroke="black" stroke-linecap="round" />
<!-- Effect of the "square" value -->
<line x1="1" y1="5" x2="5" y2="5" stroke="black" stroke-linecap="square" />
<!--
the following pink lines highlight the
position of the path for each stroke
-->
<path d="M1,1 h4 M1,3 h4 M1,5 h4" stroke="pink" stroke-width="0.025" />
</svg>
class Node:
def __init__(self,text):
self.text = text
self.last = 0
self.output = ""
self.child = {}
self.fail = None
self.rank = 0
def show(self):
print( "text:", self.text, "output:",self.output, "fail:", self.fail.text if self.fail is not None else "None","rank:",self.rank)
if self.last:
print( "LAST OUTPUT : ", self.output)
for k in self.child.keys():
s = self.child[k]
s.show()
class AhocorasickTrie:
def __init__(self):
self.no = 0
self.root = Node(None)
def add(self,text):
rank = 0
currentNode = self.root
for t in text:
if t not in currentNode.child:
self.no +=1
currentNode.child[t] = Node(t)
print(f"ADD : {t} || Current No. : {self.no}")
currentNode.rank = rank
rank+=1
currentNode = currentNode.child[t]
currentNode.output = text
currentNode.last = 1
currentNode.rank = rank
print(f"TOTAL : {self.no}")
def set_failur(self):
queue = []
for c,node in self.root.child.items():
node.fail = self.root
queue.append(node)
while queue:
currentNode = queue.pop(0)
for t,node in currentNode.child.items():
fail_node = currentNode.fail
while fail_node and t not in fail_node.child:
fail_node = fail_node.fail
if fail_node:
node.fail = fail_node.child[t]
else:
node.fail = self.root
queue.append(node)
def show(self):
self.root.display()
def find(self,text):
result = []
currentNode = self.root
for t in text:
while currentNode is not None and t not in currentNode.child:
print("fail",currentNode.text)
currentNode = currentNode.fail
if t in currentNode.child:
currentNode = currentNode.child[t]
if currentNode.output != "":
result += [currentNode.output]
print(result,t,currentNode.output,currentNode.last,currentNode.output)
return result
class Node:
def __init__(self,text):
self.text = text
self.last = 0
self.child = {}
class Trie:
def __init__(self):
self.no = 0
self.root = Node(None)
def add(self,text):
currentNode = self.root
for t in text:
if t not in currentNode.child:
self.no +=1
currentNode.child[t] = Node(t)
print(f"ADD : {t} || Current No. : {self.no}")
currentNode = currentNode.child[t]
currentNode.last = 1
print(f"TOTAL : {self.no}")
def find(self,text):
result = ""
currentNode = self.root
for t in text:
if t in currentNode.child:
result += t
currentNode = currentNode.child[t]
return result
intro의 경우에는 main과 똑같이 flex 속성을 가지지만, flex-direction 값으로 column 을 주어 세로로 flex 속성 값들을 반영해 줍니다. 각 태그들의 사이를 8px 정도로 띄어줍니다. width는 100% 이지만, 400px은 넘어가지 않게 max-width 값을 주었고, 양옆으로 padding 70px 씩 입력해 줍니다.