アルゴリズムエラーと不正な数学環境区切り文字

アルゴリズムエラーと不正な数学環境区切り文字

私は LaTeX で疑似コードを書くのに苦労しています。以下の 2 つのアルゴリズムを確認してください。ドキュメントでは、画像で強調表示されている部分を除けば、アルゴリズムは良さそうです。

ここに画像の説明を入力してください

\begin{algorithm}
\caption{Incident Description and Text Separation}
\label{algo:1}
\KwIn{Text file T of all the Incidents}
\KwOut{Short description and Updates of each Incident as a .CSV fIle \(c\).}
split T if line in T begins with `Incident:'\\
\For{\textup{each split of} \(e\) in T}
{
     Short description \Leftarrow \( \) Line starting with 'short\textunderscore description:'\\
     Updates \Leftarrow \( \) Line starting with 'sys\textunderscore mod\textunderscore count:'\\
}
\end{algorithm}
\begin{algorithm}
\caption{Preprocessing the description field of each incident   \(i\)}
\label{algo:2}
\KwIn{Short description of each incident \(i\)}
\KwOut{Preprocessed short descriptions to single strings.}
convert description of each incident \(i\) to lowercase\\
stopwords \Leftarrow \( \) repeatedly occurring words and person names\\
\For{\textup{each incident} i}
{
  \If{\textup{\textit{word }in short description} \in stopwords}{\textup{replace \(word\) with nothing}}
  \endIf
\textup{remove all special symbols \& characters}\\
\textup{remove all extra line \& word spaces}\\
}
\end{algorithm}

答え1

アルゴリズムを挿入するために使用していると思いますalgorithm2e

また、数式モードでは数式記号を挿入する必要があります。例: $\Leftarrow$

最後に、 を削除しますEndif

ここに画像の説明を入力してください

ムウェ

\documentclass[11pt,a4paper]{report}
\usepackage{amsthm,amsmath,amssymb}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{algorithm2e}

\begin{document}
\begin{algorithm}
\caption{Preprocessing the description field of each incident $i$}
\label{algo:2}
\KwIn{Short description of each incident $i$.}
\KwOut{Preprocessed short descriptions to single strings.}
convert description of each incident $i$ to lowercase\\
stopwords $\Leftarrow$ repeatedly occurring words and person names\\
\For{\textup{each incident} $i$}
{
  \If{\textup{\textit{word} in short description $\in$ \textit{stopwords}}}{\textup{replace \textit{word} with nothing}}
  \textup{remove all special symbols \& characters}\\
  \textup{remove all extra line \& word spaces}\\
}
\end{algorithm}
\end{document}

関連情報