Natural Language Processing an der TU München | Karteikarten & Zusammenfassungen

# Lernmaterialien für Natural Language Processing an der TU München

Greife auf kostenlose Karteikarten, Zusammenfassungen, Übungsaufgaben und Altklausuren für deinen Natural Language Processing Kurs an der TU München zu.

TESTE DEIN WISSEN

How are the newline and the tab character referred to? (regular expression)

Lösung anzeigen
TESTE DEIN WISSEN

newline character \n and the

tab character \t

Lösung ausblenden
TESTE DEIN WISSEN

How can you replace any occurence of 'colour' with 'color' using regular expression?

Lösung anzeigen
TESTE DEIN WISSEN

For example, the substitution operator s/regexp1/pattern/ allows a string characterized by a regular expression to be replaced by another string:
s/colour/color/

Lösung ausblenden
TESTE DEIN WISSEN

How can you replace every occurence of 35 with <35> using regular expression?

Hint: You need the substitution operator.

Lösung anzeigen
TESTE DEIN WISSEN

We’d like a way to refer to the integer we’ve found so that we can easily add the brackets. To do this, we put parentheses ( and ) around the ﬁrst pattern and use the number operator \1 in the second pattern to refer back. Here’s how it looks:

s/([0-9]+)/<\1>/

Lösung ausblenden
TESTE DEIN WISSEN

How can you specify that a string or expression must occur twice?

Lösung anzeigen
TESTE DEIN WISSEN

We do this by surrounding the ﬁrst X with the parenthesis operator, and replacing the second X with the number operator \1, as follows:
/the (.*)er they were, the \1er they will be/

Lösung ausblenden
TESTE DEIN WISSEN

What is a capture group?

Lösung anzeigen
TESTE DEIN WISSEN

The use of parentheses to store a pattern in memory is called a capture group.

Lösung ausblenden
TESTE DEIN WISSEN

What are the two functions of parantheses in regular expression?

Lösung anzeigen
TESTE DEIN WISSEN

Parentheses thus have a double function in regular expressions; they are used to group terms for specifying the order in which operators should apply, and they are
used to capture something in a register.

Lösung ausblenden
TESTE DEIN WISSEN

The double function of the parentheses operator would cause a pattern to be stored in register. How can you prevent this?

Lösung anzeigen
TESTE DEIN WISSEN

In that case we use a non-capturing group, which is speciﬁed by putting the commands ?: after the open paren, in the form (?: pattern ).

Lösung ausblenden
TESTE DEIN WISSEN

How can we ﬁnd any line in which a particular word, for example, aardvark, appears twice?

Lösung anzeigen
TESTE DEIN WISSEN

We can specify this with the regular expression /aardvark.*aardvark/.

Lösung ausblenden
TESTE DEIN WISSEN

Which regular expression do you need to search for word boundaries?

Lösung anzeigen
TESTE DEIN WISSEN

\b matches a word boundary

Lösung ausblenden
TESTE DEIN WISSEN

What is a word boundary (regular exression)?

Lösung anzeigen
TESTE DEIN WISSEN

A “word” for a regular expression is deﬁned as any sequence of digits, underscores, or letters.

Lösung ausblenden
TESTE DEIN WISSEN

How can you search for either car or dog?

Lösung anzeigen
TESTE DEIN WISSEN

using a disjunction operator:

The pattern /cat|dog/ matches either the string cat or the string dog.

Lösung ausblenden
TESTE DEIN WISSEN

Which operator is used to give precedence?

Lösung anzeigen
TESTE DEIN WISSEN

parenthesis operators ( and ):

So the pattern /gupp(y|ies)/ would specify that we meant the disjunction only to apply to the sufﬁxes y and ies.

Lösung ausblenden
• 356460 Karteikarten
• 8257 Studierende
• 335 Lernmaterialien

## Beispielhafte Karteikarten für deinen Natural Language Processing Kurs an der TU München - von Kommilitonen auf StudySmarter erstellt!

Q:

How are the newline and the tab character referred to? (regular expression)

A:

newline character \n and the

tab character \t

Q:

How can you replace any occurence of 'colour' with 'color' using regular expression?

A:

For example, the substitution operator s/regexp1/pattern/ allows a string characterized by a regular expression to be replaced by another string:
s/colour/color/

Q:

How can you replace every occurence of 35 with <35> using regular expression?

Hint: You need the substitution operator.

A:

We’d like a way to refer to the integer we’ve found so that we can easily add the brackets. To do this, we put parentheses ( and ) around the ﬁrst pattern and use the number operator \1 in the second pattern to refer back. Here’s how it looks:

s/([0-9]+)/<\1>/

Q:

How can you specify that a string or expression must occur twice?

A:

We do this by surrounding the ﬁrst X with the parenthesis operator, and replacing the second X with the number operator \1, as follows:
/the (.*)er they were, the \1er they will be/

Q:

What is a capture group?

A:

The use of parentheses to store a pattern in memory is called a capture group.

Q:

What are the two functions of parantheses in regular expression?

A:

Parentheses thus have a double function in regular expressions; they are used to group terms for specifying the order in which operators should apply, and they are
used to capture something in a register.

Q:

The double function of the parentheses operator would cause a pattern to be stored in register. How can you prevent this?

A:

In that case we use a non-capturing group, which is speciﬁed by putting the commands ?: after the open paren, in the form (?: pattern ).

Q:

How can we ﬁnd any line in which a particular word, for example, aardvark, appears twice?

A:

We can specify this with the regular expression /aardvark.*aardvark/.

Q:

Which regular expression do you need to search for word boundaries?

A:

\b matches a word boundary

Q:

What is a word boundary (regular exression)?

A:

A “word” for a regular expression is deﬁned as any sequence of digits, underscores, or letters.

Q:

How can you search for either car or dog?

A:

using a disjunction operator:

The pattern /cat|dog/ matches either the string cat or the string dog.

Q:

Which operator is used to give precedence?

A:

parenthesis operators ( and ):

So the pattern /gupp(y|ies)/ would specify that we meant the disjunction only to apply to the sufﬁxes y and ies.

### Erstelle und finde Lernmaterialien auf StudySmarter.

Greife kostenlos auf tausende geteilte Karteikarten, Zusammenfassungen, Altklausuren und mehr zu.

## Das sind die beliebtesten StudySmarter Kurse für deinen Studiengang Natural Language Processing an der TU München

Für deinen Studiengang Natural Language Processing an der TU München gibt es bereits viele Kurse, die von deinen Kommilitonen auf StudySmarter erstellt wurden. Karteikarten, Zusammenfassungen, Altklausuren, Übungsaufgaben und mehr warten auf dich!

LMU München