"AKA"및 "FKA"와 같은 별칭 토큰이있는 법원의 사례 캡션을 구문 분석하는 우아한 방법을 찾고 있습니다. 다음 캡션과 마찬가지로 별칭 유형을 검색해야합니다. 짐승 같은 솔루션을 강요했지만 다른 옵션이 있는지보고 싶습니다. 나는 Linq를 좋아하고 Sprache를 시도했지만 그 주위에 내 머리를 감쌀 수 없었다.우아한 LINQ 텍스트 구문 분석 옵션이 있습니까?
Example caption:
JOHN SMITH AKA JOHN R SMITH FKA JOHNNY R SMITH
Desired output:
Alias Type Found: AKA
Alias Caption Found: JOHN R SMITH
Alias Type Found: FKA
Alias Caption Found: JOHNNY R SMITH
다음은 LinqPad에서 지금까지 던진 내용입니다.
void Main()
{
var caption = "JOHN SMITH AKA JOHN R SMITH FKA JOHNNY R SMITH";
caption.Split().ParseAliases((t,c)=>{
Console.WriteLine ("Alias Type Found: {0}",t);
Console.WriteLine ("Alias Caption Found: {0}",c);
});
}
public delegate void AliasRetrievedDelegate(string aliasType, string aliasCaption);
public static class ParserExtensions{
private static IEnumerable<string> aliasTypes = new[]{"AKA","FKA"};
public static void ParseAliases(this IEnumerable<string> tokens,
aliasRetrievedDelegate d,
int startIdx = 0){
// TODO
}
}
LINQ가 아닌 정규식 작업과 비슷합니다. –
저의 생각은 저의 첫 번째 생각이었습니다. 좀 더 쉽게 확장 할 수있는 미니 DSL 라인을 따라 좀 더 읽기 쉬운 솔루션을 원합니다. – Ken