1

パブリケーション管理のための非常に大規模な実装をストレステストするためのテストユニットを構築しようとしています。NLTK を使用して、記事のさまざまな事柄やランダムなタイトルについての段落を生成することを考えました。

NLTK はそのようなことを行うことができますか? さまざまなレイアウトのサイズをテストするために、各記事を独自のものにしたいと考えています。科目も同じようにしたいです。

PS Am は、最終的に多くのこと (パフォーマンス、検索、レイアウトなど) をテストするために使用される 100 万以上の記事を生成する必要があります。

誰でもアドバイスできますか?

4

1 に答える 1

6

これを使用しました。ノーム・チョムスキーからフレーズを受け取り、ランダムな段落を生成します。原料のテキストを好きなように変更できます。もちろん、使用するテキストが多ければ多いほどよいでしょう。

# List of LEADINs to buy time.
leadins = """To characterize a linguistic level L,
        On the other hand,
        This suggests that
        It appears that
        Furthermore """

# List of SUBJECTs chosen for maximum professorial macho.
subjects = """ the notion of level of grammaticalness
        a case of semigrammaticalness of a different sort
        most of the methodological work in modern linguistics
        a subset of English sentences interesting on quite independent grounds
        the natural general principle that will subsume this case """

#List of VERBs chosen for autorecursive obfuscation.
verbs = """can be defined in such a way as to impose
        delimits
        suffices to account for
        cannot be arbitrary in
        is not subject to """


# List of OBJECTs selected for profound sententiousness.

objects = """ problems of phonemic and morphological analysis.
        a corpus of utterance tokens upon which conformity has been defined by the paired utterance test.
        the traditional practice of grammarians.
        the levels of acceptability from fairly high (e.g. (99a)) to virtual gibberish (e.g. (98d)).
        a stipulation to place the constructions into these various categories.
        a descriptive fact.
        a parasitic gap construction."""

import textwrap, random
from itertools import chain, islice, izip
from time import sleep

def chomsky(times=1, line_length=72):
    parts = []
    for part in (leadins, subjects, verbs, objects):
        phraselist = map(str.strip, part.splitlines())
        random.shuffle(phraselist)
        parts.append(phraselist)
    output = chain(*islice(izip(*parts), 0, times))
    return textwrap.fill(' '.join(output), line_length)

print chomsky()

それは私のために戻った:

これは、異なる種類の半文法性のケースが、ペアの発話テストによって適合性が定義されている発話トークンのコーパスの対象ではないことを示唆しています。

そしてタイトルについては、もちろんあなたはすることができます

chomsky().split('\n')[0]
于 2012-12-13T13:12:01.563 に答える