Найти - Пользователи
Полная версия: -
Начало » Центр помощи » -
1 2
thanqurewelcome
-
thanqurewelcome


-
thanqurewelcome
-
Budulianin
thanqurewelcome
Напишите код, который будет рещать следующую задачу
thanqurewelcome
новичку-девушке
: D
sergeek
Неужели на филфаке стали заставлять программировать?
Singularity
thanqurewelcome
Внимание: для решения этой задачи достаточно того, что уже было рассмотрено на занятиях.
и какие могут быть вопросы ?
sergeek
import re
sentences = 'Computational linguistics is an interdisciplinary field concerned with the statistical or rule-based modeling of natural language from a computational perspective.', 'Traditionally, computational linguistics was usually performed by computer scientists who had specialized in the application of computers to the processing of a natural language.', ' Computational linguists often work as members of interdisciplinary teams, including linguists (specifically trained in linguistics), language experts (persons with some level of ability in the languages relevant to a given project), and computer scientists.', ' In general, computational linguistics draws upon the involvement of linguists, computer scientists, experts in artificial intelligence, mathematicians, logicians, philosophers, cognitive scientists, cognitive psychologists, psycholinguists, anthropologists and neuroscientists, among others.', 'Computational linguistics has theoretical and applied components, where theoretical computational linguistics takes up issues in theoretical linguistics and cognitive science, and applied computational linguistics focuses on the practical outcome of modeling human language use.'
word = 'computer'
regex = re.compile('(?:^|\W){}(?:\W|$)'.format(word), re.I)
for sentence in sentences:
    if regex.search(sentence):
        print(sentence)
Singularity
sergeek
чего ты всяким трансам помогаешь ?
sergeek
Singularity
sergeekчего ты всяким трансам помогаешь ?
не знаю, мне нравится
2
import re
 
mark_spec = {
    'ellipsis '         : ' \.{3} ?'
    ,'dot'              : '\. ?'
    ,'comma'            : ', ?'
    ,'exclamation mark' : '! ?'
    ,'question mark'    : '\? ?'
    ,'colon'            : ': '
    ,'dash'             : ' - ?'
}
 
regex = re.compile('(?:{})+'.format('|'.join(mark_spec.values())))
 
def split(text):
    for name, mark in mark_spec.items():
        if re.search(mark, text):
            print('...see {} here'.format(name))
            
    print('The segments of your text are:')    
    for s in re.split(regex, text):
        print(s)
    
def main():
    while True:
        split(input('Your text, please: ').replace('"',''))
  
main()
thanqurewelcome
-
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB