• Как создать матрицу с количеством вхождений слова в предложение?

    @Kapasim988 Автор вопроса
    Kapasim988, у меня количество элементов в result = 5588, то есть выдает 22 предложения в каждом из которых 254 числа. Почему так получилось?
  • Как создать матрицу с количеством вхождений слова в предложение?

    @Kapasim988 Автор вопроса
    o5a я применяю такую команду result = [[sentence.count(word) for word in new_list] for sentence in output]

    в результате мне выдает список, в котором чисел больше, чем слов. В чем ошибка?
  • Как создать матрицу с количеством вхождений слова в предложение?

    @Kapasim988 Автор вопроса
    o5a, привет, можешь пожалуйста ответить еще на 1 вопрос? Вот мой список списков. Также у меня есть список уникальных слов

    output = [['in', 'comparison', 'to', 'dogs', 'cats', 'have', 'not', 'undergone', 'major', 'changes', 'during', 'the', 'domestication', 'process'], ['as', 'cat', 'simply', 'catenates', 'streams', 'of', 'bytes', 'it', 'can', 'be', 'also', 'used', 'to', 'concatenate', 'binary', 'files', 'where', 'it', 'will', 'just', 'concatenate', 'sequence', 'of', 'bytes'], ['a', 'common', 'interactive', 'use', 'of', 'cat', 'for', 'a', 'single', 'file', 'is', 'to', 'output', 'the', 'content', 'of', 'a', 'file', 'to', 'standard', 'output'], ['cats', 'can', 'hear', 'sounds', 'too', 'faint', 'or', 'too', 'high', 'in', 'frequency', 'for', 'human', 'ears', 'such', 'as', 'those', 'made', 'by', 'mice', 'and', 'other', 'small', 'animals'], ['in', 'one', 'people', 'deliberately', 'tamed', 'cats', 'in', 'a', 'process', 'of', 'artificial', 'selection', 'as', 'they', 'were', 'useful', 'predators', 'of', 'vermin'], ['the', 'domesticated', 'cat', 'and', 'its', 'closest', 'wild', 'ancestor', 'are', 'both', 'diploid', 'organisms', 'that', 'possess', 'chromosomes', 'and', 'roughly', 'genes'], ['domestic', 'cats', 'are', 'similar', 'in', 'size', 'to', 'the', 'other', 'members', 'of', 'the', 'genus', 'felis', 'typically', 'weighing', 'between', 'and', 'kg', 'and', 'lb'], ['however', 'if', 'the', 'output', 'is', 'piped', 'or', 'redirected', 'cat', 'is', 'unnecessary'], ['cat', 'with', 'one', 'named', 'file', 'is', 'safer', 'where', 'human', 'error', 'is', 'a', 'concern', 'one', 'wrong', 'use', 'of', 'the', 'default', 'redirection', 'symbol', 'instead', 'of', 'often', 'adjacent', 'on', 'keyboards', 'may', 'permanently', 'delete', 'the', 'file', 'you', 'were', 'just', 'needing', 'to', 'read'], ['in', 'terms', 'of', 'legibility', 'a', 'sequence', 'of', 'commands', 'starting', 'with', 'cat', 'and', 'connected', 'by', 'pipes', 'has', 'a', 'clear', 'left', 'to', 'right', 'flow', 'of', 'information'], ['cat', 'command', 'is', 'one', 'of', 'the', 'basic', 'commands', 'that', 'you', 'learned', 'when', 'you', 'started', 'in', 'the', 'unix', 'linux', 'world'], ['using', 'cat', 'command', 'the', 'lines', 'received', 'from', 'stdin', 'can', 'be', 'redirected', 'to', 'a', 'new', 'file', 'using', 'redirection', 'symbols'], ['when', 'you', 'type', 'simply', 'cat', 'command', 'without', 'any', 'arguments', 'it', 'just', 'receives', 'the', 'stdin', 'content', 'and', 'displays', 'it', 'in', 'the', 'stdout'], ['leopard', 'was', 'released', 'on', 'october', 'as', 'the', 'successor', 'of', 'tiger', 'version', 'and', 'is', 'available', 'in', 'two', 'editions'], ['according', 'to', 'apple', 'leopard', 'contains', 'over', 'changes', 'and', 'enhancements', 'over', 'its', 'predecessor', 'mac', 'os', 'x', 'tiger'], ['as', 'of', 'mid', 'some', 'apple', 'computers', 'have', 'firmware', 'factory', 'installed', 'which', 'will', 'no', 'longer', 'allow', 'installation', 'of', 'mac', 'os', 'x', 'leopard'], ['since', 'apple', 'moved', 'to', 'using', 'intel', 'processors', 'in', 'their', 'computers', 'the', 'osx', 'community', 'has', 'developed', 'and', 'now', 'also', 'allows', 'mac', 'os', 'x', 'tiger', 'and', 'later', 'releases', 'to', 'be', 'installed', 'on', 'non', 'apple', 'x', 'based', 'computers'], ['os', 'x', 'mountain', 'lion', 'was', 'released', 'on', 'july', 'for', 'purchase', 'and', 'download', 'through', 'apple', 's', 'mac', 'app', 'store', 'as', 'part', 'of', 'a', 'switch', 'to', 'releasing', 'os', 'x', 'versions', 'online', 'and', 'every', 'year'], ['apple', 'has', 'released', 'a', 'small', 'patch', 'for', 'the', 'three', 'most', 'recent', 'versions', 'of', 'safari', 'running', 'on', 'os', 'x', 'yosemite', 'mavericks', 'and', 'mountain', 'lion'], ['the', 'mountain', 'lion', 'release', 'marks', 'the', 'second', 'time', 'apple', 'has', 'offered', 'an', 'incremental', 'upgrade', 'rather', 'than', 'releasing', 'a', 'new', 'cat', 'entirely'], ['mac', 'os', 'x', 'mountain', 'lion', 'installs', 'in', 'place', 'so', 'you', 'won', 't', 'need', 'to', 'create', 'a', 'separate', 'disk', 'or', 'run', 'the', 'installation', 'off', 'an', 'external', 'drive'], ['the', 'fifth', 'major', 'update', 'to', 'mac', 'os', 'x', 'leopard', 'contains', 'such', 'a', 'mountain', 'of', 'features', 'more', 'than', 'by', 'apple', 's', 'count']]

    new_list = ['in', 'comparison', 'to', 'dogs', 'cats', 'have', 'not', 'undergone', 'major', 'changes', 'during', 'the', 'domestication', 'process', 'as', 'cat', 'simply', 'catenates', 'streams', 'of', 'bytes', 'it', 'can', 'be', 'also', 'used', 'concatenate', 'binary', 'files', 'where', 'will', 'just', 'sequence', 'a', 'common', 'interactive', 'use', 'for', 'single', 'file', 'is', 'output', 'content', 'standard', 'hear', 'sounds', 'too', 'faint', 'or', 'high', 'frequency', 'human', 'ears', 'such', 'those', 'made', 'by', 'mice', 'and', 'other', 'small', 'animals', 'one', 'people', 'deliberately', 'tamed', 'artificial', 'selection', 'they', 'were', 'useful', 'predators', 'vermin', 'domesticated', 'its', 'closest', 'wild', 'ancestor', 'are', 'both', 'diploid', 'organisms', 'that', 'possess', 'chromosomes', 'roughly', 'genes', 'domestic', 'similar', 'size', 'members', 'genus', 'felis', 'typically', 'weighing', 'between', 'kg', 'lb', 'however', 'if', 'piped', 'redirected', 'unnecessary', 'with', 'named', 'safer', 'error', 'concern', 'wrong', 'default', 'redirection', 'symbol', 'instead', 'often', 'adjacent', 'on', 'keyboards', 'may', 'permanently', 'delete', 'you', 'needing', 'read', 'terms', 'legibility', 'commands', 'starting', 'connected', 'pipes', 'has', 'clear', 'left', 'right', 'flow', 'information', 'command', 'basic', 'learned', 'when', 'started', 'unix', 'linux', 'world', 'using', 'lines', 'received', 'from', 'stdin', 'new', 'symbols', 'type', 'without', 'any', 'arguments', 'receives', 'displays', 'stdout', 'leopard', 'was', 'released', 'october', 'successor', 'tiger', 'version', 'available', 'two', 'editions', 'according', 'apple', 'contains', 'over', 'enhancements', 'predecessor', 'mac', 'os', 'x', 'mid', 'some', 'computers', 'firmware', 'factory', 'installed', 'which', 'no', 'longer', 'allow', 'installation', 'since', 'moved', 'intel', 'processors', 'their', 'osx', 'community', 'developed', 'now', 'allows', 'later', 'releases', 'non', 'based', 'mountain', 'lion', 'july', 'purchase', 'download', 'through', 's', 'app', 'store', 'part', 'switch', 'releasing', 'versions', 'online', 'every', 'year', 'patch', 'three', 'most', 'recent', 'safari', 'running', 'yosemite', 'mavericks', 'release', 'marks', 'second', 'time', 'offered', 'an', 'incremental', 'upgrade', 'rather', 'than', 'entirely', 'installs', 'place', 'so', 'won', 't', 'need', 'create', 'separate', 'disk', 'run', 'off', 'external', 'drive', 'fifth', 'update', 'features', 'more', 'count']
  • Как создать матрицу с количеством вхождений слова в предложение?

    @Kapasim988 Автор вопроса
    o5a, спасибо большое, не знаю почему в 1 раз такое не сработало, 1 в 1 было, ты мне очень помог
  • Как создать матрицу с количеством вхождений слова в предложение?

    @Kapasim988 Автор вопроса
    Спасибо, в общем я создал список списков такого вида [['in', 'comparison', 'to', 'dogs', 'cats', 'have', 'not', 'undergone', 'major', 'changes', 'during', 'the', 'domestication', 'process'], ['as', 'cat', 'simply', 'catenates', 'streams', 'of', 'bytes'] и список из уникальных слов ['in', 'comparison', 'to', 'dogs', 'cats', 'have', 'not', 'undergone', 'major', 'changes', 'during', 'the', 'domestication', 'process', 'as', 'cat', 'simply', 'catenates', 'streams', 'of', 'bytes'], я написал эту строку, которую вы сказали [[sentence.count(word) for word in unique_words] for sentence in sentences], но у меня вывелись все нули, что делать?
  • Как решить задачу на симметричную пару в массиве на python?

    @Kapasim988 Автор вопроса
    Andy_U действительно последний элемент n-1, спасибо за подсказку