如何从给定的单词中获得不同的句子组合,并在给定的句子列表中搜索它们 [英] how to get different combinations of the sentences from the given words and also search them in the given list of sentences

查看:95
本文介绍了如何从给定的单词中获得不同的句子组合,并在给定的句子列表中搜索它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我试图编写一个搜索程序代码,在那里我将能够用一个用户输入并应显示结果的句子搜索给定的序列列表。也就是说,程序应该能够获得句子中的所有单词并尝试搜索下面的所有单词组合来制作不同的句子并将其与给定的句号相匹配。该句子包含n个单词。

例如,如果我们考虑一个3个单词的句子hello world program,它应该尝试将给定列表与下面给出的以下组合的发送匹配,然后显示匹配的发送结果

Hello world program

Hello program world

世界你好计划

世界节目你好

节目你好世界

节目世界你好

我所知道的是,第一个字保持不变然后是其他所有n -1个单词应该放在不同的位置,然后用任何其他n-1个单词改变第一个单词,剩下的所有单词应该准备剩余的n-1个单词

我需要帮助...有人可以帮助我这个算法提前感谢。

解决方案

这可能比你想要的要多得多,但它是一个好的起点:使用C#泛型的组合,组合和变体 [ ^ ]


我可能会对两者进行排序句子(单词列表)而不是试图找到排列,尽管可以在找到候选人之后完成。

您也可以使用单词而不是字符来使用Levenshtein Distance的变体。然后你可以有一些确定候选人的门槛距离。



http:/ /en.wikipedia.org/wiki/Levenshtein_distance [ ^

Hi all !!
I was trying to code a search program , where I will be able to search a given list of sentances with one sentence that that the user inputs and should display the results . that is the program should be able to get all the words in the sentence and try searching for all the following word combinationsto make different sentences and match it with the given sentances. Herre the sentence contains n words.
For example if we consider a 3 word sentence "hello world program " it should try and match the given list with the following combinations of the sentances that are given below and then display the result of the matched sentances
Hello world program
Hello program world
World hello program
World program hello
Program hello world
Program world hello
What I know till now is that put the first word is kept constant then all the other n-1 words should be put in different possitions then change first word with any other n-1 word and all the remaining words should accupy the remaining n-1 possitions
I need help… can somebody help me with the algorithm for this thanks a ton in advance.

解决方案

This is probably quite a bit more than you wanted, but it''s a good place to start: Permutations, Combinations, and Variations using C# Generics[^]


I would likely sort both sentences (lists of words) rather than try to find the permutations, though that could be done after a candidate is found.
You might also be able to use a variation of Levenshtein Distance using words rather than characters. You could then have some threshold distance for determining candidates.

http://en.wikipedia.org/wiki/Levenshtein_distance[^]


这篇关于如何从给定的单词中获得不同的句子组合,并在给定的句子列表中搜索它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆