Exact string matching

How do I write a code, that finds repeated words from an input file and prints those with its position, i.e. (where it was found)

댓글 수: 4

Jan
Jan 2011년 10월 15일
Please post, what you have done already and ask for a specific question. This forum is not a programming robot and we will not solve your homework.
Gurusaran
Gurusaran 2011년 10월 16일
Dear Simon,
I have scripted the above mentioned problem in perl and I am just curious and a bit sure that it can can also be done in matlab(I am new to matlab). More over, mine is just a naive algorithm. My aim is to implement efficient string algorithms like Suffix array or Suffix tree. All I wanted to know is, Is it feasible to implement such complicated algorithm in matlab or is there any better way doing this in matlab.
Gurusaran
Gurusaran 2011년 10월 16일
And brother, this is not my homework nor you have to do it for me, I'm just curious and need a kick start.
Jan
Jan 2011년 10월 16일
Ok, no homework. Even if you are new at Matlab, I assume you can implement the reading of a text file by your own. Then it would be useful if you implement as much as you can and ask a specific question. For such general questions there is a discrepancy between the effort needed to create a meaningful answer, and the effort shown by the author.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2011년 10월 16일

0 개 추천

Read the file in to a string, newlines and all. Use regex() to extract the "words" and corresponding locations (for whatever you define a "word" to be.) Use the three-output form of unique() to get the unique words and the corresponding indices into the original list of words. Index the location list by that index list to get the word positions.
Biggest trick: you will need to set two optional modes for regex, as shown here

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2011년 10월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by