I
I
iscateli2014-12-24 15:11:05
Artificial intelligence
iscateli, 2014-12-24 15:11:05

What algorithms for identifying patterns exist?

And what kinds of regularities are there?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Armenian Radio, 2014-12-24
@gbg

The topic is huge. Start at least with a wiki .

X
xmoonlight, 2014-12-24
@xmoonlight

Abstraction
Approximation
Modeling
Interpolation
Extrapolation
Oka's approximation theorem

S
Sly_tom_cat ., 2017-05-15
@Iqv

You can, as dimonchik2013 suggested, or you can really use a split and just use a dictionary, set is only needed to work out the case when you need to sort out the lexicographic order.

#!/usr/bin/env python3

counts = dict()
with open('input.txt', 'rt') as fin:
    for line in fin:
        for word in line.split():
            counts[word] = counts.get(word, 0) + 1
    max = 0
    max_word = set()
    for word, cnt in counts.items():
        if cnt > max:
            max_word = {word}
            max = cnt
        if cnt == max:
            max_word.add(word)
    with open('output.txt', 'wt') as fout:
        fout.write(min(max_word))

By the way, in your code there is nothing specifically about the lexicographic order when choosing a word from the list (those for which the maximum occurrence is equal and maximum).
And one more thing: Reading the file in one Czech is not entirely correct. In a task, it can be 1MB, but in real life it can be 1TB - and you will immediately create an overflow crash - it's not a fact that this crash cannot be used to hack the system, for example.

D
Dimonchik, 2017-05-15
@dimonchik2013

itertools groupby()
collections counter()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question