Skip to content

Instantly share code, notes, and snippets.

@ShapeLayer
Last active August 31, 2021 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShapeLayer/78cfae2ee8d48179e09c2a4d002368ef to your computer and use it in GitHub Desktop.
Save ShapeLayer/78cfae2ee8d48179e09c2a4d002368ef to your computer and use it in GitHub Desktop.

HangulSeperator

주의

8월 31일 이전 SeperatedHangul 클래스는 현재 문서의 SeperatedHangul 클래스와 큰 차이를 가지고 있습니다. HangulSeperator가 사용하고 있는 SeperatedHangul 클래스가 어느 시기에 작성된 클래스인지 확인해야합니다.
8월 31일 이후에 작성된 코드에는 첫 줄에 관련 정보가 주석으로 작성되어있습니다.

/*
    Author: Park, Jonghyeon
    Last Update: 2021-08-31 05:34:00
*/

HangulSeperator 클래스는 한글 자모 분리 기능을 담당합니다. 한글 자모 분리 기능은 Seperate 메서드를 통해 사용할 수 있습니다.

HangulSeperatorDebugger 프리팹은 실 사용 예시를 위해 첨부한 것으로, 동명의 클래스 스크립트를 컴포넌트로 갖는 게임 오브젝트입니다.

정적 메서드

이름 설명
SeperatedHangul Seperate(string content) content의 한글 자모를 분리합니다.

예시

예시 1

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HangulSeperatorDebugger : MonoBehaviour
{
    [ContextMenu("DebugSeperateHangul")] void DebugSeperateHangul() 
    { 
        SeperatedHangul li = HangulSeperator.Seperate("테스트 문장 ㅎㅎ!");
        foreach (char i in li.normal) { print($"{(int)i} {i}"); }
    }
}

예시 2

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HangulSeperatorDebugger : MonoBehaviour
{
    [ContextMenu("DebugSeperateHangul")] void DebugSeperateHangul() 
    { 
        SeperatedHangul li = HangulSeperator.Seperate("테스트 문장 ㅎㅎ!");
        foreach (char i in li.full) { print($"{(int)i} {i}"); }
    }
}

SeperatedHangul

[System.Serializable]
class SeperatedHangul
{
  public SeperatedHangul(string Content) { content = Content; }
  public SeperatedHangul(string Content, List<char> Full, List<char> Normal, List<char> NormalSeperated, List<int> NormalCode) { content = Content; full = Full; normal = Normal; normalSeperated = NormalSeperated; normalCode = NormalCode; }
}

속성

이름 설명
string content 분리 이전의 전체 문장입니다.
List<char> full 분리된 한글 자모와 한글 외 다른 문자를 포함하는 char 리스트입니다.
List<char> normal 분리된 한글 자모만 포함하는 char 리스트입니다.
List<char> normalSeperated 복잡한 형태의 종성 한글 자모를 단순한 한글 자모로 분리한 char 리스트입니다.
List<int> normalCode 내부 규칙에 따라 normalSeperated를 정수로 변환한 결과 리스트입니다.
  • 내부 규칙은 프로젝트 공유 드라이브 [2]한국문화기술연구소 > 2차년도 수어단어집 > 수어단어집 제작_21.08.26.xlsxJH(지화) 시트를 기반으로 합니다.

메서드

이름 설명
Add(char Content) Content를 full, normal, normalSeperated에 모두 추가하고, 내부 규칙에 따라 변환하여 normalCode에 내부 정수 코드를 추가합니다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment