Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

code for search missing #2

Open
robomotic opened this issue Jun 20, 2019 · 2 comments
Open

code for search missing #2

robomotic opened this issue Jun 20, 2019 · 2 comments

Comments

@robomotic
Copy link

Hello,
I can see the code to create the tree but there isn't an example about how to use it to search for a string.
This is very important of course to measure performance.
Cheers.

@pwrliang
Copy link
Owner

pwrliang commented Jun 21, 2019

Hi there,

The struct of tree node like this:

class TreeNode implements Serializable, Cloneable {
int index; // the index of String list
int start; // the start of index of that string
int end; // the end of index of that string
int suffix_index = -1; // the index in the string of suffix
}

We don't store substring in TreeNode for saving memory but we store the index of string. If we have a list of string like: List S. We can get substring which is stored in the TreeNode t by S.get(t.index).substring(t.start, t.end).

You can easily implement a search or endsWith method by the information on the TreeNode.

I had wrote a method "void traverseTree(List S, TreeNode root, Map<Character, String> terminatorFileName, Set result)" which only output the leaf node of the suffix tree.

Which search method do you need, e.g. contains substring, endsWith...?
Feel free to ask if you have any questions.

Regards,
Liang

@robomotic
Copy link
Author

Yes makes sense, I am not that good with Java but I am assuming you will have to first deserialize from the file output to the TreeNode object, would like to see some example code for that.

Yes I would like to see starstwith, endswith and contains implemented as a method.
That would be great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants