Example #1
0
from queue import Queue
from bintree import Bintree

ordl = open('word3').read().split()

svenska = Bintree()
gamla = Bintree()

for o in ordl:
    svenska.put(o)

alfabet = "qweryuiopåasdfgjklöäzxcvbnm"

bfsqueue = Queue()


class bfsnode:
    value = None
    parent = None

    def __init__(self, value, parent):
        self.value = value
        self.parent = parent


def makesons(o, end):
    word = o.value
    for c in alfabet:
        for i in range(len(word)):
            if c == word[i]:
                continue
Example #2
0
from bintree import Bintree

tree = Bintree()
print("Putta in ord, avsluta med retur")
while True:
    word = input()
    if word == "": break
    tree.put(word)
    print("Hela trädet:")
    tree.write()
    print("Sök ord, avsluta med retur")
    while True:
        word = input()
        if word == "":
            break
        if tree.exists(word):
            print(word, "finns")
Example #3
0
File: fanextra.py Project: Hkau/kth
#Av: Cecilia Bruhn, fanextra
fil=open("word3")
ordlista=fil.read().split()

from bintree import Bintree
from queue import Queue

q2=Queue()
q=Queue()
svenska=Bintree()           #träd med ordlistan

for ord in ordlista:
    svenska.put(ord)        #stoppar in orden från ordlistan i svenska binärträdet och skriver ut dubletterna

gamla=Bintree()             #träd med alla besökta ord

class Node:					#skapar en ny nod klass
    value=None
    parent=None
    def __init__(self, value, parent):		#ser till att noden tar fler än en parameter
        self.value=value
        self.parent=parent

#startord=Node(None,None)
#slutord=Node(None,None)
startord=input("Ordet där du vill börja:")
#slutord=input("Ordet du vill gå till:")
      
def makesons(nod):
    alfabetet="qwertyuiopåasdfghjklöäzxcvbnm"
    for tecken in alfabetet:
Example #4
0
File: labb.py Project: Hkau/kth
from bintree import Bintree

f = open("word3")

ordlista = f.readlines()

for i in range(len(ordlista)):
	ordlista[i] = ordlista[i].rstrip()

swedish = Bintree()

for ord in ordlista:
	swedish.put(ord)

f.close()

f = open("english")

ordlista = f.read().split()

oldtree = Bintree()

for i in range(len(ordlista)):
	ordlista[i] = ordlista[i].strip('",.')

print (ordlista)

for o in ordlista:
	if oldtree.exists(o):
		continue
Example #5
0
File: fan.py Project: Hkau/kth
from queue import Queue
from bintree import Bintree

ordl = open('word3').read().split()

svenska = Bintree()
gamla = Bintree()

for o in ordl:
	svenska.put(o)

alfabet = "qweryuiopåasdfgjklöäzxcvbnm"

bfsqueue = Queue()

class bfsnode:
	value=None
	parent=None

	def __init__(self, value, parent):
		self.value = value
		self.parent = parent

def makesons(o, end):
	word = o.value
	for c in alfabet:
		for i in range(len(word)):
			if c == word[i]:
				continue
			child = word[:i] + c + word[i+1:]
Example #6
0
def main():
    svenska = Bintree()
    engelska = Bintree()
    readFiles(svenska)
    readFilesE(engelska, svenska)
Example #7
0
from bintree import Bintree

f = open("word3")

ordlista = f.readlines()

for i in range(len(ordlista)):
    ordlista[i] = ordlista[i].rstrip()

swedish = Bintree()

for ord in ordlista:
    swedish.put(ord)

f.close()

f = open("english")

ordlista = f.read().split()

oldtree = Bintree()

for i in range(len(ordlista)):
    ordlista[i] = ordlista[i].strip('",.')

print(ordlista)

for o in ordlista:
    if oldtree.exists(o):
        continue
    if swedish.exists(o):
Example #8
0
from bintree import Bintree

tree=Bintree()
print("Putta in ord, avsluta med retur")
while True:
	word=input()
	if word=="": break
	tree.put(word)
	print("Hela trädet:")
	tree.write()
	print("Sök ord, avsluta med retur")
	while True:
		word=input()
		if word=="":
			break
		if tree.exists(word):
			print(word,"finns")

Example #9
0
fil = open("word3.txt")
ordlista = fil.read().split()
from bintree import Bintree

svenska = Bintree()  #träd med ordlistan
for ord in ordlista:
    svenska.put(ord)  #stoppar in orden från ordlistan i svenska binärträdet
gamla = Bintree()  #träd med alla besökta ord
startord = input("Ordet där du vill börja:")
slutord = input("Ordet du vill gå till:")


def makesons(o):
    alfabetet = "qwertyuiopåasdfghjklöäzxcvbnm"
    for tecken in alfabetet:
        for i in range(len(o)):
            child = o[:i] + tecken + o[i + 1:]
            if svenska.exists(child) and not gamla.exists(child):
                gamla.put(child)
                print(child)


makesons(startord)
Example #10
0
File: cecilia.py Project: Hkau/kth
fil=open("word3.txt")
ordlista=fil.read().split()
from bintree import Bintree
svenska=Bintree()           #träd med ordlistan
for ord in ordlista:
	svenska.put(ord)        #stoppar in orden från ordlistan i svenska binärträdet
gamla=Bintree()             #träd med alla besökta ord
startord=input("Ordet där du vill börja:")
slutord=input("Ordet du vill gå till:")
def makesons(o):
	alfabetet="qwertyuiopåasdfghjklöäzxcvbnm"
	for tecken in alfabetet:
		for i in range(len(o)):
			child=o[:i]+tecken+o[i+1:]
			if svenska.exists(child)and not gamla.exists(child):
				gamla.put(child)
				print(child)

makesons(startord)
Example #11
0
#Av: Cecilia Bruhn, fanextra
fil = open("word3")
ordlista = fil.read().split()

from bintree import Bintree
from queue import Queue

q2 = Queue()
q = Queue()
svenska = Bintree()  #träd med ordlistan

for ord in ordlista:
    svenska.put(
        ord
    )  #stoppar in orden från ordlistan i svenska binärträdet och skriver ut dubletterna

gamla = Bintree()  #träd med alla besökta ord


class Node:  #skapar en ny nod klass
    value = None
    parent = None

    def __init__(self, value,
                 parent):  #ser till att noden tar fler än en parameter
        self.value = value
        self.parent = parent


#startord=Node(None,None)
#slutord=Node(None,None)