-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTokenization.fs
47 lines (43 loc) · 1.89 KB
/
Tokenization.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace ArcGraphModel.IO
open ArcGraphModel
open FsSpreadsheet
open KeyParser
module Tokenization =
let convertTokens (line : FsCell seq) =
match line |> Seq.toList with
| [] -> failwith "Cannot convert nothin"
| key :: [] ->
let f = parseKey [] key.Value
[f (ParamValue.Value "")]
| key :: cells ->
let f = parseKey [] key.Value
cells
|> List.map (fun c ->
let param = f (ParamValue.Value c.Value)
CvAttributeCollection.tryAddAttribute (Address.createRowParam(c.RowNumber)) param |> ignore
CvAttributeCollection.tryAddAttribute (Address.createColumnParam(c.ColumnNumber)) param |> ignore
param
)
let parseLine (line : FsCell seq) =
match line |> Seq.toList |> List.filter (fun c -> c.Value <> "") with
| [] -> seq []
| [Container (ContainerBase.investigationContacts) container]
| [Container (ContainerBase.investigationPublication) container] ->
container
|> CvAttributeCollection.tryAddAttribute (CvParam(Terms.investigation,""))
|> ignore
[container] |> Seq.cast<ICvBase>
| [Container (ContainerBase.studyContacts) container]
| [Container (ContainerBase.studyAssays) container]
| [Container (ContainerBase.studyDesignDescriptors) container]
| [Container (ContainerBase.studyFactors) container] ->
container
|> CvAttributeCollection.tryAddAttribute (CvParam(Terms.study,""))
|> ignore
[container] |> Seq.cast<ICvBase>
| [Container (ContainerBase.investigation) container]
| [Container (ContainerBase.study) container] ->
[container] |> Seq.cast<ICvBase>
| line ->
convertTokens line
|> Seq.cast<ICvBase>