Algorithm to match one input file with given numbers of file

后端 未结 3 707
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 09:17

I had an interview last week. I was stuck in one of the question in algorithm round. I answered that question, but the interviewer did not seem convinced. That\'s why I am s

相关标签:
3条回答
  • 2021-01-05 10:08

    You can create some kind of indexing (example: trie) to summarize the input file. Then you can check how many indices match across documents.

    Eg. Create a trie for input file for length 10. For every string of length 10 (overlapping) in the text files check how many of them match in the trie.

    0 讨论(0)
  • 2021-01-05 10:14

    As a suggestion for designing really capable, scalable systems for document similarity I'd suggest reading Chapter 3 of Mining Massive Datasets, which is freely available online. One approach presented there is to 'shingle' datasets by vectorizing word counts into sets, then hashing those word counts and comparing families of hashes results with Jaccard similarity to get a score between all documents. This can work on petabytes of files with high precision if done right. Explicit details with good diagrams can be read off Stanford's CS246 Slides on Locality Sensitive Hashing. Simpler approaches like word frequency counting are described in the book as well.

    0 讨论(0)
  • 2021-01-05 10:16

    diff them and pass through wc -l, or implement Levenshtein distance in C++ treating each line as a single character (or any more appropriate unit condidering the subject domain)

    0 讨论(0)
提交回复
热议问题