Package org.languagetool.dev.conversion.cg

Examples of org.languagetool.dev.conversion.cg.CgCompositeTag$AnyTag


  private ArrayList<CgSet> groupCompositeTags(CgSet target) {
    HashMap<String,ArrayList<CgCompositeTag>> bf = new HashMap<String,ArrayList<CgCompositeTag>>();
    HashMap<String,ArrayList<CgCompositeTag>> sf = new HashMap<String,ArrayList<CgCompositeTag>>();
    HashMap<String,CgCompositeTag> dict = new HashMap<String,CgCompositeTag>()// dictionary of sorts
    for (CgCompositeTag ctag : target.tags) {
      CgCompositeTag postags = new CgCompositeTag();
      CgCompositeTag baseforms = new CgCompositeTag();
      CgCompositeTag surfaceforms = new CgCompositeTag();
      for (CgTag tag : ctag.tags) {
        if (isBaseForm(tag.tag)) {
          baseforms.addTag(tag);
        } else if (isSurfaceForm(tag.tag)) {
          surfaceforms.addTag(tag);
        } else if (isPostag(tag.tag)) {
          postags.addTag(tag);
        }
      }
      if (!postags.isEmpty()) {
        if (!baseforms.isEmpty()) {
          bf = (HashMap)smartPut(bf, postags.toString(), baseforms);
        }
        else if (!surfaceforms.isEmpty()) {  // assumes there won't be both sf and bf in the same composite tag
          sf = (HashMap)smartPut(sf, postags.toString(), surfaceforms);
        }
      }
      dict.put(postags.toString(), postags);
    }
    ArrayList<CgSet> ret = new ArrayList<CgSet>();
    for (String postagSet : bf.keySet()) {
      CgSet newSet = new CgSet(target);
      newSet.tags = new HashSet<CgCompositeTag>();
      ArrayList<CgCompositeTag> bfs = bf.get(postagSet);
      for (CgCompositeTag singleBf : bfs) {
        CgCompositeTag newTotalTag = new CgCompositeTag();
        for (CgTag tag : dict.get(postagSet).tags) {
          newTotalTag.addTag(tag);
        }
        for (CgTag tag : singleBf.tags) {
          newTotalTag.addTag(tag);
        }
        newSet.addCompositeTag(newTotalTag);
      }
      ret.add(newSet);
    }
View Full Code Here


    }
    HashSet<String> pos = new HashSet<String>();
    HashSet<String> base = new HashSet<String>();
    HashSet<String> surf = new HashSet<String>();
    for (CgCompositeTag ctag : token.compositeTags) {
      CgCompositeTag postagCompile = new CgCompositeTag();
      for (CgTag tag : ctag.tags) {
        if (isPostag(tag.tag)) {
          postagCompile.addTag(tag);
        } else if (isSurfaceForm(tag.tag)) {
          surf.add(tag.tag);
        } else if (isBaseForm(tag.tag)) {
          base.add(tag.tag);
        }
      }
      pos.add(postagCompile.toString());
    }
    if (pos.size() > 1 && (surf.size() > 1 || base.size() > 1)) {
      return false;
    }
    if (surf.size() > 1 && base.size() > 1) {
View Full Code Here

    // also, if there're composite tags, they should have the same postags component, and not both base and surface forms
    if (compositeTags.length != 0) {
      ArrayList<String> baseformsList = new ArrayList<String>();
      ArrayList<String> surfaceformsList = new ArrayList<String>();
      for (CgCompositeTag ctag : compositeTags) {
        CgCompositeTag postagCompiled = new CgCompositeTag();
        for (CgTag tag : ctag.tags) {
          if (isPostag(tag.tag)) {
            postagCompiled.addTag(tag);
          } else if (isBaseForm(tag.tag)) {
            baseformsList.add(tag.tag);
          } else if (isSurfaceForm(tag.tag)) {
            surfaceformsList.add(tag.tag);
          }
View Full Code Here

          for (CgTag tag : expandedSet1.single_tags) {
            for (CgTag tag2 : expandedSet2.single_tags) {
              if (tag.tag.equals(tag2.tag)) {
                newSet.addTag(tag);
              } else {
                CgCompositeTag ctag = new CgCompositeTag();
                ctag.addTag(tag);
                ctag.addTag(tag2);
                newSet.addCompositeTag(ctag);
              }
            }
          }
          for (CgCompositeTag ctag : expandedSet1.tags) {
            for (CgTag tag : expandedSet2.single_tags) {
              if (ctag.tags.contains(tag)) {
                newSet.addCompositeTag(ctag);
              } else {
                CgCompositeTag ctagnew = new CgCompositeTag();
                for (CgTag tag2 : ctag.tags) {
                  ctagnew.addTag(tag2);
                }
                ctagnew.addTag(tag);
                newSet.addCompositeTag(ctagnew);
              }
            }
          }
          for (CgCompositeTag ctag : expandedSet2.tags) {
            for (CgTag tag : expandedSet1.single_tags) {
              if (ctag.tags.contains(tag)) {
                newSet.addCompositeTag(ctag);
              } else {
                CgCompositeTag ctagnew = new CgCompositeTag();
                for (CgTag tag2 : ctag.tags) {
                  ctagnew.addTag(tag2);
                }
                ctagnew.addTag(tag);
                newSet.addCompositeTag(ctagnew);
              }
            }
          }
          for (CgCompositeTag ctag : expandedSet1.tags) {
            for (CgCompositeTag ctag2 : expandedSet2.tags) {
              CgCompositeTag ctagnew = new CgCompositeTag();
              for (CgTag tag : ctag.tags) {
                if (!ctagnew.tags.contains(tag)) {
                  ctagnew.addTag(tag);
                }
              }
              for (CgTag tag : ctag2.tags) {
                if (!ctagnew.tags.contains(tag)) {
                  ctagnew.addTag(tag);
                }
              }
              newSet.addCompositeTag(ctagnew);
            }
          }
View Full Code Here

  private List<CgSet> groupCompositeTags(CgSet target) {
    HashMap<String,ArrayList<CgCompositeTag>> bf = new HashMap<>();
    Map<String, ArrayList<CgCompositeTag>> sf = new HashMap<>();
    Map<String, CgCompositeTag> dict = new HashMap<>()// dictionary of sorts
    for (CgCompositeTag ctag : target.tags) {
      CgCompositeTag postags = new CgCompositeTag();
      CgCompositeTag baseforms = new CgCompositeTag();
      CgCompositeTag surfaceforms = new CgCompositeTag();
      for (CgTag tag : ctag.tags) {
        if (isBaseForm(tag.tag)) {
          baseforms.addTag(tag);
        } else if (isSurfaceForm(tag.tag)) {
          surfaceforms.addTag(tag);
        } else if (isPostag(tag.tag)) {
          postags.addTag(tag);
        }
      }
      if (!postags.isEmpty()) {
        if (!baseforms.isEmpty()) {
          bf = (HashMap)smartPut(bf, postags.toString(), baseforms);
        }
        else if (!surfaceforms.isEmpty()) {  // assumes there won't be both sf and bf in the same composite tag
          sf = (HashMap)smartPut(sf, postags.toString(), surfaceforms);
        }
      }
      dict.put(postags.toString(), postags);
    }
    List<CgSet> ret = new ArrayList<>();
    for (String postagSet : bf.keySet()) {
      CgSet newSet = new CgSet(target);
      newSet.tags = new HashSet<>();
      Iterable<CgCompositeTag> bfs = bf.get(postagSet);
      for (CgCompositeTag singleBf : bfs) {
        CgCompositeTag newTotalTag = new CgCompositeTag();
        for (CgTag tag : dict.get(postagSet).tags) {
          newTotalTag.addTag(tag);
        }
        for (CgTag tag : singleBf.tags) {
          newTotalTag.addTag(tag);
        }
        newSet.addCompositeTag(newTotalTag);
      }
      ret.add(newSet);
    }
View Full Code Here

    }
    Collection<String> pos = new HashSet<>();
    Collection<String> base = new HashSet<>();
    Collection<String> surf = new HashSet<>();
    for (CgCompositeTag ctag : token.compositeTags) {
      CgCompositeTag postagCompile = new CgCompositeTag();
      for (CgTag tag : ctag.tags) {
        if (isPostag(tag.tag)) {
          postagCompile.addTag(tag);
        } else if (isSurfaceForm(tag.tag)) {
          surf.add(tag.tag);
        } else if (isBaseForm(tag.tag)) {
          base.add(tag.tag);
        }
      }
      pos.add(postagCompile.toString());
    }
    if (pos.size() > 1 && (surf.size() > 1 || base.size() > 1)) {
      return false;
    }
    if (surf.size() > 1 && base.size() > 1) {
View Full Code Here

    // also, if there're composite tags, they should have the same postags component, and not both base and surface forms
    if (compositeTags.length != 0) {
      ArrayList<String> baseformsList = new ArrayList<>();
      ArrayList<String> surfaceformsList = new ArrayList<>();
      for (CgCompositeTag ctag : compositeTags) {
        CgCompositeTag postagCompiled = new CgCompositeTag();
        for (CgTag tag : ctag.tags) {
          if (isPostag(tag.tag)) {
            postagCompiled.addTag(tag);
          } else if (isBaseForm(tag.tag)) {
            baseformsList.add(tag.tag);
          } else if (isSurfaceForm(tag.tag)) {
            surfaceformsList.add(tag.tag);
          }
View Full Code Here

          for (CgTag tag : expandedSet1.single_tags) {
            for (CgTag tag2 : expandedSet2.single_tags) {
              if (tag.tag.equals(tag2.tag)) {
                newSet.addTag(tag);
              } else {
                CgCompositeTag ctag = new CgCompositeTag();
                ctag.addTag(tag);
                ctag.addTag(tag2);
                newSet.addCompositeTag(ctag);
              }
            }
          }
          for (CgCompositeTag ctag : expandedSet1.tags) {
            for (CgTag tag : expandedSet2.single_tags) {
              if (ctag.tags.contains(tag)) {
                newSet.addCompositeTag(ctag);
              } else {
                CgCompositeTag ctagnew = new CgCompositeTag();
                for (CgTag tag2 : ctag.tags) {
                  ctagnew.addTag(tag2);
                }
                ctagnew.addTag(tag);
                newSet.addCompositeTag(ctagnew);
              }
            }
          }
          for (CgCompositeTag ctag : expandedSet2.tags) {
            for (CgTag tag : expandedSet1.single_tags) {
              if (ctag.tags.contains(tag)) {
                newSet.addCompositeTag(ctag);
              } else {
                CgCompositeTag ctagnew = new CgCompositeTag();
                for (CgTag tag2 : ctag.tags) {
                  ctagnew.addTag(tag2);
                }
                ctagnew.addTag(tag);
                newSet.addCompositeTag(ctagnew);
              }
            }
          }
          for (CgCompositeTag ctag : expandedSet1.tags) {
            for (CgCompositeTag ctag2 : expandedSet2.tags) {
              CgCompositeTag ctagnew = new CgCompositeTag();
              for (CgTag tag : ctag.tags) {
                if (!ctagnew.tags.contains(tag)) {
                  ctagnew.addTag(tag);
                }
              }
              for (CgTag tag : ctag2.tags) {
                if (!ctagnew.tags.contains(tag)) {
                  ctagnew.addTag(tag);
                }
              }
              newSet.addCompositeTag(ctagnew);
            }
          }
View Full Code Here

TOP

Related Classes of org.languagetool.dev.conversion.cg.CgCompositeTag$AnyTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.