알고리즘 오류 및 잘못된 수학 환경 구분 기호

알고리즘 오류 및 잘못된 수학 환경 구분 기호

라텍스로 의사 코드를 작성하는 데 많은 어려움을 겪고 있습니다. 아래 두 가지 알고리즘을 검토해 보세요. 문서에서 알고리즘은 그림에서 강조 표시된 부분을 제외하면 좋아 보입니다.

여기에 이미지 설명을 입력하세요

\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.

여기에 이미지 설명을 입력하세요

MWE

\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}

관련 정보