제 질문은 오늘입니다 :
패턴과 일치하는 모든 단어를 찾을 수있는 함수를 만들려면 어떻게해야합니까?구조체 목록에서 단어를 검색하고 접미사가있는 단어를 모두 얻으십시오.
예를 들어 우리는 단어가 duck
이고, 우리는 그 단어 오리에서 시작하는 모든 단어를 찾고 싶습니다.
나는 성능 최적화 기능을 찾고 있는데 LINQ를 사용할 수 있다면 기쁠 것입니다.
public List<List<string>> FindWordsPostfix(List<Parameters.Words> wordsChess, List<string> wordsFromDictionary, int width)
{
List<List<string>> listPostfixForstructxIndex = new List<List<string>>();
foreach (Parameters.Words structx in wordsChess)
{
//1for each structx I have some parameters eg. name, length, index
//2for each word (name) I need find word from dict. starting that word(name)
//list storing lists of words for each of the structx object
List<string> list = new List<string>();
foreach (String wordDictionary in wordsFromDictionary)
{
Match match = Regex.Match(wordDictionary, structx.word, RegexOptions.IgnoreCase);
if(match.Success && (match.Length > structx.length))
{
list.Add(match.Value);
}
}
//add list of words to main list
listPostfixForstructxIndex.Add(list);
}
throw new NotImplementedException();
}
Parameters.Words
포함하는 구조체는 다음과 같습니다 : string name, int length, etc..
은 지금까지 나는 그런 일 (아직 작동하지 않습니다)를했다.
왜 내 기능이 좋지 않고 데이터를 저장하지 않습니까?
PS2. 나는 그 질문을 편집했다. 나는 그 일을 정리해야했다. 성냥의 길이가 결코 구조체의 길이보다 더 될 것 없다
아마도 _helloing_가 비활성화되었습니다. 하지만 아무런 인사도없이 질문을 작성할 수 있습니다.) – Abel
코드를 읽은 후에도 무엇을 하려는지 확실하지 않습니다. 일련의 글자 또는 패턴으로 끝나는 단어를 찾고 싶지만 목록에 목록이있는 이유를 이해하지 못하는 것 같습니다. – Dracorat
@Dracorat 질문을 편집 할 수 있습니다. 내 영어가 너무 나쁘면 내 질문을 수정해야합니다. 그러나 나는 다시 설명하려고 노력할 것이다 :) 이것은 예이다 : 나는 단어'금지'를 가지고 있고 결과가 될 수 있도록'ban'로 시작하는 모든 단어를 찾고 싶다 : 우리는'List'을 저장하고있다 :'banner''bans'' 은행가 '등으로 목록에 올렸습니다. 목록의 색인은 다른 기능을 필요로합니다. 그럴거야. –
deadfish